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

feat: manage default uri plugins for DevWorkspaces #425

Closed
wants to merge 1 commit into from

Conversation

dkwon17
Copy link
Contributor

@dkwon17 dkwon17 commented Dec 13, 2021

What does this PR do?

This PR provides support for adding/deleting default plugins for DevWorkspaces. This PR only supports managing plugins specified by url to a v2 devfile / DW / DWT.

Example plugin urls:

Default plugin urls are to be added to the Che CR's server.workspaceDefaultPlugins field, which is introduced in this PR: eclipse-che/che-operator#1248.

Example:

  server:
    workspacesDefaultPlugins:
      - editor: 'eclipse/che-theia/latest'
        plugins: ['https://eclipse-che.github.io/che-plugin-registry/main/v3/plugins/containers/buildah/latest/devfile.yaml']

What issues does this PR fix or reference?

This PR brings support for specifying default plugins by url in the CR for: eclipse-che/che#20090

Is it tested? How?

  1. Deploy Che using the chectl command from this PR: eclipse-che/che-operator#1248, with this patch:
spec:
 devWorkspace:
   enabled: true
 server:
    dashboardImagePullPolicy: Always
    dashboardImage: 'quay.io/dkwon17/che-dashboard:che-20090'
  1. Add this field to the existing CheCluster CR:
  server:
    workspacesDefaultPlugins:
      - editor: 'eclipse/che-theia/next'
        plugins: ['https://eclipse-che.github.io/che-plugin-registry/main/v3/plugins/containers/buildah/latest/devfile.yaml']
  1. Start a devworkspace from the che-dashboard. For the screenshot below, I created a Go devworkspace.

  2. Verify that the devworkspace has a plugin component for the default plugin
    image

  3. Remove server.workspacesDefaultPlugins from the CheCluster CR.

  4. Start the same devworkspace from step 4, and verify that the devworkspace does not have the default plugin anymore
    image

Release Notes

Docs PR

TODO

@che-bot
Copy link
Contributor

che-bot commented Dec 13, 2021

Can one of the admins verify this patch?


workspace.spec.template.components.push({
name: pluginName,
attributes: { [DEFAULT_PLUGIN_ATTRIBUTE]: true },
Copy link
Contributor Author

Choose a reason for hiding this comment

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

An attribute is being set here (default-plugin), in order to distinguish between non-default and default plugins in spec.template.components:
image

});
}

private isUri(str: string) {
Copy link
Member

Choose a reason for hiding this comment

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

my understanding is that if the definition of the plugin is not valid (not URI), there will be no error message, and the plugins will not be processed at all. Probably a good idea, but can we possibly at least log it somehow

Copy link
Contributor Author

@dkwon17 dkwon17 Dec 15, 2021

Choose a reason for hiding this comment

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

Yes, that's how it works, and sounds good, I've updated the PR with logging:

const defaultUriPlugins = new Set(defaultPlugins.filter(plugin => {
if (this.isUri(plugin)) {
return true;
}
console.log(`Default plugin ${plugin} is not a uri. Ignoring.`);
return false;
}));

import { V1alpha2DevWorkspaceSpecTemplateComponents } from '@devfile/api';
import * as DwApi from '../../dashboard-backend-client/devWorkspaceApi';

const DEFAULT_PLUGIN_ATTRIBUTE = 'default-plugin';
Copy link
Member

Choose a reason for hiding this comment

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

@amisevsk wdyt? is it ok to add extra attribute in the plugin definition - https://github.com/eclipse-che/che-dashboard/pull/425/files#r768182143

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, it's not a problem. Attributes are intended to be implementation-dependant additional info, so this field is intended for use by other tools (DWO does this too). The only recommendation I'd have is to use a prefix to scope the attribute to Che itself, e.g. che.eclipse.org/default-plugin

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, updated to use che.eclipse.org/default-plugin

@codecov
Copy link

codecov bot commented Dec 14, 2021

Codecov Report

Merging #425 (0903fac) into main (6dcde16) will increase coverage by 0.20%.
The diff coverage is 69.81%.

❗ Current head 0903fac differs from pull request most recent head 6aeacf6. Consider uploading reports for the commit 6aeacf6 to get more accurate results
Impacted file tree graph

@@            Coverage Diff             @@
##             main     #425      +/-   ##
==========================================
+ Coverage   49.61%   49.81%   +0.20%     
==========================================
  Files         211      213       +2     
  Lines        7242     7265      +23     
  Branches     1199     1201       +2     
==========================================
+ Hits         3593     3619      +26     
+ Misses       3308     3300       -8     
- Partials      341      346       +5     
Impacted Files Coverage Δ
...ontend/src/store/Workspaces/devWorkspaces/index.ts 10.19% <0.00%> (-0.70%) ⬇️
...rvices/dashboard-backend-client/serverConfigApi.ts 36.36% <36.36%> (ø)
.../devworkspace/DevWorkspaceDefaultPluginsHandler.ts 78.94% <78.94%> (ø)
...orkspace-client/devworkspace/devWorkspaceClient.ts 45.88% <100.00%> (+0.71%) ⬆️
...ashboard-frontend/src/components/LogsTab/index.tsx 76.59% <0.00%> (-4.66%) ⬇️
...frontend/src/containers/WorkspaceActions/index.tsx 77.38% <0.00%> (-0.78%) ⬇️
...s/dashboard-frontend/src/store/Workspaces/index.ts 7.25% <0.00%> (ø)
...rd-frontend/src/containers/FactoryLoader/index.tsx 73.59% <0.00%> (ø)
...es/dashboard-frontend/src/containers/IdeLoader.tsx 50.96% <0.00%> (+0.01%) ⬆️
... and 4 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6dcde16...6aeacf6. Read the comment docs.

@openshift-ci
Copy link

openshift-ci bot commented Dec 15, 2021

[APPROVALNOTIFIER] This PR is NOT APPROVED

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

The full list of commands accepted by this bot can be found 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

@dkwon17
Copy link
Contributor Author

dkwon17 commented Dec 15, 2021

I have created a new PR on the original repository: #426

Signed-off-by: David Kwon <dakwon@redhat.com>
@openshift-ci
Copy link

openshift-ci bot commented Dec 16, 2021

New changes are detected. LGTM label has been removed.

@dmytro-ndp
Copy link
Contributor

[dashboard-ci-test]

@che-bot
Copy link
Contributor

che-bot commented Dec 16, 2021

✅ E2E dashboard tests succeed 🎉

See Details

Test product:

  • Use comment "[dashboard-ci-test]" to rerun the dashboard e2e tests

Eclipse Che QE channel: https://mattermost.eclipse.org/eclipse/channels/eclipse-che-qe

@openshift-ci
Copy link

openshift-ci bot commented Dec 20, 2021

@dkwon17: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/v8-dashboard-happy-path a313f38 link true /test v8-dashboard-happy-path

Full PR test history. Your PR dashboard.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here.

@dkwon17
Copy link
Contributor Author

dkwon17 commented Dec 21, 2021

Closing in favour of #425

@dkwon17 dkwon17 closed this Dec 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants