Skip to content

Fail workspace validation if config contains both ws.next plugins and installers#11392

Merged
amisevsk merged 2 commits intoeclipse-che:masterfrom
amisevsk:issue-11259
Oct 1, 2018
Merged

Fail workspace validation if config contains both ws.next plugins and installers#11392
amisevsk merged 2 commits intoeclipse-che:masterfrom
amisevsk:issue-11259

Conversation

@amisevsk
Copy link
Copy Markdown
Contributor

What does this PR do?

Checks if a workspace config contains both ws.next config options (editor, plugins) and installers during validation.

One potential shortcoming of the way this is currently implemented is that validation only occurs on creation/modification, so existing workspace with the issue will continue to launch. @garagatyi is this something we should also fix, or no?

What issues does this PR fix or reference?

#11259

Raise error if workspace config contains both plugins and installers,
preventing user from creating workspace with both, which can result in
confusion.

Signed-off-by: Angel Misevski <amisevsk@redhat.com>
@amisevsk amisevsk added the kind/task Internal things, technical debt, and to-do tasks to be performed. label Sep 27, 2018
@amisevsk
Copy link
Copy Markdown
Contributor Author

ci-test

@benoitf benoitf added the status/code-review This issue has a pull request posted for it and is awaiting code review completion by the community. label Sep 27, 2018
@amisevsk amisevsk changed the title Fail workspace validation if config contains both plugins and installers Fail workspace validation if config contains both ws.next plugins and installers Sep 27, 2018
@riuvshin
Copy link
Copy Markdown
Contributor

Results of automated E2E tests of Eclipse Che Multiuser on OCP:
Build details
Test report
docker image: eclipseche/che-server:11392
https://github.com/orgs/eclipse/teams/eclipse-che-qa please check this report.

.map(MachineConfig::getInstallers)
.flatMap(List::stream))
.flatMap(Function.identity())
.collect(Collectors.toList());
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think you don't need to collect all items and findAny will be enough here

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Yeah, it can be simpler a bit.

config
            .getEnvironments()
            .values()
            .stream()
            .flatMap(env -> env.getMachines().values().stream()) //convert stream of envs to stream of machines
            .flatMap(machine -> machine.getInstallers())// convert to a stream of installers
            .blahblah() // find if there is at least 1 entry 

And also:

wsNext = attributes.containsKey(PLUGINS_ATTRIBUTE) || attributes.containsKey(EDITOR_ATTRIBUTE) 

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the installers advice, I'll make that change. For the attributes, containsKey won't work because if e.g. a user toggles plugins on and off while creating a workspace it will add the attribute "plugins" with an empty key, and this can't be fixed during workspace creation.

* Check that workspace has either plugins defined in attributes (Che 7) or installers defined in
* machines (Che 6).
*
* @throws ValidationException
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please add few words when this exception can be thrown

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed

private static final Pattern VOLUME_NAME = Pattern.compile("[a-z][a-z0-9]{1,18}");
private static final Pattern VOLUME_PATH = Pattern.compile("/.+");

static final String PLUGINS_ATTRIBUTE = "plugins";
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ah didn't see, thanks. Will fix.

Copy link
Copy Markdown

@garagatyi garagatyi left a comment

Choose a reason for hiding this comment

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

Looks good!

Signed-off-by: Angel Misevski <amisevsk@redhat.com>
@amisevsk amisevsk merged commit 77a6f57 into eclipse-che:master Oct 1, 2018
@amisevsk amisevsk deleted the issue-11259 branch October 1, 2018 03:04
@benoitf benoitf removed the status/code-review This issue has a pull request posted for it and is awaiting code review completion by the community. label Oct 1, 2018
@benoitf benoitf added this to the 6.12.0 milestone Oct 1, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/task Internal things, technical debt, and to-do tasks to be performed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants