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

Don't fail workspaces that use Kubernetes/OpenShift components with URIs #1104

Merged
merged 2 commits into from
May 23, 2023

Conversation

amisevsk
Copy link
Collaborator

@amisevsk amisevsk commented May 19, 2023

What does this PR do?

Update how Kubernetes/OpenShift components with URIs are handled:

  • If a component has deployByDefault: false, it is ignored and workspace starts normally (the component is expected to be applied later, e.g. via an apply command
  • If a component has deployByDefault: true, it is not applied to the cluster if it uses a URI, and instead the workspace gets a warning condition. This effectively downgrades the webhook rejection to a warning condition

What issues does this PR fix or reference?

Closes #1103

Is it tested? How?

Apply the DevWorkspace

apiVersion: workspace.devfile.io/v1alpha2
kind: DevWorkspace
metadata:
  name: plain
spec:
  routingClass: basic
  started: true
  template:
    attributes:
      controller.devfile.io/storage-type: ephemeral
    components:
    - name: web-terminal
      container:
        command: ["tail", "-f", "/dev/null"]
        image: quay.io/amisevsk/web-terminal-tooling:dev
        memoryLimit: 512Mi
        mountSources: true
    - name: test-k8s
      kubernetes: 
        deployByDefault: false
        uri: https://raw.githubusercontent.com/devfile/devworkspace-operator/main/deploy/deployment/kubernetes/objects/devworkspace-controller-metrics.Service.yaml

Update the workspace to set deployByDefault:

  • If false, workspace should start normally, without any issues or warnings
  • If true, the workspace should still start, but have a warning condition:

    Ignored components that use unsupported features: component test-k8s
    defines a Kubernetes/OpenShift component via URI

PR Checklist

  • E2E tests pass (when PR is ready, comment /test v8-devworkspace-operator-e2e, v8-che-happy-path to trigger)
    • v8-devworkspace-operator-e2e: DevWorkspace e2e test
    • v8-che-happy-path: Happy path for verification integration with Che

@amisevsk amisevsk requested review from l0rd and AObuchow May 19, 2023 17:06
@amisevsk amisevsk requested a review from ibuziuk as a code owner May 19, 2023 17:06
Copy link
Collaborator

@AObuchow AObuchow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code looks good to me and works as expected on OpenShift 4.12.
Minor comment regarding documentation, but LGTM

@@ -34,11 +35,16 @@ import (
// Only Kubernetes/OpenShift components that are inlined are supported; components that define
// a URI will cause a FailError to be returned
Copy link
Collaborator

@AObuchow AObuchow May 19, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Documentation should be changed to ...a URI will cause a WarningError to be returned

@@ -42,7 +42,8 @@ func (h *WebhookHandler) validateKubernetesObjectPermissionsOnCreate(ctx context
continue
}
if component.Uri != "" {
return fmt.Errorf("kubenetes components specified via URI are unsupported")
// We're going to ignore URI components for now
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A future improvement could be to return a webhook warning (so that the dashboard could display it) but for now, I don't think this is necessary.

@codecov
Copy link

codecov bot commented May 19, 2023

Codecov Report

Patch coverage: 62.50% and project coverage change: -0.02 ⚠️

Comparison is base (89370ce) 51.64% compared to head (0319e70) 51.62%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1104      +/-   ##
==========================================
- Coverage   51.64%   51.62%   -0.02%     
==========================================
  Files          79       79              
  Lines        7285     7299      +14     
==========================================
+ Hits         3762     3768       +6     
- Misses       3237     3243       +6     
- Partials      286      288       +2     
Impacted Files Coverage Δ
webhook/workspace/handler/kubernetes.go 0.00% <0.00%> (ø)
pkg/library/kubernetes/provision.go 72.50% <54.54%> (-7.79%) ⬇️
pkg/library/kubernetes/util.go 95.55% <100.00%> (+0.55%) ⬆️

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

Ignore Kubernetes/OpenShift-type components that define a URI, allowing
such workspaces to start successfully. Instead of failing startup, add a
warning to the workspace to notify the user.

This helps us give at least partial compatibility with some standard
devfile samples, which use currently use URIs. With this change, the
workspace will at least be started (or, more accurately, partially
started).

Signed-off-by: Angel Misevski <amisevsk@redhat.com>
Update the webhook server to ignore Kubernetes and OpenShift components
that use URIs with deployByDefault: true. Instead these components
will be ignored by DWO and a warning should be added to the workspace.

Signed-off-by: Angel Misevski <amisevsk@redhat.com>
@openshift-ci openshift-ci bot removed the lgtm label May 19, 2023
@openshift-ci openshift-ci bot added the lgtm label May 19, 2023
@amisevsk
Copy link
Collaborator Author

/retest

@l0rd
Copy link
Collaborator

l0rd commented May 22, 2023

@amisevsk do you have an already built image to test this PR?

@openshift-ci
Copy link

openshift-ci bot commented May 23, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: amisevsk, AObuchow, ibuziuk

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@l0rd
Copy link
Collaborator

l0rd commented May 23, 2023

I have tested with https://github.com/devfile-samples/devfile-sample-go-basic.git and I was able to start the workspace successfully.

The weird thing is that my workspace pod has 3 containers (but it may be related to a dashboard issue that ignores the parent and adds a default component):

image

NOTE: I have tested using Dev Spaces 3.6

@amisevsk
Copy link
Collaborator Author

do you have an already built image to test this PR?

I didn't build a specific image for this PR, so it was only pushed to quay.io/amisevsk/devworkspace-controller:dev (which is the image I use for whatever I'm working on).

The weird thing is that my workspace pod has 3 containers (but it may be related to a dashboard issue that ignores the parent and adds a default component):

This should be reported as an issue on the Eclipse Che side -- it looks like something is going wrong with merging components. The runtime component is coming from the parent, but since #993 the che-code-runtime-description component should have been merged into it automatically (i.e. even without the explicit merge-components attribute). I tried briefly to reproduce the issue but would need to roll changes from this PR out to test properly.

@amisevsk amisevsk merged commit 636b1a5 into devfile:main May 23, 2023
@amisevsk amisevsk deleted the kubernetes-components-uri branch May 23, 2023 16:55
@l0rd
Copy link
Collaborator

l0rd commented May 23, 2023

I opened the parent issue a few weeks ago and it has been fixed Che-side but not back ported to 3.6. So yes, probably related to that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Workspaces that define Kubernetes/OpenShift components with URIs always fail to start
4 participants