diff --git a/api/v2/checluster_types.go b/api/v2/checluster_types.go index 2ac64391d..dd97b894a 100644 --- a/api/v2/checluster_types.go +++ b/api/v2/checluster_types.go @@ -119,6 +119,10 @@ type CheClusterDevEnvironments struct { // +kubebuilder:validation:Pattern=^[a-z0-9]([-a-z0-9]*[a-z0-9])?$ // +kubebuilder:validation:MaxLength=63 ServiceAccount string `json:"serviceAccount,omitempty"` + // Pod scheduler for the workspace pods. + // If not specified, the pod scheduler is set to the default scheduler on the cluster. + // +optional + PodSchedulerName string `json:"podSchedulerName,omitempty"` } // Che components configuration. diff --git a/bundle/next/eclipse-che/manifests/che-operator.clusterserviceversion.yaml b/bundle/next/eclipse-che/manifests/che-operator.clusterserviceversion.yaml index bc8a5cfb7..5cb266f8b 100644 --- a/bundle/next/eclipse-che/manifests/che-operator.clusterserviceversion.yaml +++ b/bundle/next/eclipse-che/manifests/che-operator.clusterserviceversion.yaml @@ -77,7 +77,7 @@ metadata: operators.operatorframework.io/project_layout: go.kubebuilder.io/v3 repository: https://github.com/eclipse-che/che-operator support: Eclipse Foundation - name: eclipse-che.v7.59.0-740.next + name: eclipse-che.v7.59.0-742.next namespace: placeholder spec: apiservicedefinitions: {} @@ -1233,7 +1233,7 @@ spec: minKubeVersion: 1.19.0 provider: name: Eclipse Foundation - version: 7.59.0-740.next + version: 7.59.0-742.next webhookdefinitions: - admissionReviewVersions: - v1 diff --git a/bundle/next/eclipse-che/manifests/org.eclipse.che_checlusters.yaml b/bundle/next/eclipse-che/manifests/org.eclipse.che_checlusters.yaml index 558ac3af4..1da854e54 100644 --- a/bundle/next/eclipse-che/manifests/org.eclipse.che_checlusters.yaml +++ b/bundle/next/eclipse-che/manifests/org.eclipse.che_checlusters.yaml @@ -6980,6 +6980,10 @@ spec: description: The node selector limits the nodes that can run the workspace pods. type: object + podSchedulerName: + description: Pod scheduler for the workspace pods. If not specified, + the pod scheduler is set to the default scheduler on the cluster. + type: string secondsOfInactivityBeforeIdling: default: 1800 description: Idle timeout for workspaces in seconds. This timeout diff --git a/config/crd/bases/org.eclipse.che_checlusters.yaml b/config/crd/bases/org.eclipse.che_checlusters.yaml index a4671fa6f..cb199aa91 100644 --- a/config/crd/bases/org.eclipse.che_checlusters.yaml +++ b/config/crd/bases/org.eclipse.che_checlusters.yaml @@ -6790,6 +6790,10 @@ spec: description: The node selector limits the nodes that can run the workspace pods. type: object + podSchedulerName: + description: Pod scheduler for the workspace pods. If not specified, + the pod scheduler is set to the default scheduler on the cluster. + type: string secondsOfInactivityBeforeIdling: default: 1800 description: Idle timeout for workspaces in seconds. This timeout diff --git a/deploy/deployment/kubernetes/combined.yaml b/deploy/deployment/kubernetes/combined.yaml index 332b3ec60..576e5ba53 100644 --- a/deploy/deployment/kubernetes/combined.yaml +++ b/deploy/deployment/kubernetes/combined.yaml @@ -6809,6 +6809,10 @@ spec: description: The node selector limits the nodes that can run the workspace pods. type: object + podSchedulerName: + description: Pod scheduler for the workspace pods. If not specified, + the pod scheduler is set to the default scheduler on the cluster. + type: string secondsOfInactivityBeforeIdling: default: 1800 description: Idle timeout for workspaces in seconds. This timeout diff --git a/deploy/deployment/kubernetes/objects/checlusters.org.eclipse.che.CustomResourceDefinition.yaml b/deploy/deployment/kubernetes/objects/checlusters.org.eclipse.che.CustomResourceDefinition.yaml index 5cb69b4fa..9e4495600 100644 --- a/deploy/deployment/kubernetes/objects/checlusters.org.eclipse.che.CustomResourceDefinition.yaml +++ b/deploy/deployment/kubernetes/objects/checlusters.org.eclipse.che.CustomResourceDefinition.yaml @@ -6804,6 +6804,10 @@ spec: description: The node selector limits the nodes that can run the workspace pods. type: object + podSchedulerName: + description: Pod scheduler for the workspace pods. If not specified, + the pod scheduler is set to the default scheduler on the cluster. + type: string secondsOfInactivityBeforeIdling: default: 1800 description: Idle timeout for workspaces in seconds. This timeout diff --git a/deploy/deployment/openshift/combined.yaml b/deploy/deployment/openshift/combined.yaml index 96a1bc4be..811ad0566 100644 --- a/deploy/deployment/openshift/combined.yaml +++ b/deploy/deployment/openshift/combined.yaml @@ -6809,6 +6809,10 @@ spec: description: The node selector limits the nodes that can run the workspace pods. type: object + podSchedulerName: + description: Pod scheduler for the workspace pods. If not specified, + the pod scheduler is set to the default scheduler on the cluster. + type: string secondsOfInactivityBeforeIdling: default: 1800 description: Idle timeout for workspaces in seconds. This timeout diff --git a/deploy/deployment/openshift/objects/checlusters.org.eclipse.che.CustomResourceDefinition.yaml b/deploy/deployment/openshift/objects/checlusters.org.eclipse.che.CustomResourceDefinition.yaml index 1a03d87ca..78ebef595 100644 --- a/deploy/deployment/openshift/objects/checlusters.org.eclipse.che.CustomResourceDefinition.yaml +++ b/deploy/deployment/openshift/objects/checlusters.org.eclipse.che.CustomResourceDefinition.yaml @@ -6804,6 +6804,10 @@ spec: description: The node selector limits the nodes that can run the workspace pods. type: object + podSchedulerName: + description: Pod scheduler for the workspace pods. If not specified, + the pod scheduler is set to the default scheduler on the cluster. + type: string secondsOfInactivityBeforeIdling: default: 1800 description: Idle timeout for workspaces in seconds. This timeout diff --git a/helmcharts/next/crds/checlusters.org.eclipse.che.CustomResourceDefinition.yaml b/helmcharts/next/crds/checlusters.org.eclipse.che.CustomResourceDefinition.yaml index 5cb69b4fa..9e4495600 100644 --- a/helmcharts/next/crds/checlusters.org.eclipse.che.CustomResourceDefinition.yaml +++ b/helmcharts/next/crds/checlusters.org.eclipse.che.CustomResourceDefinition.yaml @@ -6804,6 +6804,10 @@ spec: description: The node selector limits the nodes that can run the workspace pods. type: object + podSchedulerName: + description: Pod scheduler for the workspace pods. If not specified, + the pod scheduler is set to the default scheduler on the cluster. + type: string secondsOfInactivityBeforeIdling: default: 1800 description: Idle timeout for workspaces in seconds. This timeout diff --git a/pkg/deploy/dev-workspace-config/dev_workspace_config.go b/pkg/deploy/dev-workspace-config/dev_workspace_config.go index 277c9f25a..a07077171 100644 --- a/pkg/deploy/dev-workspace-config/dev_workspace_config.go +++ b/pkg/deploy/dev-workspace-config/dev_workspace_config.go @@ -84,6 +84,10 @@ func updateWorkspaceConfig(devEnvironments *chev2.CheClusterDevEnvironments, ope return err } + if err := updateWorkspacePodSchedulerNameConfig(devEnvironments, operatorConfig.Workspace); err != nil { + return err + } + return nil } @@ -131,3 +135,8 @@ func updateWorkspaceServiceAccountConfig(devEnvironments *chev2.CheClusterDevEnv } return nil } + +func updateWorkspacePodSchedulerNameConfig(devEnvironments *chev2.CheClusterDevEnvironments, workspaceConfig *controllerv1alpha1.WorkspaceConfig) error { + workspaceConfig.SchedulerName = devEnvironments.PodSchedulerName + return nil +} diff --git a/pkg/deploy/dev-workspace-config/dev_workspace_config_test.go b/pkg/deploy/dev-workspace-config/dev_workspace_config_test.go index 895fc374a..5129b89f6 100644 --- a/pkg/deploy/dev-workspace-config/dev_workspace_config_test.go +++ b/pkg/deploy/dev-workspace-config/dev_workspace_config_test.go @@ -492,3 +492,151 @@ func TestReconcileServiceAccountConfig(t *testing.T) { }) } } + +func TestReconcileDevWorkspaceConfigPodSchedulerName(t *testing.T) { + type testCase struct { + name string + cheCluster *chev2.CheCluster + existedObjects []runtime.Object + expectedOperatorConfig *controllerv1alpha1.OperatorConfiguration + } + + var testCases = []testCase{ + { + name: "Create DevWorkspaceOperatorConfig with podSchedulerName", + cheCluster: &chev2.CheCluster{ + ObjectMeta: metav1.ObjectMeta{ + Namespace: "eclipse-che", + Name: "eclipse-che", + }, + Spec: chev2.CheClusterSpec{ + DevEnvironments: chev2.CheClusterDevEnvironments{ + PodSchedulerName: "test-scheduler", + }, + }, + }, + expectedOperatorConfig: &controllerv1alpha1.OperatorConfiguration{ + Workspace: &controllerv1alpha1.WorkspaceConfig{ + SchedulerName: "test-scheduler", + }, + }, + }, + { + name: "Update existing DevWorkspaceOperatorConfig when PodSchedulerName is added", + cheCluster: &chev2.CheCluster{ + ObjectMeta: metav1.ObjectMeta{ + Namespace: "eclipse-che", + Name: "eclipse-che", + }, + Spec: chev2.CheClusterSpec{ + DevEnvironments: chev2.CheClusterDevEnvironments{ + PodSchedulerName: "test-scheduler", + }, + }, + }, + existedObjects: []runtime.Object{ + &controllerv1alpha1.DevWorkspaceOperatorConfig{ + ObjectMeta: metav1.ObjectMeta{ + Name: devWorkspaceConfigName, + Namespace: "eclipse-che", + }, + TypeMeta: metav1.TypeMeta{ + Kind: "DevWorkspaceOperatorConfig", + APIVersion: controllerv1alpha1.GroupVersion.String(), + }, + }, + }, + expectedOperatorConfig: &controllerv1alpha1.OperatorConfiguration{ + Workspace: &controllerv1alpha1.WorkspaceConfig{ + SchedulerName: "test-scheduler", + }, + }, + }, + { + name: "Update existing DevWorkspaceOperatorConfig when PodSchedulerName is changed", + cheCluster: &chev2.CheCluster{ + ObjectMeta: metav1.ObjectMeta{ + Namespace: "eclipse-che", + Name: "eclipse-che", + }, + Spec: chev2.CheClusterSpec{ + DevEnvironments: chev2.CheClusterDevEnvironments{ + PodSchedulerName: "test-scheduler", + }, + }, + }, + existedObjects: []runtime.Object{ + &controllerv1alpha1.DevWorkspaceOperatorConfig{ + ObjectMeta: metav1.ObjectMeta{ + Name: devWorkspaceConfigName, + Namespace: "eclipse-che", + }, + TypeMeta: metav1.TypeMeta{ + Kind: "DevWorkspaceOperatorConfig", + APIVersion: controllerv1alpha1.GroupVersion.String(), + }, + Config: &controllerv1alpha1.OperatorConfiguration{ + Workspace: &controllerv1alpha1.WorkspaceConfig{ + SchedulerName: "previous-scheduler", + }, + }, + }, + }, + expectedOperatorConfig: &controllerv1alpha1.OperatorConfiguration{ + Workspace: &controllerv1alpha1.WorkspaceConfig{ + SchedulerName: "test-scheduler", + }, + }, + }, + { + name: "Update existing DevWorkspaceOperatorConfig when PodSchedulerName is removed", + cheCluster: &chev2.CheCluster{ + ObjectMeta: metav1.ObjectMeta{ + Namespace: "eclipse-che", + Name: "eclipse-che", + }, + Spec: chev2.CheClusterSpec{ + DevEnvironments: chev2.CheClusterDevEnvironments{ + PodSchedulerName: "", + }, + }, + }, + existedObjects: []runtime.Object{ + &controllerv1alpha1.DevWorkspaceOperatorConfig{ + ObjectMeta: metav1.ObjectMeta{ + Name: devWorkspaceConfigName, + Namespace: "eclipse-che", + }, + TypeMeta: metav1.TypeMeta{ + Kind: "DevWorkspaceOperatorConfig", + APIVersion: controllerv1alpha1.GroupVersion.String(), + }, + Config: &controllerv1alpha1.OperatorConfiguration{ + Workspace: &controllerv1alpha1.WorkspaceConfig{ + SchedulerName: "previous-scheduler", + }, + }, + }, + }, + expectedOperatorConfig: &controllerv1alpha1.OperatorConfiguration{ + Workspace: &controllerv1alpha1.WorkspaceConfig{}, + }, + }, + } + + for _, testCase := range testCases { + t.Run(testCase.name, func(t *testing.T) { + deployContext := test.GetDeployContext(testCase.cheCluster, []runtime.Object{}) + infrastructure.InitializeForTesting(infrastructure.OpenShiftv4) + + devWorkspaceConfigReconciler := NewDevWorkspaceConfigReconciler() + _, _, err := devWorkspaceConfigReconciler.Reconcile(deployContext) + assert.NoError(t, err) + + dwoc := &controllerv1alpha1.DevWorkspaceOperatorConfig{} + err = deployContext.ClusterAPI.Client.Get(context.TODO(), types.NamespacedName{Name: devWorkspaceConfigName, Namespace: testCase.cheCluster.Namespace}, dwoc) + assert.NoError(t, err) + assert.Equal(t, testCase.expectedOperatorConfig.Workspace.SchedulerName, dwoc.Config.Workspace.SchedulerName) + }) + } +}