Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions controllers/workspace/devworkspace_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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{}
}
Expand All @@ -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
}
Expand All @@ -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).
Expand Down