Skip to content

Commit

Permalink
adding back changes, addressing comments
Browse files Browse the repository at this point in the history
  • Loading branch information
manasachi committed Jan 30, 2024
1 parent 787e75a commit ca41bc8
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 19 deletions.
32 changes: 15 additions & 17 deletions cmd/kperf/commands/virtualcluster/nodepool.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"strings"

"github.com/Azure/kperf/virtualcluster"
"helm.sh/helm/v3/pkg/release"

"github.com/urfave/cli"
)
Expand Down Expand Up @@ -92,28 +93,25 @@ var nodepoolListCommand = cli.Command{
Name: "list",
Usage: "List virtual node pools",
Action: func(cliCtx *cli.Context) error {
fmt.Println("In List command")
kubeCfgPath := cliCtx.String("kubeconfig")
nodepools, err := virtualcluster.ListNodepools(context.Background(), kubeCfgPath)
fmt.Println("after getting nodepools")
if err != nil {
return err
}
fmt.Println("No error :)")
fmt.Println("Number of nodepools: \n", len(nodepools))
fmt.Println()
for _, nodepool := range nodepools {
fmt.Println("Nodepool name: ", nodepool.Name)
return renderRunnerGroups(nodepools)

//fmt.Println("Nodepool Nodes: ", len(nodepool.Info.repli))

//fmt.Println("Nodepool Memory: ", nodepool.Info.memory)
fmt.Println("Nodepool Status: ", nodepool.Info.Status)
// fmt.Println("-------------------")
// fmt.Println(nodepool)
// fmt.Println("-------------------")
}
fmt.Println("after printing returned nodepools")
return nil
},
}

func renderRunnerGroups(nodepools []*release.Release) error {
if len(nodepools) > 0 {
fmt.Println("+-------------------+------------+-------------+-------------+------------+")
fmt.Printf("| %-17s | %-10s | %-9s | %-11s | %-9s |\n", "Name", "Nodes", "CPU (cores)", "Memory (GiB)", "Status")
fmt.Println("+-------------------+------------+-------------+-------------+------------+")
}
for _, nodepool := range nodepools {
fmt.Printf("| %-17s | %-10v | %-12v| %-12v| %-10v |\n", nodepool.Name, nodepool.Config["replicas"], nodepool.Config["cpu"], nodepool.Config["memory"], nodepool.Info.Status)
fmt.Println("+-------------------+------------+-------------+-------------+------------+")
}
return nil
}
4 changes: 2 additions & 2 deletions virtualcluster/node_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ func ListNodepools(_ context.Context, kubeconfigPath string) ([]*release.Release
return nil, fmt.Errorf("failed to create helm list client: %w", err)
}

nodepools, err := listCli.List()
return nodepools, err
return listCli.List()

}

0 comments on commit ca41bc8

Please sign in to comment.