Skip to content
This repository has been archived by the owner on Mar 17, 2021. It is now read-only.

Bayesian compatibility and workspace cleaning with multi-tenancy #417

Conversation

davidfestal
Copy link
Collaborator

Signed-off-by: David Festal dfestal@redhat.com

What does this PR do?

This PR now uses the last changes made in upstream to support proper workspace cleaning (PR eclipse-che/che#7243), and make the Bayesian plugin work with multi-tenancy (issue #376) by:

  • creating a service endpoint started on wsmaster along with the
    Bayesian Agent, to provide the required up-to-date token (from the user
    that started the workspace) from the machine token of the workspace
    agent
  • retrieving this token endpoint when starting the language server on
    the workspace agent.

What issues does this PR fix or reference?

#376

How have you tested this PR?

Deployed the resulting image on the AWS cluster, started a workspace on my OSIO account, got a Bayesian warning on a pom.xml file.

Signed-off-by: David Festal <dfestal@redhat.com>
) ...

... by:

- creating a service endpoint started on wsmaster along with the
Bayesian Agent, to provide the required up-to-date token (from the user
that started the workspace)  from the machine token of the workspace
agent
- retrieving this token endpoint when starting the language server on
the workspace agent.

Signed-off-by: David Festal <dfestal@redhat.com>
@davidfestal davidfestal self-assigned this Nov 8, 2017
@davidfestal davidfestal requested a review from tsmaeder November 8, 2017 14:36
@davidfestal davidfestal changed the title First part of the work for Bayesian compatibility and workspace cleaning Bayesian compatibility and workspace cleaning with multi-tenancy Nov 8, 2017
}
try {
return tokenCache.get(keycloakToken);
} catch (ExecutionException e) {
throw new OpenShiftException(
"Cound not retrieve OSO token from Keycloak token: " + keycloakToken, e.getCause());
"Cound not retrieve OSO token from Keycloak token for user: "
Copy link
Contributor

@l0rd l0rd Nov 8, 2017

Choose a reason for hiding this comment

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

s/Cound/Could/

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fixed

Signed-off-by: David Festal <dfestal@redhat.com>
@GET
@Path("/token")
@Produces(MediaType.APPLICATION_JSON)
public Response getBayesianToken(@HeaderParam(HttpHeaders.AUTHORIZATION) String machineToken)
Copy link
Member

Choose a reason for hiding this comment

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

am I correct that with getBayesianToken we do not need to have RECOMMENDER_API_TOKEN [1] as a secret in the template

[1] b4bbc02#diff-c98f3dce05b630b31da8dbdfee24da1fL9

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yes

}

LOG.info("Recommender token : {}", recommenderToken);
Copy link
Contributor

Choose a reason for hiding this comment

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

is that token should be displayed by default ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

no, I should have removed this after tests

if (keycloakToken == null) {
throw new OpenShiftException("User Openshift token is needed but there is no current user");
throw new OpenShiftException(
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe add a inner method to display subject

subject.getUserName()
 +              + "("
 +              + subject.getUserId()
 +              + ")",

as it is used several times in this class

workspaceStarter.getUserName());
throw new NotFoundException("Bayesian token not found");
}
return Response.ok("\"" + keycloakToken + '"').build();
Copy link
Contributor

Choose a reason for hiding this comment

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

you've used "\"" for the left part but '"' for the right part ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

''"' + keycloakToken + '"' doesn't compile since the first element of the +-based concatenation should be a String. The last one can be a char, which I assume involves one less string allocation.

public Response getBayesianToken(@HeaderParam(HttpHeaders.AUTHORIZATION) String machineToken)
throws NotFoundException {
String workspaceId = machineTokenRegistry.getWorkspaceId(machineToken);
LOG.info("workspaceId for Bayesian recommender token retrieval: {}", workspaceId);
Copy link
Contributor

Choose a reason for hiding this comment

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

it seems to me there are too many info log level on this PR but it may only myself.

Signed-off-by: David Festal <dfestal@redhat.com>
Signed-off-by: David Festal <dfestal@redhat.com>
Signed-off-by: David Festal <dfestal@redhat.com>
@davidfestal davidfestal merged commit dcbb673 into redhat-developer:multi-tenant-rh-che Nov 13, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants