Skip to content

Commit de96cea

Browse files
claudioloradamjensenbot
authored andcommitted
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 b0734d0 commit de96cea

File tree

1 file changed

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

1 file changed

+22
-2
lines changed

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

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -294,10 +294,30 @@ 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, checking if 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+
// Enable the authentication module
315+
*provider = true
316+
fcutils.EnableModuleAuthentication(fc)
317+
// Set the API Server URL to enable the health check.
318+
fc.Status.APIServerURL = cfg.Host
299319
case err != nil:
300-
klog.Errorf("an error occurred while getting the Identity resource for the ForeignCluster %q: %s", clusterID, err)
320+
klog.Errorf("An error occurred while getting the Identity resource for the ForeignCluster %q: %s", clusterID, err)
301321
return err
302322
default:
303323
*provider = true

0 commit comments

Comments
 (0)