Skip to content

Commit

Permalink
feat: queue workspace reconcile if workspace health check encounters …
Browse files Browse the repository at this point in the history
…an error

fix #1325

Signed-off-by: Max batleforc <[email protected]>
  • Loading branch information
batleforc committed Oct 9, 2024
1 parent 0136d4c commit 7df914e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
6 changes: 4 additions & 2 deletions controllers/workspace/devworkspace_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion controllers/workspace/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit 7df914e

Please sign in to comment.