Skip to content

Commit

Permalink
Merge pull request #2733 from hunterkepley/ocm-10147-2
Browse files Browse the repository at this point in the history
OCM-10147 | feat: removing validation for no changes on np
  • Loading branch information
hunterkepley authored Dec 16, 2024
2 parents 5809319 + 1d1ca9b commit 8396ed1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
13 changes: 4 additions & 9 deletions pkg/machinepool/machinepool.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ import (
ocmOutput "github.com/openshift/rosa/pkg/ocm/output"
mpOpts "github.com/openshift/rosa/pkg/options/machinepool"
"github.com/openshift/rosa/pkg/output"
rprtr "github.com/openshift/rosa/pkg/reporter"
"github.com/openshift/rosa/pkg/rosa"
)

Expand Down Expand Up @@ -1252,7 +1251,6 @@ func fillAutoScalingAndReplicas(npBuilder *cmv1.NodePoolBuilder, autoscaling boo
}

func getMachinePoolReplicas(cmd *cobra.Command,
reporter *rprtr.Object,
machinePoolID string,
existingReplicas int,
existingAutoscaling *cmv1.MachinePoolAutoscaling,
Expand Down Expand Up @@ -1458,7 +1456,7 @@ func editMachinePool(cmd *cobra.Command, machinePoolId string,
}

autoscaling, replicas, minReplicas, maxReplicas, err :=
getMachinePoolReplicas(cmd, r.Reporter, machinePoolId, machinePool.Replicas(), machinePool.Autoscaling(),
getMachinePoolReplicas(cmd, machinePoolId, machinePool.Replicas(), machinePool.Autoscaling(),
!isLabelsSet && !isTaintsSet, isMultiAZMachinePool(machinePool), cluster.OpenshiftVersion())

if err != nil {
Expand Down Expand Up @@ -1551,7 +1549,7 @@ func editNodePool(cmd *cobra.Command, nodePoolID string,
return fmt.Errorf("Machine pool '%s' does not exist for hosted cluster '%s'", nodePoolID, clusterKey)
}

autoscaling, replicas, minReplicas, maxReplicas, err := getNodePoolReplicas(cmd, r, nodePoolID,
autoscaling, replicas, minReplicas, maxReplicas, err := getNodePoolReplicas(cmd, nodePoolID,
nodePool.Replicas(), nodePool.Autoscaling(), isAnyAdditionalParameterSet, cluster.OpenshiftVersion())
if err != nil {
return fmt.Errorf("Failed to get autoscaling or replicas: '%s'", err)
Expand Down Expand Up @@ -1839,7 +1837,6 @@ func promptForNodePoolNodeRecreate(
}

func getNodePoolReplicas(cmd *cobra.Command,
r *rosa.Runtime,
nodePoolID string,
existingReplicas int,
existingAutoscaling *cmv1.NodePoolAutoscaling,
Expand Down Expand Up @@ -1990,10 +1987,8 @@ func editAutoscaling(nodePool *cmv1.NodePool, minReplicas int, maxReplicas int)
max = maxReplicas
}

if existingMinReplica != minReplicas || existingMaxReplica != maxReplicas {
if min >= 1 && max >= 1 {
return cmv1.NewNodePoolAutoscaling().MinReplica(min).MaxReplica(max)
}
if min >= 1 && max >= 1 {
return cmv1.NewNodePoolAutoscaling().MinReplica(min).MaxReplica(max)
}

return nil
Expand Down
4 changes: 2 additions & 2 deletions pkg/machinepool/machinepool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,13 @@ var _ = Describe("Machinepool and nodepool", func() {
testCommand.Flags().Lookup("min-replicas").Changed = true
testCommand.Flags().Lookup("max-replicas").Changed = true
})
It("editAutoscaling should equal nil if nothing is changed", func() {
It("editAutoscaling should not be nil if nothing is changed", func() {
nodepool, err := cmv1.NewNodePool().
Autoscaling(cmv1.NewNodePoolAutoscaling().MaxReplica(2).MinReplica(1)).
Build()
Expect(err).ToNot(HaveOccurred())
builder := editAutoscaling(nodepool, 1, 2)
Expect(builder).To(BeNil())
Expect(builder).To(Not(BeNil()))
})
It("editAutoscaling should equal the expected output", func() {
nodepool, err := cmv1.NewNodePool().
Expand Down

0 comments on commit 8396ed1

Please sign in to comment.