Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,9 @@ spec:
maximum: 16384
minimum: 75
type: integer
x-kubernetes-validations:
- message: volumeSize is immutable
rule: self == oldSelf
required:
- instanceType
- nodePoolName
Expand Down
1 change: 1 addition & 0 deletions exp/api/v1beta2/rosamachinepool_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ type RosaMachinePoolSpec struct {
// VolumeSize set the disk volume size for the machine pool, in Gib. The default is 300 GiB.
// +kubebuilder:validation:Minimum=75
// +kubebuilder:validation:Maximum=16384
// +kubebuilder:validation:XValidation:rule="self == oldSelf", message="volumeSize is immutable"
// +immutable
// +optional
VolumeSize int `json:"volumeSize,omitempty"`
Expand Down
2 changes: 2 additions & 0 deletions exp/controllers/rosamachinepool_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,7 @@ func (r *ROSAMachinePoolReconciler) updateNodePool(machinePoolScope *scope.RosaM
desiredSpec.Version = ""
desiredSpec.AdditionalSecurityGroups = nil
desiredSpec.AdditionalTags = nil
desiredSpec.VolumeSize = 0

npBuilder := nodePoolBuilder(desiredSpec, machinePoolScope.MachinePool.Spec, machinePoolScope.ControlPlane.Spec.ChannelGroup, machinePoolScope.ControlPlane.Spec.Channel)
nodePoolSpec, err := npBuilder.Build()
Expand Down Expand Up @@ -430,6 +431,7 @@ func computeSpecDiff(desiredSpec expinfrav1.RosaMachinePoolSpec, nodePool *cmv1.
"Version", // Version changes are reconciled separately.
"AdditionalTags", // AdditionalTags day2 changes not supported.
"AdditionalSecurityGroups", // AdditionalSecurityGroups day2 changes not supported.
"VolumeSize", // VolumeSize is immutable after creation.
}

return cmp.Diff(desiredSpec, currentSpec,
Expand Down
48 changes: 48 additions & 0 deletions exp/controllers/rosamachinepool_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -708,6 +708,54 @@ func TestRosaMachinePoolReconcile(t *testing.T) {
})
}

func TestVolumeSizeIgnoredInDiff(t *testing.T) {
g := NewWithT(t)

rosaMachinePoolSpec := expinfrav1.RosaMachinePoolSpec{
NodePoolName: "test-nodepool",
Version: "4.14.5",
Subnet: "subnet-id",
AutoRepair: true,
InstanceType: "m5.large",
VolumeSize: 300,
}

// Create a NodePool with different volumeSize
nodePool, err := cmv1.NewNodePool().
ID("test-nodepool").
Version(cmv1.NewVersion().ID("openshift-v4.14.5")).
Subnet("subnet-id").
AutoRepair(true).
AWSNodePool(cmv1.NewAWSNodePool().
InstanceType("m5.large").
RootVolume(cmv1.NewAWSVolume().Size(400))).
Build()
g.Expect(err).ToNot(HaveOccurred())

diff := computeSpecDiff(rosaMachinePoolSpec, nodePool)
g.Expect(diff).To(BeEmpty(), "volumeSize should be ignored in diff computation")
}

func TestVolumeSizeZeroedBeforeUpdate(t *testing.T) {
g := NewWithT(t)

desiredSpec := expinfrav1.RosaMachinePoolSpec{
NodePoolName: "test-nodepool",
InstanceType: "m5.large",
VolumeSize: 0,
}

machinePoolSpec := clusterv1.MachinePoolSpec{
Replicas: ptr.To[int32](2),
}
nodePoolBuilder := nodePoolBuilder(desiredSpec, machinePoolSpec, rosacontrolplanev1.Stable, "")
nodePoolSpec, err := nodePoolBuilder.Build()
g.Expect(err).ToNot(HaveOccurred())

g.Expect(nodePoolSpec.AWSNodePool()).ToNot(BeNil())
g.Expect(nodePoolSpec.AWSNodePool().RootVolume()).To(BeNil(), "RootVolume should not be set when volumeSize is 0")
}

func createObject(g *WithT, obj client.Object, namespace string) {
if obj.DeepCopyObject() != nil {
obj.SetNamespace(namespace)
Expand Down
Loading