9
9
"github.com/aws/aws-sdk-go/service/ec2"
10
10
"github.com/blang/semver"
11
11
"github.com/google/go-cmp/cmp"
12
+ "github.com/google/go-cmp/cmp/cmpopts"
12
13
cmv1 "github.com/openshift-online/ocm-sdk-go/clustersmgmt/v1"
13
14
"github.com/openshift/rosa/pkg/ocm"
14
15
"github.com/pkg/errors"
@@ -220,6 +221,11 @@ func (r *ROSAMachinePoolReconciler) reconcileNormal(ctx context.Context,
220
221
}
221
222
222
223
if found {
224
+ if rosaMachinePool .Spec .AvailabilityZone == "" {
225
+ // reflect the current AvailabilityZone in the spec if not set.
226
+ rosaMachinePool .Spec .AvailabilityZone = nodePool .AvailabilityZone ()
227
+ }
228
+
223
229
nodePool , err := r .updateNodePool (machinePoolScope , ocmClient , nodePool )
224
230
if err != nil {
225
231
return ctrl.Result {}, fmt .Errorf ("failed to ensure rosaMachinePool: %w" , err )
@@ -349,13 +355,23 @@ func (r *ROSAMachinePoolReconciler) reconcileMachinePoolVersion(machinePoolScope
349
355
}
350
356
351
357
func (r * ROSAMachinePoolReconciler ) updateNodePool (machinePoolScope * scope.RosaMachinePoolScope , ocmClient * ocm.Client , nodePool * cmv1.NodePool ) (* cmv1.NodePool , error ) {
352
- desiredSpec := machinePoolScope .RosaMachinePool .Spec .DeepCopy ()
353
-
358
+ desiredSpec := * machinePoolScope .RosaMachinePool .Spec .DeepCopy ()
354
359
currentSpec := nodePoolToRosaMachinePoolSpec (nodePool )
355
- currentSpec .ProviderIDList = desiredSpec .ProviderIDList // providerIDList is set by the controller and shouldn't be compared here.
356
- currentSpec .Version = desiredSpec .Version // Version changes are reconciled separately and shouldn't be compared here.
357
360
358
- if cmp .Equal (desiredSpec , currentSpec ) {
361
+ if desiredSpec .NodeDrainGracePeriod == nil {
362
+ // currentSpec.NodeDrainGracePeriod is always non-nil.
363
+ // if desiredSpec.NodeDrainGracePeriod is nil, set to 0 so we update the nodePool, otherewise the current value will be preserved.
364
+ desiredSpec .NodeDrainGracePeriod = & metav1.Duration {}
365
+ }
366
+
367
+ ignoredFields := []string {
368
+ "ProviderIDList" , // providerIDList is set by the controller.
369
+ "Version" , // Version changes are reconciled separately.
370
+ "AdditionalTags" , // AdditionalTags day2 changes not supported.
371
+ }
372
+ if cmp .Equal (desiredSpec , currentSpec ,
373
+ cmpopts .EquateEmpty (), // ensures empty non-nil slices and nil slices are considered equal.
374
+ cmpopts .IgnoreFields (currentSpec , ignoredFields ... )) {
359
375
// no changes detected.
360
376
return nodePool , nil
361
377
}
@@ -365,7 +381,7 @@ func (r *ROSAMachinePoolReconciler) updateNodePool(machinePoolScope *scope.RosaM
365
381
desiredSpec .AdditionalSecurityGroups = nil
366
382
desiredSpec .AdditionalTags = nil
367
383
368
- npBuilder := nodePoolBuilder (* desiredSpec , machinePoolScope .MachinePool .Spec )
384
+ npBuilder := nodePoolBuilder (desiredSpec , machinePoolScope .MachinePool .Spec )
369
385
nodePoolSpec , err := npBuilder .Build ()
370
386
if err != nil {
371
387
return nil , fmt .Errorf ("failed to build nodePool spec: %w" , err )
@@ -470,11 +486,13 @@ func nodePoolToRosaMachinePoolSpec(nodePool *cmv1.NodePool) expinfrav1.RosaMachi
470
486
AvailabilityZone : nodePool .AvailabilityZone (),
471
487
Subnet : nodePool .Subnet (),
472
488
Labels : nodePool .Labels (),
473
- AdditionalTags : nodePool .AWSNodePool ().Tags (),
474
489
AutoRepair : nodePool .AutoRepair (),
475
490
InstanceType : nodePool .AWSNodePool ().InstanceType (),
476
491
TuningConfigs : nodePool .TuningConfigs (),
477
492
AdditionalSecurityGroups : nodePool .AWSNodePool ().AdditionalSecurityGroupIds (),
493
+ // nodePool.AWSNodePool().Tags() returns all tags including "system" tags if "fetchUserTagsOnly" parameter is not specified.
494
+ // TODO: enable when AdditionalTags day2 changes is supported.
495
+ // AdditionalTags: nodePool.AWSNodePool().Tags(),
478
496
}
479
497
480
498
if nodePool .Autoscaling () != nil {
0 commit comments