Skip to content

fix: common PVC cleanup job to be assigned to a correct node #1415

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

akurinnoy
Copy link
Contributor

@akurinnoy akurinnoy commented Apr 17, 2025

What does this PR do?

This pull request enhances the common PVC cleanup job by adding node affinity rule.

This change modifies the cleanup job creation logic to:

  1. Read the volume.kubernetes.io/selected-node annotation from the common PVC associated with the DevWorkspace.
  2. If the annotation exists, add a requiredDuringSchedulingIgnoredDuringExecution node affinity rule to the cleanup job's pod spec, targeting the specified node.

This ensures that the cleanup job pod runs on the same node as the volume. If the annotation is not present, no node affinity is added.

What issues does this PR fix or reference?

resolves #1269

Is it tested? How?

  1. Create at least two DevWorkspaces; at least one should be running.
  2. Verify that the PVC has the volume.kubernetes.io/selected-node annotation. Note the node name specified in the annotation value.
    kubectl get pvc -n <namespace> claim-devworkspace -o jsonpath='{.metadata.annotations.volume\.kubernetes\.io/selected-node}'
  3. Delete a DevWorkspace, and leave at least one running DevWorkspace untouched.
  4. Inspect the cleanup job to verify that the node affinity rule was added:
    kubectl get job -n <namespace> <job-name> -o jsonpath='{.spec.template.spec.affinity.nodeAffinity}'
    Check that the nodeSelectorTerms target the node name noted in step 2 via the kubernetes.io/hostname key.
  5. Ensure the cleanup Job completes successfully and the DevWorkspace is deleted.

PR Checklist

  • E2E tests pass (when PR is ready, comment /test v8-devworkspace-operator-e2e, v8-che-happy-path to trigger)
    • v8-devworkspace-operator-e2e: DevWorkspace e2e test
    • v8-che-happy-path: Happy path for verification integration with Che

Copy link

openshift-ci bot commented Apr 17, 2025

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@akurinnoy akurinnoy marked this pull request as ready for review April 18, 2025 14:02
@dkwon17
Copy link
Collaborator

dkwon17 commented Apr 28, 2025

/retest

@dkwon17 dkwon17 requested a review from rohanKanojia May 3, 2025 05:59
Co-authored-by: Rohan Kumar  <[email protected]>
Signed-off-by: Oleksii Kurinnyi <[email protected]>
Copy link

openshift-ci bot commented May 7, 2025

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: akurinnoy, rohanKanojia
Once this PR has been reviewed and has the lgtm label, please assign dkwon17 for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Common PVC cleanup job can be assigned to incorrect node in multi-node cluster
3 participants