From 6560132f97615febebda56d9105517328809a9ee Mon Sep 17 00:00:00 2001 From: Mulham Raee Date: Tue, 22 Aug 2023 12:04:53 +0200 Subject: [PATCH] Add MachineSetReady condition to MchineDeployment --- api/v1beta1/condition_consts.go | 8 ++++++++ .../machinedeployment/machinedeployment_sync.go | 7 +++++++ 2 files changed, 15 insertions(+) diff --git a/api/v1beta1/condition_consts.go b/api/v1beta1/condition_consts.go index 7b1a5483b7b4..ff798aa3ef0e 100644 --- a/api/v1beta1/condition_consts.go +++ b/api/v1beta1/condition_consts.go @@ -228,6 +228,14 @@ const ( // machines required (i.e. Spec.Replicas-MaxUnavailable when MachineDeploymentStrategyType = RollingUpdate) are up and running for at least minReadySeconds. MachineDeploymentAvailableCondition ConditionType = "Available" + // MachineSetReadyCondition reports a summary of current status of the MachineSet owned by the MachineDeployment. + MachineSetReadyCondition ConditionType = "MachineSetReady" + + // WaitingForMachineSetFallbackReason (Severity=Info) documents a MachineDeployment waiting for the underlying MachineSet + // to be available. + // NOTE: This reason is used only as a fallback when the MachineSet object is not reporting its own ready condition. + WaitingForMachineSetFallbackReason = "WaitingForMachineSet" + // WaitingForAvailableMachinesReason (Severity=Warning) reflects the fact that the required minimum number of machines for a machinedeployment are not available. WaitingForAvailableMachinesReason = "WaitingForAvailableMachines" ) diff --git a/internal/controllers/machinedeployment/machinedeployment_sync.go b/internal/controllers/machinedeployment/machinedeployment_sync.go index 546ecd85f86f..0abfb3106450 100644 --- a/internal/controllers/machinedeployment/machinedeployment_sync.go +++ b/internal/controllers/machinedeployment/machinedeployment_sync.go @@ -548,6 +548,13 @@ func calculateStatus(allMSs []*clusterv1.MachineSet, newMS *clusterv1.MachineSet } } } + + // Report a summary of current status of the MachineSet object owned by this MachineDeployment. + conditions.SetMirror(deployment, clusterv1.MachineSetReadyCondition, + newMS, + conditions.WithFallbackValue(false, clusterv1.WaitingForMachineSetFallbackReason, clusterv1.ConditionSeverityInfo, ""), + ) + return status }