Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support devWorkspace.ignoredUnrecoverableEvents. #1864

Merged
Merged
Show file tree
Hide file tree
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
7 changes: 7 additions & 0 deletions api/v2/checluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,13 @@ type CheClusterDevEnvironments struct {
// WorkspacesPodAnnotations defines additional annotations for workspace pods.
// +optional
WorkspacesPodAnnotations map[string]string `json:"workspacesPodAnnotations,omitempty"`
// IgnoredUnrecoverableEvents defines a list of Kubernetes event names that should
// be ignored when deciding to fail a workspace that is starting. This option should be used
// if a transient cluster issue is triggering false-positives (for example, if
// the cluster occasionally encounters FailedScheduling events). Events listed
// here will not trigger workspace failures.
// +optional
IgnoredUnrecoverableEvents []string `json:"ignoredUnrecoverableEvents,omitempty"`
}

// Che components configuration.
Expand Down
5 changes: 5 additions & 0 deletions api/v2/zz_generated.deepcopy.go

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

Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,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.88.0-873.next
name: eclipse-che.v7.89.0-876.next
namespace: placeholder
spec:
apiservicedefinitions: {}
Expand Down Expand Up @@ -1036,7 +1036,7 @@ spec:
minKubeVersion: 1.19.0
provider:
name: Eclipse Foundation
version: 7.88.0-873.next
version: 7.89.0-876.next
webhookdefinitions:
- admissionReviewVersions:
- v1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7010,6 +7010,16 @@ spec:
type: object
type: object
type: object
ignoredUnrecoverableEvents:
description: |-
IgnoredUnrecoverableEvents defines a list of Kubernetes event names that should
be ignored when deciding to fail a workspace that is starting. This option should be used
if a transient cluster issue is triggering false-positives (for example, if
the cluster occasionally encounters FailedScheduling events). Events listed
here will not trigger workspace failures.
items:
type: string
type: array
imagePullPolicy:
description: ImagePullPolicy defines the imagePullPolicy used
for containers in a DevWorkspace.
Expand Down
10 changes: 10 additions & 0 deletions config/crd/bases/org.eclipse.che_checlusters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6963,6 +6963,16 @@ spec:
type: object
type: object
type: object
ignoredUnrecoverableEvents:
description: |-
IgnoredUnrecoverableEvents defines a list of Kubernetes event names that should
be ignored when deciding to fail a workspace that is starting. This option should be used
if a transient cluster issue is triggering false-positives (for example, if
the cluster occasionally encounters FailedScheduling events). Events listed
here will not trigger workspace failures.
items:
type: string
type: array
imagePullPolicy:
description: ImagePullPolicy defines the imagePullPolicy used
for containers in a DevWorkspace.
Expand Down
10 changes: 10 additions & 0 deletions deploy/deployment/kubernetes/combined.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6984,6 +6984,16 @@ spec:
type: object
type: object
type: object
ignoredUnrecoverableEvents:
description: |-
IgnoredUnrecoverableEvents defines a list of Kubernetes event names that should
be ignored when deciding to fail a workspace that is starting. This option should be used
if a transient cluster issue is triggering false-positives (for example, if
the cluster occasionally encounters FailedScheduling events). Events listed
here will not trigger workspace failures.
items:
type: string
type: array
imagePullPolicy:
description: ImagePullPolicy defines the imagePullPolicy used
for containers in a DevWorkspace.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6979,6 +6979,16 @@ spec:
type: object
type: object
type: object
ignoredUnrecoverableEvents:
description: |-
IgnoredUnrecoverableEvents defines a list of Kubernetes event names that should
be ignored when deciding to fail a workspace that is starting. This option should be used
if a transient cluster issue is triggering false-positives (for example, if
the cluster occasionally encounters FailedScheduling events). Events listed
here will not trigger workspace failures.
items:
type: string
type: array
imagePullPolicy:
description: ImagePullPolicy defines the imagePullPolicy used
for containers in a DevWorkspace.
Expand Down
10 changes: 10 additions & 0 deletions deploy/deployment/openshift/combined.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6984,6 +6984,16 @@ spec:
type: object
type: object
type: object
ignoredUnrecoverableEvents:
description: |-
IgnoredUnrecoverableEvents defines a list of Kubernetes event names that should
be ignored when deciding to fail a workspace that is starting. This option should be used
if a transient cluster issue is triggering false-positives (for example, if
the cluster occasionally encounters FailedScheduling events). Events listed
here will not trigger workspace failures.
items:
type: string
type: array
imagePullPolicy:
description: ImagePullPolicy defines the imagePullPolicy used
for containers in a DevWorkspace.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6979,6 +6979,16 @@ spec:
type: object
type: object
type: object
ignoredUnrecoverableEvents:
description: |-
IgnoredUnrecoverableEvents defines a list of Kubernetes event names that should
be ignored when deciding to fail a workspace that is starting. This option should be used
if a transient cluster issue is triggering false-positives (for example, if
the cluster occasionally encounters FailedScheduling events). Events listed
here will not trigger workspace failures.
items:
type: string
type: array
imagePullPolicy:
description: ImagePullPolicy defines the imagePullPolicy used
for containers in a DevWorkspace.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6979,6 +6979,16 @@ spec:
type: object
type: object
type: object
ignoredUnrecoverableEvents:
description: |-
IgnoredUnrecoverableEvents defines a list of Kubernetes event names that should
be ignored when deciding to fail a workspace that is starting. This option should be used
if a transient cluster issue is triggering false-positives (for example, if
the cluster occasionally encounters FailedScheduling events). Events listed
here will not trigger workspace failures.
items:
type: string
type: array
imagePullPolicy:
description: ImagePullPolicy defines the imagePullPolicy used
for containers in a DevWorkspace.
Expand Down
6 changes: 6 additions & 0 deletions pkg/deploy/dev-workspace-config/dev_workspace_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ func updateWorkspaceConfig(ctx *chetypes.DeployContext, operatorConfig *controll

updateAnnotations(devEnvironments.WorkspacesPodAnnotations, operatorConfig.Workspace)

updateIgnoredUnrecoverableEvents(devEnvironments.IgnoredUnrecoverableEvents, operatorConfig.Workspace)

// If the CheCluster has a configured proxy, or if the Che Operator has detected a proxy configuration,
// we need to disable automatic proxy handling in the DevWorkspace Operator as its implementation collides
// with ours -- they set environment variables the deployment spec explicitly, which overrides the proxy-settings
Expand Down Expand Up @@ -200,6 +202,10 @@ func updateAnnotations(annotations map[string]string, workspaceConfig *controlle
workspaceConfig.PodAnnotations = annotations
}

func updateIgnoredUnrecoverableEvents(ignoredUnrecoverableEvents []string, workspaceConfig *controllerv1alpha1.WorkspaceConfig) {
workspaceConfig.IgnoredUnrecoverableEvents = ignoredUnrecoverableEvents
}

func updateWorkspaceServiceAccountConfig(devEnvironments *chev2.CheClusterDevEnvironments, workspaceConfig *controllerv1alpha1.WorkspaceConfig) {
isNamespaceAutoProvisioned := pointer.BoolDeref(devEnvironments.DefaultNamespace.AutoProvision, constants.DefaultAutoProvision)

Expand Down
92 changes: 92 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 @@ -2358,3 +2358,95 @@ func TestReconcileDevWorkspaceAnnotations(t *testing.T) {
})
}
}

