Skip to content

Commit

Permalink
OCM-9882 | feat: print custom worker disk size in describe nodepool
Browse files Browse the repository at this point in the history
Signed-off-by: Will Kutler <wkutler@redhat.com>
  • Loading branch information
willkutler authored and openshift-cherrypick-robot committed Sep 5, 2024
1 parent 566bc00 commit 0ac924d
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
11 changes: 10 additions & 1 deletion pkg/machinepool/output.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func machinePoolOutput(clusterId string, machinePool *cmv1.MachinePool) string {
}

func nodePoolOutput(clusterId string, nodePool *cmv1.NodePool) string {
return fmt.Sprintf(nodePoolOutputString,
output := fmt.Sprintf(nodePoolOutputString,
nodePool.ID(),
clusterId,
ocmOutput.PrintNodePoolAutoscaling(nodePool.Autoscaling()),
Expand All @@ -87,4 +87,13 @@ func nodePoolOutput(clusterId string, nodePool *cmv1.NodePool) string {
ocmOutput.PrintNodePoolManagementUpgrade(nodePool.ManagementUpgrade()),
ocmOutput.PrintNodePoolMessage(nodePool.Status()),
)

if nodePool.AWSNodePool() != nil && nodePool.AWSNodePool().RootVolume() != nil {
diskSize, ok := nodePool.AWSNodePool().RootVolume().GetSize()
if ok {
output += fmt.Sprintf("Disk size: %d\n", diskSize)
}
}

return output
}
19 changes: 19 additions & 0 deletions pkg/machinepool/output_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,25 @@ var _ = Describe("Output", Ordered, func() {
"test-mp", "test-cluster", "No", "4", "", "", labelsOutput, "", taintsOutput, "test-az",
"test-subnets", "1", "optional", "No", "test-tc", "test-kc", "", "", "", "")

result := nodePoolOutput("test-cluster", nodePool)
Expect(out).To(Equal(result))
})
It("nodepool output with custom disk size", func() {
awsNodePoolBuilder := cmv1.NewAWSNodePool().RootVolume(cmv1.NewAWSVolume().Size(256))
nodePoolBuilder := cmv1.NewNodePool().ID("test-mp").Replicas(4).AWSNodePool(awsNodePoolBuilder).
AvailabilityZone("test-az").Subnet("test-subnets").Version(cmv1.NewVersion().
ID("1")).AutoRepair(false).TuningConfigs("test-tc").
KubeletConfigs("test-kc").Labels(labels).Taints(taintsBuilder)
nodePool, err := nodePoolBuilder.Build()
Expect(err).ToNot(HaveOccurred())
labelsOutput := ocmOutput.PrintLabels(labels)
taintsOutput := ocmOutput.PrintTaints([]*cmv1.Taint{taint})

out := fmt.Sprintf(nodePoolOutputString,
"test-mp", "test-cluster", "No", "4", "", "", labelsOutput, "", taintsOutput, "test-az",
"test-subnets", "1", "optional", "No", "test-tc", "test-kc", "", "", "", "")
out += "Disk size: 256\n"

result := nodePoolOutput("test-cluster", nodePool)
Expect(out).To(Equal(result))
})
Expand Down

0 comments on commit 0ac924d

Please sign in to comment.