diff --git a/controllers/workspace/devworkspace_controller.go b/controllers/workspace/devworkspace_controller.go index 84a257f82..0026888c0 100644 --- a/controllers/workspace/devworkspace_controller.go +++ b/controllers/workspace/devworkspace_controller.go @@ -27,7 +27,6 @@ import ( "github.com/devfile/devworkspace-operator/controllers/workspace/metrics" "github.com/devfile/devworkspace-operator/pkg/common" "github.com/devfile/devworkspace-operator/pkg/conditions" - "github.com/devfile/devworkspace-operator/pkg/config" wkspConfig "github.com/devfile/devworkspace-operator/pkg/config" "github.com/devfile/devworkspace-operator/pkg/constants" "github.com/devfile/devworkspace-operator/pkg/library/annotate" @@ -123,9 +122,10 @@ func (r *DevWorkspaceReconciler) Reconcile(ctx context.Context, req ctrl.Request return reconcile.Result{}, err } + reconcileStatus := currentStatus{} config, err := wkspConfig.ResolveConfigForWorkspace(rawWorkspace, clusterAPI.Client) if err != nil { - reqLogger.Error(err, "Error applying external DevWorkspace-Operator configuration") + reconcileStatus.setConditionTrue(conditions.DevWorkspaceWarning, fmt.Sprint("Error applying external DevWorkspace-Operator configuration: ", err.Error())) config = wkspConfig.GetGlobalConfig() } configString := wkspConfig.GetCurrentConfigString(config) @@ -208,7 +208,7 @@ func (r *DevWorkspaceReconciler) Reconcile(ctx context.Context, req ctrl.Request } // Prepare handling workspace status and condition - reconcileStatus := currentStatus{phase: dw.DevWorkspaceStatusStarting} + reconcileStatus.phase = dw.DevWorkspaceStatusStarting reconcileStatus.setConditionTrue(conditions.Started, "DevWorkspace is starting") clusterWorkspace := &common.DevWorkspaceWithConfig{} clusterWorkspace.DevWorkspace = workspace.DevWorkspace.DeepCopy() @@ -265,8 +265,6 @@ func (r *DevWorkspaceReconciler) Reconcile(ctx context.Context, req ctrl.Request } if warnings != nil { reconcileStatus.setConditionTrue(conditions.DevWorkspaceWarning, flatten.FormatVariablesWarning(warnings)) - } else { - reconcileStatus.setConditionFalse(conditions.DevWorkspaceWarning, "No warnings in processing DevWorkspace") } workspace.Spec.Template = *flattenedWorkspace reconcileStatus.setConditionTrue(conditions.DevWorkspaceResolved, "Resolved plugins and parents from DevWorkspace") @@ -692,7 +690,7 @@ func (r *DevWorkspaceReconciler) dwPVCHandler(obj client.Object) []reconcile.Req // TODO: Label PVCs used for workspace storage so that they can be cleaned up if non-default name is used. // Otherwise, check if common PVC is deleted to make sure all DevWorkspaces see it happen - if obj.GetName() != config.GetGlobalConfig().Workspace.PVCName || obj.GetDeletionTimestamp() == nil { + if obj.GetName() != wkspConfig.GetGlobalConfig().Workspace.PVCName || obj.GetDeletionTimestamp() == nil { // We're looking for a deleted common PVC return []reconcile.Request{} } @@ -718,7 +716,7 @@ func (r *DevWorkspaceReconciler) dwPVCHandler(obj client.Object) []reconcile.Req func (r *DevWorkspaceReconciler) SetupWithManager(mgr ctrl.Manager) error { setupHttpClients() - maxConcurrentReconciles, err := config.GetMaxConcurrentReconciles() + maxConcurrentReconciles, err := wkspConfig.GetMaxConcurrentReconciles() if err != nil { return err } @@ -727,7 +725,7 @@ func (r *DevWorkspaceReconciler) SetupWithManager(mgr ctrl.Manager) error { return []reconcile.Request{} } - var configWatcher builder.WatchesOption = builder.WithPredicates(config.Predicates()) + var configWatcher builder.WatchesOption = builder.WithPredicates(wkspConfig.Predicates()) // TODO: Set up indexing https://book.kubebuilder.io/cronjob-tutorial/controller-implementation.html#setup return ctrl.NewControllerManagedBy(mgr).