func TestReconcileDevWorkspaceIgnoredUnrecoverableEvents(t *testing.T) {
type testCase struct {
name string
cheCluster *chev2.CheCluster
existedObjects []runtime.Object
expectedOperatorConfig *controllerv1alpha1.OperatorConfiguration
}

var testCases = []testCase{
{
name: "Set events",
cheCluster: &chev2.CheCluster{
ObjectMeta: metav1.ObjectMeta{
Namespace: "eclipse-che",
Name: "eclipse-che",
},
Spec: chev2.CheClusterSpec{
DevEnvironments: chev2.CheClusterDevEnvironments{
IgnoredUnrecoverableEvents: []string{
"value1",
"value2",
},
},
},
},
expectedOperatorConfig: &controllerv1alpha1.OperatorConfiguration{
Workspace: &controllerv1alpha1.WorkspaceConfig{
IgnoredUnrecoverableEvents: []string{
"value1",
"value2",
},
},
},
},
{
name: "Remove events",
cheCluster: &chev2.CheCluster{
ObjectMeta: metav1.ObjectMeta{
Namespace: "eclipse-che",
Name: "eclipse-che",
},
Spec: chev2.CheClusterSpec{
DevEnvironments: chev2.CheClusterDevEnvironments{
IgnoredUnrecoverableEvents: nil,
},
},
},
expectedOperatorConfig: &controllerv1alpha1.OperatorConfiguration{
Workspace: &controllerv1alpha1.WorkspaceConfig{
IgnoredUnrecoverableEvents: nil,
},
},
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{
IgnoredUnrecoverableEvents: []string{
"value1",
"value2",
},
},
},
},
},
},
}

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.IgnoredUnrecoverableEvents, dwoc.Config.Workspace.IgnoredUnrecoverableEvents)
})
}
}
Loading