Skip to content

Commit cb18268

Browse files
authored
Merge pull request #2702 from k8s-infra-cherrypick-robot/cherry-pick-2700-to-release-1.5
[release-1.5] fix agent pool created in failed state becoming ready
2 parents ef914c2 + e971a31 commit cb18268

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

exp/controllers/azuremanagedmachinepool_controller.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ import (
3636
expv1 "sigs.k8s.io/cluster-api/exp/api/v1beta1"
3737
"sigs.k8s.io/cluster-api/util"
3838
"sigs.k8s.io/cluster-api/util/annotations"
39+
"sigs.k8s.io/cluster-api/util/conditions"
3940
"sigs.k8s.io/cluster-api/util/predicates"
4041
ctrl "sigs.k8s.io/controller-runtime"
4142
"sigs.k8s.io/controller-runtime/pkg/client"
@@ -259,6 +260,11 @@ func (ammpr *AzureManagedMachinePoolReconciler) reconcileNormal(ctx context.Cont
259260

260261
if err := svc.Reconcile(ctx); err != nil {
261262
scope.SetAgentPoolReady(false)
263+
// Ensure the ready condition is false, but do not overwrite an existing
264+
// error condition which might provide more details.
265+
if conditions.IsTrue(scope.InfraMachinePool, infrav1.AgentPoolsReadyCondition) {
266+
conditions.MarkFalse(scope.InfraMachinePool, infrav1.AgentPoolsReadyCondition, infrav1.FailedReason, clusterv1.ConditionSeverityError, err.Error())
267+
}
262268

263269
// Handle transient and terminal errors
264270
log := log.WithValues("name", scope.InfraMachinePool.Name, "namespace", scope.InfraMachinePool.Namespace)

0 commit comments

Comments
 (0)