Skip to content

Commit ae094eb

Browse files
committed
machinesetsync: also adjust MAPItoCAPI
1 parent 682e9ff commit ae094eb

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

pkg/controllers/machinesetsync/machineset_sync_controller.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -996,6 +996,7 @@ func (r *MachineSetSyncReconciler) ensureMAPIMachineSetStatusUpdated(ctx context
996996
}
997997

998998
// setChangedCAPIMachineSetStatusFields sets the updated fields in the CAPI machine set status.
999+
// Note: ObservedGeneration is handled after calling this function.
9991000
func setChangedCAPIMachineSetStatusFields(existingCAPIMachineSet, convertedCAPIMachineSet *clusterv1.MachineSet) {
10001001
// convertedCAPIMachine holds the computed and desired status changes converted from the source MAPI machine, so apply them to the existing existingCAPIMachine.
10011002
// Merge the v1beta1 conditions.
@@ -1059,6 +1060,7 @@ func (r *MachineSetSyncReconciler) updateMAPIMachineSet(ctx context.Context, exi
10591060
}
10601061

10611062
// setChangedMAPIMachineSetStatusFields sets the updated fields in the MAPI machine set status.
1063+
// Note: ObservedGeneration is handled after calling this function.
10621064
func setChangedMAPIMachineSetStatusFields(existingMAPIMachineSet, convertedMAPIMachineSet *mapiv1beta1.MachineSet) {
10631065
// convertedMAPIMachineSet holds the computed and desired status changes, so apply them to the existing existingMAPIMachineSet.
10641066
existingMAPIMachineSet.Status.Replicas = convertedMAPIMachineSet.Status.Replicas
@@ -1068,9 +1070,20 @@ func setChangedMAPIMachineSetStatusFields(existingMAPIMachineSet, convertedMAPIM
10681070
existingMAPIMachineSet.Status.ErrorReason = convertedMAPIMachineSet.Status.ErrorReason
10691071
existingMAPIMachineSet.Status.ErrorMessage = convertedMAPIMachineSet.Status.ErrorMessage
10701072

1073+
// Merge the v1beta1 conditions.
10711074
for i := range convertedMAPIMachineSet.Status.Conditions {
10721075
existingMAPIMachineSet.Status.Conditions = util.SetMAPICondition(existingMAPIMachineSet.Status.Conditions, &convertedMAPIMachineSet.Status.Conditions[i])
10731076
}
1077+
1078+
// Copy them back to the convertedMAPIMachineSet.
1079+
convertedMAPIMachineSet.Status.Conditions = existingMAPIMachineSet.Status.Conditions
1080+
1081+
// Keep the current SynchronizedGeneration and AuthorativeAPI. They get handled separately in `applySynchronizedConditionWithPatch`
1082+
convertedMAPIMachineSet.Status.SynchronizedGeneration = existingMAPIMachineSet.Status.SynchronizedGeneration
1083+
convertedMAPIMachineSet.Status.AuthoritativeAPI = existingMAPIMachineSet.Status.AuthoritativeAPI
1084+
1085+
// Finally overwrite the entire existingMAPIMachineSet status with the convertedMAPIMachineSet status.
1086+
existingMAPIMachineSet.Status = convertedMAPIMachineSet.Status
10741087
}
10751088

10761089
// ensureSyncFinalizer ensures the sync finalizer is present across mapi and capi machine sets.

0 commit comments

Comments
 (0)