Skip to content

Commit

Permalink
feat: add spec.devEnvironments.podSchedulerName in CR
Browse files Browse the repository at this point in the history
Signed-off-by: David Kwon <[email protected]>
  • Loading branch information
dkwon17 committed Nov 18, 2022
1 parent d37039b commit 97ea796
Show file tree
Hide file tree
Showing 17 changed files with 172 additions and 5 deletions.
4 changes: 4 additions & 0 deletions api/v2/checluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,10 @@ type CheClusterDevEnvironments struct {
// Container build configuration.
// +optional
ContainerBuildConfiguration *ContainerBuildConfiguration `json:"containerBuildConfiguration,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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.57.0-729.next
name: eclipse-che.v7.57.0-730.next
namespace: placeholder
spec:
apiservicedefinitions: {}
Expand Down Expand Up @@ -1241,7 +1241,7 @@ spec:
minKubeVersion: 1.19.0
provider:
name: Eclipse Foundation
version: 7.57.0-729.next
version: 7.57.0-730.next
webhookdefinitions:
- admissionReviewVersions:
- v1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions config/crd/bases/org.eclipse.che_checlusters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions deploy/deployment/kubernetes/combined.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4590,6 +4590,9 @@ spec:
type: string
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 is the duration after which a workspace will be idled if there is no activity. To disable workspace idling due to inactivity, set this value to -1.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4585,6 +4585,9 @@ spec:
type: string
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 is the duration after which a workspace will be idled if there is no activity. To disable workspace idling due to inactivity, set this value to -1.
Expand Down
3 changes: 3 additions & 0 deletions deploy/deployment/openshift/combined.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4590,6 +4590,9 @@ spec:
type: string
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 is the duration after which a workspace will be idled if there is no activity. To disable workspace idling due to inactivity, set this value to -1.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4585,6 +4585,9 @@ spec:
type: string
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 is the duration after which a workspace will be idled if there is no activity. To disable workspace idling due to inactivity, set this value to -1.
Expand Down
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -459,3 +459,5 @@ replace (
)

replace github.com/docker/docker => github.com/moby/moby v0.7.3-0.20190826074503-38ab9da00309 // Required by Helm

replace github.com/devfile/devworkspace-operator => github.com/dkwon17/devworkspace-operator v0.2.1-0.20221114184800-62aa6f1d7c01
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ github.com/devfile/devworkspace-operator v0.17.0/go.mod h1:xLELAolfebwROqGSvOWhd
github.com/dgrijalva/jwt-go v3.2.0+incompatible h1:7qlOGliEKZXTDg6OTjfoBKDXWrumCAMpl/TFQ4/5kLM=
github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
github.com/dhui/dktest v0.3.2/go.mod h1:l1/ib23a/CmxAe7yixtrYPc8Iy90Zy2udyaHINM5p58=
github.com/dkwon17/devworkspace-operator v0.2.1-0.20221114184800-62aa6f1d7c01 h1:qK27w9VKhAXSBXLAvCt0LiS+Du79ijEp5Fs7bvkOU2I=
github.com/dkwon17/devworkspace-operator v0.2.1-0.20221114184800-62aa6f1d7c01/go.mod h1:xLELAolfebwROqGSvOWhdC0eH7S+V7iVFzHxtm3Jf2A=
github.com/docker/cli v0.0.0-20200130152716-5d0cf8839492 h1:FwssHbCDJD025h+BchanCwE1Q8fyMgqDr2mOQAWOLGw=
github.com/docker/cli v0.0.0-20200130152716-5d0cf8839492/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8=
github.com/docker/distribution v2.7.1+incompatible h1:a5mlkVzth6W5A4fOsS3D2EO5BUmsJpcB+cRlLU7cSug=
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4585,6 +4585,9 @@ spec:
type: string
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 is the duration after which a workspace will be idled if there is no activity. To disable workspace idling due to inactivity, set this value to -1.
Expand Down
6 changes: 4 additions & 2 deletions pkg/deploy/dev-workspace-config/dev_workspace_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,10 @@ func updateOperatorConfig(cheCluster *chev2.CheCluster, operatorConfig *controll
operatorConfig.Workspace = &controllerv1alpha1.WorkspaceConfig{}
}

return updateWorkspaceConfig(pvc, pvcStrategy == constants.PerWorkspacePVCStorageStrategy, cheCluster.IsContainerBuildCapabilitiesEnabled(), operatorConfig.Workspace)
return updateWorkspaceConfig(pvc, pvcStrategy == constants.PerWorkspacePVCStorageStrategy, cheCluster.IsContainerBuildCapabilitiesEnabled(), cheCluster.Spec.DevEnvironments.PodSchedulerName, operatorConfig.Workspace)
}

func updateWorkspaceConfig(pvc *chev2.PVC, isPerWorkspacePVCStorageStrategy bool, enabledContainerBuildCapabilities bool, workspaceConfig *controllerv1alpha1.WorkspaceConfig) error {
func updateWorkspaceConfig(pvc *chev2.PVC, isPerWorkspacePVCStorageStrategy bool, enabledContainerBuildCapabilities bool, podSchedulerName string, workspaceConfig *controllerv1alpha1.WorkspaceConfig) error {
if pvc != nil {
if pvc.StorageClass != "" {
workspaceConfig.StorageClassName = &pvc.StorageClass
Expand Down Expand Up @@ -125,5 +125,7 @@ func updateWorkspaceConfig(pvc *chev2.PVC, isPerWorkspacePVCStorageStrategy bool
workspaceConfig.ContainerSecurityContext = constants.DefaultWorkspaceContainerSecurityContext.DeepCopy()
}

workspaceConfig.SchedulerName = podSchedulerName

return nil
}
120 changes: 120 additions & 0 deletions pkg/deploy/dev-workspace-config/dev_workspace_config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,126 @@ func TestReconcileDevWorkspaceConfigPerUserStorage(t *testing.T) {
},
},
},
{
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 {
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ github.com/davecgh/go-spew/spew
github.com/devfile/api/v2/pkg/apis/workspaces/v1alpha2
github.com/devfile/api/v2/pkg/attributes
github.com/devfile/api/v2/pkg/devfile
# github.com/devfile/devworkspace-operator v0.17.0
# github.com/devfile/devworkspace-operator v0.17.0 => github.com/dkwon17/devworkspace-operator v0.2.1-0.20221114184800-62aa6f1d7c01
## explicit
github.com/devfile/devworkspace-operator/apis/controller/v1alpha1
github.com/devfile/devworkspace-operator/controllers/controller/devworkspacerouting
Expand Down Expand Up @@ -1127,3 +1127,4 @@ sigs.k8s.io/yaml
# sigs.k8s.io/kustomize/api => sigs.k8s.io/kustomize/api v0.8.8
# sigs.k8s.io/kustomize/kyaml => sigs.k8s.io/kustomize/kyaml v0.10.17
# github.com/docker/docker => github.com/moby/moby v0.7.3-0.20190826074503-38ab9da00309
# github.com/devfile/devworkspace-operator => github.com/dkwon17/devworkspace-operator v0.2.1-0.20221114184800-62aa6f1d7c01

0 comments on commit 97ea796

Please sign in to comment.