Skip to content

Commit 12d3ec5

Browse files
committed
fix: enable healthcheck with missing identity
This patch fixes an issue that caused the lack of the health check against the provider API server when access was configured through a control plane secret. With this fixwhen the ForeignCluster controller does not found an Identity resource for the given cluster it looks for control plane secrets to set the APIServer URL in the status, used then for the health check.
1 parent 1aea31d commit 12d3ec5

File tree

1 file changed

+19
-2
lines changed
  • pkg/liqo-controller-manager/core/foreigncluster-controller

1 file changed

+19
-2
lines changed

pkg/liqo-controller-manager/core/foreigncluster-controller/status.go

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -294,10 +294,27 @@ func (r *ForeignClusterReconciler) handleAuthenticationModuleStatus(ctx context.
294294
identity, err := getters.GetControlPlaneIdentityByClusterID(ctx, r.Client, clusterID)
295295
switch {
296296
case errors.IsNotFound(err):
297-
klog.V(6).Infof("Identity resource not found for ForeignCluster %q", clusterID)
298297
fcutils.DeleteModuleCondition(&fc.Status.Modules.Authentication, liqov1beta1.AuthIdentityControlPlaneStatusCondition)
298+
klog.V(6).Infof(
299+
"ControlPlane Identity resource not found for ForeignCluster %q, there is a control plane secret.",
300+
clusterID,
301+
)
302+
303+
// Check whether there is no identity but the if the cluster has been configured with a control plane secret.
304+
cfg, err := r.identityManager.GetConfig(fc.Spec.ClusterID, corev1.NamespaceAll)
305+
switch {
306+
case errors.IsNotFound(err):
307+
klog.V(6).Infof("No credentials found for ForeignCluster %q", clusterID)
308+
return nil
309+
case err != nil:
310+
klog.Errorf("An error occurred while getting the API server config for the ForeignCluster %q: %s", clusterID, err)
311+
return err
312+
}
313+
314+
// Set the API Server URL to enable the health check.
315+
fc.Status.APIServerURL = cfg.Host
299316
case err != nil:
300-
klog.Errorf("an error occurred while getting the Identity resource for the ForeignCluster %q: %s", clusterID, err)
317+
klog.Errorf("An error occurred while getting the Identity resource for the ForeignCluster %q: %s", clusterID, err)
301318
return err
302319
default:
303320
*provider = true

0 commit comments

Comments
 (0)