feat: spec.devEnvironments.podSchedulerName in CR (#1587)
* feat: spec.devEnvironments.podSchedulerName in CR Signed-off-by: David Kwon <dakwon@redhat.com> Co-authored-by: Anatolii Bazko <abazko@redhat.com>pull/1590/head
parent
d8e1be1948
commit
4774568459
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue