wwctl should return non-zero exit code on wwctl power sub-commands

Signed-off-by: xu yang <xyang@ciq.com>
This commit is contained in:
xu yang
2024-09-30 06:41:53 +00:00
parent 617e1b9e5a
commit 65f67b79ba
13 changed files with 31 additions and 48 deletions

View File

@@ -1,4 +1,4 @@
package powercycle
package cycle
import (
"fmt"
@@ -17,14 +17,12 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
nodeDB, err := node.New()
if err != nil {
wwlog.Error("Could not open node configuration: %s", err)
os.Exit(1)
return fmt.Errorf("could not open node configuration: %s", err)
}
nodes, err := nodeDB.FindAllNodes()
if err != nil {
wwlog.Error("Could not get node list: %s", err)
os.Exit(1)
return fmt.Errorf("could not get node list: %s", err)
}
if len(args) > 0 {
@@ -36,8 +34,7 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
}
if len(nodes) == 0 {
fmt.Printf("No nodes found\n")
os.Exit(1)
return fmt.Errorf("no nodes found")
}
batchpool := batch.New(50)

View File

@@ -1,4 +1,4 @@
package powercycle
package cycle
import (
"github.com/spf13/cobra"