Skip to content

Commit

Permalink
Re-add NetworkInfrastructureReadyCondition
Browse files Browse the repository at this point in the history
  • Loading branch information
Cecile Robert-Michon committed Sep 17, 2021
1 parent 47caf96 commit 6ae407c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
2 changes: 2 additions & 0 deletions api/v1alpha4/conditions_consts.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import clusterv1 "sigs.k8s.io/cluster-api/api/v1alpha4"

// AzureCluster Conditions and Reasons.
const (
// NetworkInfrastructureReadyCondition reports of current status of cluster infrastructure.
NetworkInfrastructureReadyCondition clusterv1.ConditionType = "NetworkInfrastructureReady"
// NamespaceNotAllowedByIdentity used to indicate cluster in a namespace not allowed by identity.
NamespaceNotAllowedByIdentity = "NamespaceNotAllowedByIdentity"
)
Expand Down
2 changes: 2 additions & 0 deletions azure/scope/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,7 @@ func (s *ClusterScope) PatchObject(ctx context.Context) error {
conditions.SetSummary(s.AzureCluster,
conditions.WithConditions(
infrav1.ResourceGroupReadyCondition,
infrav1.NetworkInfrastructureReadyCondition,
),
)

Expand All @@ -562,6 +563,7 @@ func (s *ClusterScope) PatchObject(ctx context.Context) error {
patch.WithOwnedConditions{Conditions: []clusterv1.ConditionType{
clusterv1.ReadyCondition,
infrav1.ResourceGroupReadyCondition,
infrav1.NetworkInfrastructureReadyCondition,
}})
}

Expand Down
7 changes: 4 additions & 3 deletions controllers/azurecluster_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ func (r *AzureClusterReconciler) Reconcile(ctx context.Context, req ctrl.Request
return reconcile.Result{}, err
}
if !scope.IsClusterNamespaceAllowed(ctx, r.Client, identity.Spec.AllowedNamespaces, azureCluster.Namespace) {
conditions.MarkFalse(azureCluster, clusterv1.ReadyCondition, infrav1.NamespaceNotAllowedByIdentity, clusterv1.ConditionSeverityError, "")
conditions.MarkFalse(azureCluster, infrav1.NetworkInfrastructureReadyCondition, infrav1.NamespaceNotAllowedByIdentity, clusterv1.ConditionSeverityError, "")
return reconcile.Result{}, errors.New("AzureClusterIdentity list of allowed namespaces doesn't include current cluster namespace")
}
} else {
Expand Down Expand Up @@ -229,6 +229,7 @@ func (r *AzureClusterReconciler) reconcileNormal(ctx context.Context, clusterSco

// No errors, so mark us ready so the Cluster API Cluster Controller can pull it
azureCluster.Status.Ready = true
conditions.MarkTrue(azureCluster, infrav1.NetworkInfrastructureReadyCondition)

return reconcile.Result{}, nil
}
Expand All @@ -240,7 +241,7 @@ func (r *AzureClusterReconciler) reconcileDelete(ctx context.Context, clusterSco
clusterScope.Info("Reconciling AzureCluster delete")

azureCluster := clusterScope.AzureCluster
conditions.MarkFalse(azureCluster, clusterv1.ReadyCondition, clusterv1.DeletedReason, clusterv1.ConditionSeverityInfo, "")
conditions.MarkFalse(azureCluster, infrav1.NetworkInfrastructureReadyCondition, clusterv1.DeletedReason, clusterv1.ConditionSeverityInfo, "")
if err := clusterScope.PatchObject(ctx); err != nil {
return reconcile.Result{}, err
}
Expand All @@ -253,7 +254,7 @@ func (r *AzureClusterReconciler) reconcileDelete(ctx context.Context, clusterSco
if err := acr.Delete(ctx); err != nil {
wrappedErr := errors.Wrapf(err, "error deleting AzureCluster %s/%s", azureCluster.Namespace, azureCluster.Name)
r.Recorder.Eventf(azureCluster, corev1.EventTypeWarning, "ClusterReconcilerDeleteFailed", wrappedErr.Error())
conditions.MarkFalse(azureCluster, clusterv1.ReadyCondition, clusterv1.DeletionFailedReason, clusterv1.ConditionSeverityWarning, err.Error())
conditions.MarkFalse(azureCluster, infrav1.NetworkInfrastructureReadyCondition, clusterv1.DeletionFailedReason, clusterv1.ConditionSeverityWarning, err.Error())
return reconcile.Result{}, wrappedErr
}

Expand Down

0 comments on commit 6ae407c

Please sign in to comment.