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

Bug 1837739: use user creator label to identify workspace resource instead of annotation #5497

Merged
merged 1 commit into from
May 22, 2020

Conversation

vikram-raj
Copy link
Member

Fixes:
https://issues.redhat.com/browse/ODC-3615

Now, we have org.eclipse.che.workspace/creator: <user UID> label in the workspace. So, this PR start using this label instead of annotation console.openshift.io/cloudshell-user: <username> to get the workspace.

@openshift-ci-robot openshift-ci-robot added the component/core Related to console core functionality label May 19, 2020
@vikram-raj
Copy link
Member Author

/cc @christianvogt

@vikram-raj
Copy link
Member Author

/retitle Bug 1837739: use user creator label to identify workspace resource instead of annotation

@openshift-ci-robot openshift-ci-robot changed the title use user creator label to identify workspace resource instead of annotation Bug 1837739: use user creator label to identify workspace resource instead of annotation May 19, 2020
@openshift-ci-robot openshift-ci-robot added the bugzilla/severity-medium Referenced Bugzilla bug's severity is medium for the branch this PR is targeting. label May 19, 2020
@openshift-ci-robot
Copy link
Contributor

@vikram-raj: This pull request references Bugzilla bug 1837739, which is valid. The bug has been moved to the POST state. The bug has been updated to refer to the pull request using the external bug tracker.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target release (4.5.0) matches configured target release for branch (4.5.0)
  • bug is in the state NEW, which is one of the valid states (NEW, ASSIGNED, ON_DEV, POST, POST)

In response to this:

Bug 1837739: use user creator label to identify workspace resource instead of annotation

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.

@openshift-ci-robot openshift-ci-robot added the bugzilla/valid-bug Indicates that a referenced Bugzilla bug is valid for the branch this PR is targeting. label May 19, 2020
(d) => d?.metadata?.annotations?.[CLOUD_SHELL_USER_ANNOTATION] === username,
);
const workspace = isKubeAdmin
? data.find((d) => d?.metadata?.labels?.[CLOUD_SHELL_CREATOR_LABEL] === '')
Copy link
Contributor

Choose a reason for hiding this comment

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

You should be using the matchLabels selector in the useK8sWatchResource hook. Search for the label match CLOUD_SHELL_CREATOR_LABEL.
This way you no longer need to loop over the results and instead you can use the first result.

Copy link
Contributor

Choose a reason for hiding this comment

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

Guys, seems we forgot to mention really important thing.
You still should filter all workspaces which are mutable. So you should check org.eclipse.che.workspace/immutable: "true" annotation.

Copy link
Contributor

Choose a reason for hiding this comment

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

Just a bit more info about immutable annotation: It guarantees that nobody who has edit rights for workspace CR will patch your terminal workspace and put custom dev container or cheEditor that will steal user's token

Copy link
Contributor

Choose a reason for hiding this comment

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

@vikram-raj keep the loop we had already for the username check and now add this immutable annotation check.

apiVersion: 'workspace.che.eclipse.org/v1alpha1',
kind: 'Workspace',
metadata: {
name,
namespace,
labels: {
[CLOUD_SHELL_LABEL]: 'true',
Copy link
Contributor

Choose a reason for hiding this comment

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

My mistake. We still need this label applied.

Comment on lines -29 to -35
selector: {
matchLabels: { [CLOUD_SHELL_LABEL]: 'true' },
},
Copy link
Contributor

Choose a reason for hiding this comment

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

My mistake. We still need this label applied.

expect(newResource.kind).toEqual(kind);
expect(newResource.metadata.name).toEqual(name);
expect(newResource.metadata.namespace).toEqual(namespace);
expect(newResource.metadata.labels[CLOUD_SHELL_LABEL]).toEqual('true');
Copy link
Contributor

Choose a reason for hiding this comment

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

Add this check back here.

@vikram-raj vikram-raj force-pushed the odc-3615 branch 2 times, most recently from f5469fa to 111c830 Compare May 21, 2020 14:57
@christianvogt
Copy link
Contributor

/hold for #5428

@openshift-ci-robot openshift-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label May 21, 2020
@christianvogt
Copy link
Contributor

/lgtm
/approve

@openshift-ci-robot openshift-ci-robot added lgtm Indicates that a PR is ready to be merged. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels May 21, 2020
@openshift-ci-robot openshift-ci-robot removed the lgtm Indicates that a PR is ready to be merged. label May 22, 2020
@christianvogt
Copy link
Contributor

/lgtm

@christianvogt
Copy link
Contributor

/retest

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label May 22, 2020
@openshift-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: christianvogt, vikram-raj

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

@christianvogt
Copy link
Contributor

/hold cancel

@openshift-ci-robot openshift-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label May 22, 2020
@openshift-merge-robot openshift-merge-robot merged commit 71b40aa into openshift:master May 22, 2020
@openshift-ci-robot
Copy link
Contributor

@vikram-raj: All pull requests linked via external trackers have merged: openshift/console#5497. Bugzilla bug 1837739 has been moved to the MODIFIED state.

In response to this:

Bug 1837739: use user creator label to identify workspace resource instead of annotation

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.

@vikram-raj vikram-raj deleted the odc-3615 branch May 22, 2020 20:33
@spadgett spadgett added this to the v4.5 milestone May 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. bugzilla/severity-medium Referenced Bugzilla bug's severity is medium for the branch this PR is targeting. bugzilla/valid-bug Indicates that a referenced Bugzilla bug is valid for the branch this PR is targeting. component/core Related to console core functionality lgtm Indicates that a PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants