You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// we want to make sure that all other ClusterRequests are deleted first
68
-
// in case the corresponding clusters are hosting resources that depend on the MCP cluster
69
-
log.Debug("Skipping deletion of MCP's primary ClusterRequest, because there are other ClusterRequests to delete first", "crName", crName, "namespace", cr.GetNamespace())
70
-
continue
66
+
ifcrName==mcp.Name {
67
+
// this is the primary ClusterRequest for the MCP cluster
68
+
// try to fetch the corresponding Cluster resource
// only log the error, this is not critical and should not break the function
76
+
log.Error(fmt.Errorf("unable to get Cluster '%s/%s': %w", cluster.Namespace, cluster.Name, err), "error trying to fetch the primary MCP Cluster resource for condition sync")
77
+
cluster=nil
78
+
}
79
+
}
80
+
iflen(resources) >1 {
81
+
// skip the MCP's main ClusterRequest for now
82
+
// we want to make sure that all other ClusterRequests are deleted first
83
+
// in case the corresponding clusters are hosting resources that depend on the MCP cluster
84
+
log.Debug("Skipping deletion of MCP's primary ClusterRequest, because there are other ClusterRequests to delete first", "crName", crName, "namespace", cr.GetNamespace())
85
+
continue
86
+
}
71
87
}
72
88
if!cr.GetDeletionTimestamp().IsZero() {
73
89
log.Debug("ClusterRequest resource already marked for deletion", "crName", crName, "namespace", cr.GetNamespace())
log.Debug("ClusterRequest is ready", "clusterRequestName", cr.Name, "clusterRequestNamespace", cr.Namespace)
237
237
createCon(corev2alpha1.ConditionClusterRequestReady, metav1.ConditionTrue, "", "ClusterRequest is ready")
238
238
239
+
// fetch Cluster conditions to display them on the MCP
240
+
cluster:=&clustersv1alpha1.Cluster{}
241
+
ifcr.Status.Cluster==nil {
242
+
// should not happen if the ClusterRequest is granted
243
+
rr.ReconcileError=errutils.WithReason(fmt.Errorf("ClusterRequest '%s/%s' does not have a ClusterRef set", cr.Namespace, cr.Name), cconst.ReasonInternalError)
rr.ReconcileError=errutils.WithReason(fmt.Errorf("unable to get Cluster '%s/%s': %w", cluster.Namespace, cluster.Name, err), cconst.ReasonPlatformClusterInteractionProblem)
createCon(corev2alpha1.ConditionClusterConditionsSynced, metav1.ConditionTrue, "", "Cluster conditions have been synced to MCP")
355
+
} else {
356
+
// since this point is only reached if no error occurred during r.deleteRelatedClusterRequests, we can assume that the primaryCluster is nil because it does not exist
357
+
for_, con:=rangemcp.Status.Conditions {
358
+
// remove all conditions that were synced from the Cluster from the MCP to avoid having unhealthy leftovers
0 commit comments