Skip to content

Conversation

@sleshchenko
Copy link
Member

What does this PR do?

Improve OpenShift infrastructure to create a special service account for workspaces if there is no predefined project configured (it means that each workspace will be created in a new project which should be create by Che Server). Che Server makes sure that all needed objects (service account, roles, role bindings) exist each time before a workspace start. It is done in this way to provide backward compatibility with existing installation where some of workspaces' projects exist.

What issues does this PR fix or reference?

#10991

Release Notes

N/A

Docs PR

Will be provided further

@sleshchenko sleshchenko added status/code-review This issue has a pull request posted for it and is awaiting code review completion by the community. kind/task Internal things, technical debt, and to-do tasks to be performed. labels Sep 13, 2018
@sleshchenko sleshchenko self-assigned this Sep 13, 2018
@sleshchenko sleshchenko requested review from a user, garagatyi, ibuziuk and l0rd September 13, 2018 08:17
@sleshchenko
Copy link
Member Author

ci-test

@riuvshin
Copy link
Contributor

ci-test build report:
Build details
Test report
docker image: eclipseche/che-server:11199
https://github.com/orgs/eclipse/teams/eclipse-che-qa please check this report.

@sleshchenko sleshchenko force-pushed the workspaceServiceAccountCreation branch from 9adc196 to 86aaa3b Compare September 14, 2018 12:32
@sleshchenko
Copy link
Member Author

Tests failed because of error in che-plugin-java-debugger-server which is not changed into this PR. I rebased the PR with master branch and I'm going to restart ci tests.

@sleshchenko
Copy link
Member Author

ci-test

@riuvshin
Copy link
Contributor

ci-test build report:
Build details
Test report
docker image: eclipseche/che-server:11199
https://github.com/orgs/eclipse/teams/eclipse-che-qa please check this report.

@sleshchenko
Copy link
Member Author

@riuvshin @tolusha @tsmaeder Guys, as I see all last ci-test executions failed because of build error in che-plugin-java-debugger-server. Could you please take a look?

@tolusha
Copy link
Contributor

tolusha commented Sep 14, 2018

To be honest I have no idea.
Could you reproduce that locally?

16:04:49 [ERROR] DOCKER> Error occurred during container startup, shutting down...
16:04:49 [ERROR] DOCKER> I/O Error [Unable to start container id [fa3ea942f31a] : OCI runtime create failed: container_linux.go:348: starting container process caused "process_linux.go:301: running exec setns process for init caused \"exit status 40\"": unknown (Internal Server Error: 500)]

@sleshchenko
Copy link
Member Author

@tolusha I saw it) Do you think it happens because of CI infrastructures issue?

@tolusha
Copy link
Contributor

tolusha commented Sep 14, 2018

I think so.

@riuvshin
Copy link
Contributor

looks like docker issue, try rerun

@sleshchenko
Copy link
Member Author

ci-test

@riuvshin
Copy link
Contributor

ci-test build report:
Build details
Test report
docker image: eclipseche/che-server:11199
https://github.com/orgs/eclipse/teams/eclipse-che-qa please check this report.

Copy link

@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.

Overall looks good. Can you take a look at inlined comments?

