Skip to content

Commit 75c2a60

Browse files
batleforcAObuchow
authored andcommitted
feat: queue workspace reconcile if workspace health check encounters an error
fix #1325 Signed-off-by: Max batleforc <[email protected]>
1 parent a285d3b commit 75c2a60

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

controllers/workspace/devworkspace_controller.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -491,8 +491,10 @@ func (r *DevWorkspaceReconciler) Reconcile(ctx context.Context, req ctrl.Request
491491
reconcileStatus.setConditionTrue(conditions.DeploymentReady, "DevWorkspace deployment ready")
492492

493493
serverReady, serverStatusCode, err := checkServerStatus(clusterWorkspace)
494-
if err != nil {
495-
return reconcile.Result{}, err
494+
if shouldReturn, reconcileResult, reconcileErr := r.checkDWError(workspace, err, "Error checking server status", metrics.ReasonInfrastructureFailure, reqLogger, &reconcileStatus); shouldReturn {
495+
reqLogger.Info("Waiting for DevWorkspace health check endpoint to become available")
496+
reconcileStatus.setConditionFalse(dw.DevWorkspaceReady, "Waiting for workspace health check to become available")
497+
return reconcileResult, reconcileErr
496498
}
497499
if !serverReady {
498500
reqLogger.Info("Main URL server not ready", "status-code", serverStatusCode)

controllers/workspace/status.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import (
2626

2727
dw "github.com/devfile/api/v2/pkg/apis/workspaces/v1alpha2"
2828
"github.com/devfile/devworkspace-operator/pkg/common"
29+
"github.com/devfile/devworkspace-operator/pkg/dwerrors"
2930
"github.com/devfile/devworkspace-operator/pkg/provision/sync"
3031

3132
"github.com/go-logr/logr"
@@ -211,7 +212,7 @@ func checkServerStatus(workspace *common.DevWorkspaceWithConfig) (ok bool, respo
211212

212213
resp, err := healthCheckHttpClient.Get(healthz.String())
213214
if err != nil {
214-
return false, nil, err
215+
return false, nil, &dwerrors.RetryError{Err: err, Message: "Failed to check server status", RequeueAfter: 1 * time.Second}
215216
}
216217
if (resp.StatusCode / 100) == 4 {
217218
// Assume endpoint is unimplemented and/or * is covered with authentication.

0 commit comments

Comments
 (0)