@@ -313,6 +313,14 @@ func (m *ManagedMachinePoolScope) CreateNodePool(ctx context.Context) (*oke.Node
313313 IsForceDeleteAfterGraceDuration : m .OCIManagedMachinePool .Spec .NodeEvictionNodePoolSettings .IsForceDeleteAfterGraceDuration ,
314314 }
315315 }
316+ recycleConfig := m .OCIManagedMachinePool .Spec .NodePoolCyclingDetails
317+ if recycleConfig != nil {
318+ nodePoolDetails .NodePoolCyclingDetails = & oke.NodePoolCyclingDetails {
319+ IsNodeCyclingEnabled : recycleConfig .IsNodeCyclingEnabled ,
320+ MaximumSurge : recycleConfig .MaximumSurge ,
321+ MaximumUnavailable : recycleConfig .MaximumUnavailable ,
322+ }
323+ }
316324 nodePoolDetails .InitialNodeLabels = m .getInitialNodeKeyValuePairs ()
317325
318326 req := oke.CreateNodePoolRequest {
@@ -603,16 +611,22 @@ func (m *ManagedMachinePoolScope) UpdateNodePool(ctx context.Context, pool *oke.
603611 return false , err
604612 }
605613 m .Logger .Info ("Node pool" , "spec" , jsonSpec , "actual" , jsonActual )
606- placementConfig , err := m .buildPlacementConfig (spec .NodePoolNodeConfig .PlacementConfigs )
607- if err != nil {
608- return false , err
609- }
614+
610615 nodeConfigDetails := oke.UpdateNodePoolNodeConfigDetails {
611616 NsgIds : m .getWorkerMachineNSGs (),
612- PlacementConfigs : placementConfig ,
613617 IsPvEncryptionInTransitEnabled : spec .NodePoolNodeConfig .IsPvEncryptionInTransitEnabled ,
614618 KmsKeyId : spec .NodePoolNodeConfig .KmsKeyId ,
615619 }
620+ // send placement config only if there is an actual change in placement
621+ // placement config and recycle config cannot be sent at the same time, and most use cases will
622+ // be to update kubernetes version in which case, placement config is not required to be sent
623+ if ! reflect .DeepEqual (spec .NodePoolNodeConfig .PlacementConfigs , actual .NodePoolNodeConfig .PlacementConfigs ) {
624+ placementConfig , err := m .buildPlacementConfig (spec .NodePoolNodeConfig .PlacementConfigs )
625+ if err != nil {
626+ return false , err
627+ }
628+ nodeConfigDetails .PlacementConfigs = placementConfig
629+ }
616630 if nodePoolSizeUpdateRequired {
617631 nodeConfigDetails .Size = common .Int (int (* m .MachinePool .Spec .Replicas ))
618632 }
@@ -643,7 +657,9 @@ func (m *ManagedMachinePoolScope) UpdateNodePool(ctx context.Context, pool *oke.
643657 return false , err
644658 }
645659 sourceDetails := oke.NodeSourceViaImageDetails {
646- ImageId : spec .NodeSourceViaImage .ImageId ,
660+ // use image id from machinepool spec itself as the copy will not have the image set in the
661+ // setNodepoolImageId method above
662+ ImageId : m .OCIManagedMachinePool .Spec .NodeSourceViaImage .ImageId ,
647663 BootVolumeSizeInGBs : spec .NodeSourceViaImage .BootVolumeSizeInGBs ,
648664 }
649665
@@ -672,6 +688,19 @@ func (m *ManagedMachinePoolScope) UpdateNodePool(ctx context.Context, pool *oke.
672688 NodeConfigDetails : & nodeConfigDetails ,
673689 NodeMetadata : spec .NodeMetadata ,
674690 }
691+ recycleConfig := spec .NodePoolCyclingDetails
692+ // cannot send recycle config and placement config together
693+ if recycleConfig != nil && len (nodeConfigDetails .PlacementConfigs ) == 0 {
694+ nodePoolDetails .NodePoolCyclingDetails = & oke.NodePoolCyclingDetails {
695+ IsNodeCyclingEnabled : recycleConfig .IsNodeCyclingEnabled ,
696+ MaximumSurge : recycleConfig .MaximumSurge ,
697+ MaximumUnavailable : recycleConfig .MaximumUnavailable ,
698+ }
699+ }
700+ if recycleConfig != nil && len (nodeConfigDetails .PlacementConfigs ) != 0 {
701+ m .Logger .V (LogLevelWarn ).Info ("Placement configuration has been changed in the update, " +
702+ "hence node pool recycling configuration will not be sent with the update request" )
703+ }
675704 if spec .NodeEvictionNodePoolSettings != nil {
676705 nodePoolDetails .NodeEvictionNodePoolSettings = & oke.NodeEvictionNodePoolSettings {
677706 EvictionGraceDuration : spec .NodeEvictionNodePoolSettings .EvictionGraceDuration ,
@@ -701,6 +730,7 @@ func (m *ManagedMachinePoolScope) UpdateNodePool(ctx context.Context, pool *oke.
701730func setMachinePoolSpecDefaults (spec * infrav2exp.OCIManagedMachinePoolSpec ) {
702731 spec .ProviderIDList = nil
703732 spec .ProviderID = nil
733+
704734 if spec .NodePoolNodeConfig != nil {
705735 if spec .NodePoolNodeConfig .PlacementConfigs != nil {
706736 configs := spec .NodePoolNodeConfig .PlacementConfigs
@@ -782,6 +812,14 @@ func (m *ManagedMachinePoolScope) getSpecFromAPIObject(pool *oke.NodePool) *expi
782812 }
783813 spec .NodeShapeConfig = & nodeShapeConfig
784814 }
815+ if pool .NodePoolCyclingDetails != nil {
816+ cyclingDetails := pool .NodePoolCyclingDetails
817+ spec .NodePoolCyclingDetails = & expinfra1.NodePoolCyclingDetails {
818+ IsNodeCyclingEnabled : cyclingDetails .IsNodeCyclingEnabled ,
819+ MaximumSurge : cyclingDetails .MaximumSurge ,
820+ MaximumUnavailable : cyclingDetails .MaximumUnavailable ,
821+ }
822+ }
785823 return & spec
786824}
787825
0 commit comments