*/
public OpenShiftProject create(String workspaceId) throws InfrastructureException {
final String projectName = isNullOrEmpty(this.projectName) ? workspaceId : this.projectName;
boolean isPredefined = !isNullOrEmpty(this.projectName);

Choose a reason for hiding this comment

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

Looks like this line can be moved to the constructor

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeap, it even can be moved to the constructor of parent class KubernetesNamespaceFactory.

So, really thank you for this comment. Because of that, I believe that I found an issue in KubernetesNamespaceFactory. isPredefined method returns true if the configured namespace isNullOrEmpty and false otherwise, but it should do vice versa.

It may be a cause of appearing a lot of error messages in ci-jobs tests about failed PVC clean up jobs.

I'll check it and will consider adding unit test for KubernetesNamespaceFactory.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

Also, I added dummy test class for OpenShiftProjectFactory and will fix it before merge.

# Defines Kubernetes Service Account name which should be specified to be bound to all workspaces pods.
# Note that Che Server won't create the service account and it should exist.
# Note that Kubernetes Infrastructure won't create the service account and it should exist.
# OpenShift infrastructure will check if project is predefined:
Copy link
Contributor

Choose a reason for hiding this comment

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

when you say "if project is predefined" you mean "if che.infra.openshift.project is set" right?

Copy link
Member Author

Choose a reason for hiding this comment

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

Right, I'll add the corresponding comment here.

@sleshchenko
Copy link
Member Author

ci-test

@riuvshin
Copy link
Contributor

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

@sleshchenko
Copy link
Member Author

Tests failed because of error in Che Dockerfiles :: Theia module that is not modified in this PR. Going to restart tests

@sleshchenko
Copy link
Member Author

ci-test

@riuvshin
Copy link
Contributor

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

Copy link
Contributor

@amisevsk amisevsk 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, just a few (not very important) quesitons.


# Defines Kubernetes Service Account name which should be specified to be bound to all workspaces pods.
# Note that Che Server won't create the service account and it should exist.
# Note that Kubernetes Infrastructure won't create the service account and it should exist.
Copy link
Contributor

Choose a reason for hiding this comment

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

This line is a little unclear to me in related to KubernetesServiceAccount.java -- we're creating a SA there if necessary right?

Copy link
Member

@ibuziuk ibuziuk Sep 18, 2018

Choose a reason for hiding this comment

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

I believe this is the limitation of the current version of k8s client - rolebindings can only be created via OpenShiftClient, not KubernetesClient

Copy link
Member Author

Choose a reason for hiding this comment

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

This line is a little unclear to me in related to KubernetesServiceAccount.java -- we're creating a SA there if necessary right?

Actually, we don't create but we wait for default SA. We are able to create a new one but because of limitation that Illya mentioned we are not able to create rolebinding and role, so it will be implemented for K8s too after upgrading to facric8-client 4.0.4.

}
}

private void createWorkspaceServiceAccount(OpenShiftClient osClient) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Just to double check: does creating a SA / rolebindings require different privileges from what the standard Che SA might be given currently (esp. on public clusters)?

Copy link
Member Author

Choose a reason for hiding this comment

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

If workspaces are configured to be created in the same namespace then Che SA needs admin rights in the current namespace (for OpenShift, now we create SA with edit rights in its project).
If workspaces are configured to be created in different namespaces then Che SA needs cluster-admin right or OAuth provider should be used, then a user should be able to create Projects and objects there.

So, I would say that service-account should be used only if:

  1. Workspaces are created in the same namespace and service account is created during deployment.
  2. Oauth provider is configured.
    Otherwise, extra privileges should be provided for Che SA. Hope it will be helpful.

# Note that Kubernetes Infrastructure won't create the service account and it should exist.
# OpenShift infrastructure will check if project is predefined(if `che.infra.openshift.project` is not empty):
# - if it is predefined then service account must exist there
# - if it is 'NULL' or empty string then infrastructure will create new OpenShift project per workspace
Copy link
Contributor

Choose a reason for hiding this comment

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

This is for single-user only, right? I'm not clear on how this would work in the multi-user case.

Copy link
Member Author

Choose a reason for hiding this comment

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

This is for both. But out-of-the-box it will work only with OAuth provider configured, without it Che SA needs extra permissions for single or multi user mode.

@garagatyi
Copy link

@eivantsov FYI

@sleshchenko
Copy link
Member Author

Tests failed again because of error in Che Dockerfiles :: Theia module that is not modified in this PR =(
Going to restart tests

@sleshchenko
Copy link
Member Author

ci-test

@sleshchenko sleshchenko force-pushed the workspaceServiceAccountCreation branch from 926a2bf to fede1b2 Compare September 20, 2018 08:36
@riuvshin
Copy link
Contributor

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

@sleshchenko sleshchenko merged commit 41b14c7 into eclipse-che:master Sep 21, 2018
@sleshchenko sleshchenko deleted the workspaceServiceAccountCreation branch September 21, 2018 05:50
@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 Sep 21, 2018
@benoitf benoitf added this to the 6.12.0 milestone Sep 21, 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.

9 participants