Skip to content

Commit c97fbbb

Browse files
amisevskibuziuk
authored andcommitted
Don't use "error" in message on status update conflict
Avoid using the word "Error" when logging a conflict in updating the workspace status, as this can confuse users. Conflicts occur when the in-cluster object is newer than the object we are applying and do not represent error states. The controller already retries automatically on conflict. Signed-off-by: Angel Misevski <[email protected]>
1 parent d20bf94 commit c97fbbb

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

controllers/workspace/status.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import (
2727

2828
"github.com/go-logr/logr"
2929
corev1 "k8s.io/api/core/v1"
30+
k8sErrors "k8s.io/apimachinery/pkg/api/errors"
3031
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
3132
kubeclock "k8s.io/apimachinery/pkg/util/clock"
3233
"sigs.k8s.io/controller-runtime/pkg/reconcile"
@@ -78,9 +79,13 @@ func (r *DevWorkspaceReconciler) updateWorkspaceStatus(workspace *dw.DevWorkspac
7879

7980
err := r.Status().Update(context.TODO(), workspace)
8081
if err != nil {
81-
logger.Info(fmt.Sprintf("Error updating workspace status: %s", err))
82-
if reconcileError == nil {
83-
reconcileError = err
82+
if k8sErrors.IsConflict(err) {
83+
logger.Info("Failed to update workspace status due to conflict; retrying")
84+
} else {
85+
logger.Info(fmt.Sprintf("Error updating workspace status: %s", err))
86+
if reconcileError == nil {
87+
reconcileError = err
88+
}
8489
}
8590
} else {
8691
updateMetricsForPhase(workspace, oldPhase, status.phase, logger)

0 commit comments

Comments
 (0)