From 7df914e35c2636b62b2613f83500e6a80e70147c Mon Sep 17 00:00:00 2001 From: Max batleforc Date: Wed, 9 Oct 2024 20:46:15 +0200 Subject: [PATCH] feat: queue workspace reconcile if workspace health check encounters an error fix #1325 Signed-off-by: Max batleforc --- controllers/workspace/devworkspace_controller.go | 6 ++++-- controllers/workspace/status.go | 3 ++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/controllers/workspace/devworkspace_controller.go b/controllers/workspace/devworkspace_controller.go index be44e63d6..712243390 100644 --- a/controllers/workspace/devworkspace_controller.go +++ b/controllers/workspace/devworkspace_controller.go @@ -491,8 +491,10 @@ func (r *DevWorkspaceReconciler) Reconcile(ctx context.Context, req ctrl.Request reconcileStatus.setConditionTrue(conditions.DeploymentReady, "DevWorkspace deployment ready") serverReady, serverStatusCode, err := checkServerStatus(clusterWorkspace) - if err != nil { - return reconcile.Result{}, err + if shouldReturn, reconcileResult, reconcileErr := r.checkDWError(workspace, err, "Error checking server status", metrics.ReasonInfrastructureFailure, reqLogger, &reconcileStatus); shouldReturn { + reqLogger.Info("Waiting for DevWorkspace health check endpoint to become available") + reconcileStatus.setConditionFalse(dw.DevWorkspaceReady, "Waiting for workspace health check to become available") + return reconcileResult, reconcileErr } if !serverReady { reqLogger.Info("Main URL server not ready", "status-code", serverStatusCode) diff --git a/controllers/workspace/status.go b/controllers/workspace/status.go index 05540d0b6..d3184454a 100644 --- a/controllers/workspace/status.go +++ b/controllers/workspace/status.go @@ -26,6 +26,7 @@ import ( dw "github.com/devfile/api/v2/pkg/apis/workspaces/v1alpha2" "github.com/devfile/devworkspace-operator/pkg/common" + "github.com/devfile/devworkspace-operator/pkg/dwerrors" "github.com/devfile/devworkspace-operator/pkg/provision/sync" "github.com/go-logr/logr" @@ -211,7 +212,7 @@ func checkServerStatus(workspace *common.DevWorkspaceWithConfig) (ok bool, respo resp, err := healthCheckHttpClient.Get(healthz.String()) if err != nil { - return false, nil, err + return false, nil, &dwerrors.RetryError{Err: err, Message: "Failed to check server status", RequeueAfter: 1 * time.Second} } if (resp.StatusCode / 100) == 4 { // Assume endpoint is unimplemented and/or * is covered with authentication.