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

Improve session pod labels #362

Merged
merged 3 commits into from
Nov 28, 2024
Merged

Conversation

xai
Copy link
Contributor

@xai xai commented Oct 22, 2024

org.eclipse.theia.cloud.common.util.LabelsUtil is added to encapsulate creation of labels.

To indicate that a pod is a user session, its
'app.kubernetes.io/component' label is set to 'session'.

For custom labels, we use the prefix 'theia-cloud.io'.

This is currently used for:

  • Identifying a session pods associated with a user: 'theia-cloud.io/user' = '$username'
  • Identifying a session pod by appdefinition name: 'theia-cloud.io/app-definition' = $appdefinitionname

#366

Copy link
Contributor

@lucas-koehler lucas-koehler left a comment

Choose a reason for hiding this comment

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

Hi @xai ,
Thanks for this improvement :) Generally the changes look pretty good to me already. I have a few small remarks inline. Please have a look :)

try {
client.services().inNamespace(client.namespace()).withName(serviceToUse.get().getMetadata().getName())
.edit(service -> {
LOGGER.info("Setting pod labels");
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this should only be a debug level log as nothing exiting or too relevant happens here functionality wise.

Suggested change
LOGGER.info("Setting pod labels");
LOGGER.debug("Setting service labels");

@@ -444,6 +446,16 @@ protected void createAndApplyDeployment(String correlationId, String sessionReso
}
K8sUtil.loadAndCreateDeploymentWithOwnerReference(client.kubernetes(), client.namespace(), correlationId,
deploymentYaml, Session.API, Session.KIND, sessionResourceName, sessionResourceUID, 0, deployment -> {

LOGGER.info("Setting pod labels");
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this should only be a debug level log as nothing exiting or too relevant happens here functionality wise.

Suggested change
LOGGER.info("Setting pod labels");
LOGGER.debug("Setting pod labels");

@jfaltermeier
Copy link
Contributor

jfaltermeier commented Oct 23, 2024

I tested the current state and the labels are getting added as expected 👍

At the moment, in the EagerStartSessionHandler, we’re only adjusting the service labels, and in the LazySessionHandler, labels are only being added to deployments.

In the long run, I think we should consider adding the same labels to all deployments, services, and configmaps that are created. For the LazySessionHandler, this would mean updating the following:

  • createAndApplyService
  • createAndApplyEmailConfigMap
  • createAndApplyProxyConfigMap
  • createAndApplyDeployment

We could pass label maps to these methods now, and they would forward them to:

  • loadAndCreateServiceWithOwnerReference
  • loadAndCreateConfigMapWithOwnerReference
  • loadAndCreateDeploymentWithOwnerReference

I think we may also ignore the EagerStartSessionHandler for now.
I am not sure if we should remove this handler for 1.0.0, since it does not cover all functionality anyway.

@lucas-koehler
Copy link
Contributor

In the long run, I think we should consider adding the same labels to all deployments, services, and configmaps that are created.

I agree: Eventually we should label all components created by Theia Cloud, either by the operator or the Helm charts.

I think we may also ignore the EagerStartSessionHandler for now.
I am not sure if we should remove this handler for 1.0.0, since it does not cover all functionality anyway.

I think we should leave it in but make very clear in the documentation on the website, the helm charts and potentially here that the implementation is not up to par. My reason for leaving it in is that it might encourage contributions to improve this and shows our intent on bringing this up to par eventually. Furthermore, it allows basic prototyping of eager start. WDYT?

@jfaltermeier
Copy link
Contributor

I think we should leave it in but make very clear in the documentation on the website, the helm charts and potentially here that the implementation is not up to par. My reason for leaving it in is that it might encourage contributions to improve this and shows our intent on bringing this up to par eventually. Furthermore, it allows basic prototyping of eager start. WDYT?

Sounds good

xai added 2 commits November 20, 2024 09:36
org.eclipse.theia.cloud.common.util.LabelsUtil is added to encapsulate
creation of labels.

To indicate that a pod is a user session, its
'app.kubernetes.io/component' label is set to 'session'.

For custom labels, we use the prefix 'theia-cloud.io'.

This is currently used for:
- Identifying a session pods associated with a user:
  'theia-cloud.io/user' = '$username'
- Identifying a session pod by appdefinition name:
  'theia-cloud.io/app-definition' = $appdefinitionname

Signed-off-by: Olaf Lessenich <[email protected]>
Copy link
Contributor

@jfaltermeier jfaltermeier left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@lucas-koehler lucas-koehler left a comment

Choose a reason for hiding this comment

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

Code changes LGTM me. I have one very minor, non-blocking suggestion inline.
I did not retest the second iteration though. @jfaltermeier Did you test it? Otherwise, I can still do it.

@jfaltermeier
Copy link
Contributor

Code changes LGTM me. I have one very minor, non-blocking suggestion inline. I did not retest the second iteration though. @jfaltermeier Did you test it? Otherwise, I can still do it.

I did a short test and saw the labels on pods, deployments, services, and config maps

…rg/eclipse/theia/cloud/operator/util/K8sUtil.java

Co-authored-by: Lucas Koehler <[email protected]>
@jfaltermeier jfaltermeier merged commit 518c317 into eclipse-theia:main Nov 28, 2024
13 of 14 checks passed
@jfaltermeier jfaltermeier linked an issue Nov 28, 2024 that may be closed by this pull request
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.

Improve labeling of k8s components
3 participants