@@ -112,7 +112,7 @@ func (s *NodegroupService) scalingConfig() *ekstypes.NodegroupScalingConfig {
112
112
return & cfg
113
113
}
114
114
115
- func (s * NodegroupService ) updateConfig () * ekstypes.NodegroupUpdateConfig {
115
+ func (s * NodegroupService ) updateConfig () ( * ekstypes.NodegroupUpdateConfig , error ) {
116
116
updateConfig := s .scope .ManagedMachinePool .Spec .UpdateConfig
117
117
118
118
return converters .NodegroupUpdateconfigToSDK (updateConfig )
@@ -203,7 +203,10 @@ func (s *NodegroupService) createNodegroup(ctx context.Context) (*ekstypes.Nodeg
203
203
if err != nil {
204
204
return nil , fmt .Errorf ("failed getting nodegroup subnets: %w" , err )
205
205
}
206
-
206
+ updatedConfig , err := s .updateConfig ()
207
+ if err != nil {
208
+ return nil , fmt .Errorf ("failed creating nodegroup, invalid update config: %w" , err )
209
+ }
207
210
input := & eks.CreateNodegroupInput {
208
211
ScalingConfig : s .scalingConfig (),
209
212
ClusterName : aws .String (eksClusterName ),
@@ -213,7 +216,7 @@ func (s *NodegroupService) createNodegroup(ctx context.Context) (*ekstypes.Nodeg
213
216
Labels : managedPool .Labels ,
214
217
Tags : tags ,
215
218
RemoteAccess : remoteAccess ,
216
- UpdateConfig : s . updateConfig () ,
219
+ UpdateConfig : updatedConfig ,
217
220
}
218
221
if managedPool .AMIType != nil && (managedPool .AWSLaunchTemplate == nil || managedPool .AWSLaunchTemplate .AMI .ID == nil ) {
219
222
input .AmiType = converters .AMITypeToSDK (* managedPool .AMIType )
@@ -466,9 +469,14 @@ func (s *NodegroupService) reconcileNodegroupConfig(ctx context.Context, ng *eks
466
469
needsUpdate = true
467
470
}
468
471
currentUpdateConfig := converters .NodegroupUpdateconfigFromSDK (ng .UpdateConfig )
472
+ updatedConfig , err := s .updateConfig ()
473
+ if err != nil {
474
+ return errors .Wrap (err , "invalid update config" )
475
+ }
476
+
469
477
if ! cmp .Equal (managedPool .UpdateConfig , currentUpdateConfig ) {
470
478
s .Debug ("Nodegroup update configuration differs from spec, updating the nodegroup update config" , "nodegroup" , ng .NodegroupName )
471
- input .UpdateConfig = s . updateConfig ()
479
+ input .UpdateConfig = updatedConfig
472
480
needsUpdate = true
473
481
}
474
482
if ! needsUpdate {
0 commit comments