Skip to content

Add DevWorkspace Pruner (operator-lib/prune package) #1402

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 8 commits into
base: main
Choose a base branch
from

Conversation

akurinnoy
Copy link
Contributor

@akurinnoy akurinnoy commented Mar 18, 2025

What does this PR do?

This pull request adds a new controller that prunes (removes) DevWorkspaces based on these rules:

  • DevWorkspaces that haven't been started for a specific period are considered inactive. This period is configurable.
  • The pruning behavior (enable/disable, retention time, cron schedule, dry-run mode) is configured via the DevWorkspaceOperatorConfig (DWOC) resource.
  • The pruning process is scheduled using a cron library, allowing for flexible configuration of the pruning frequency.
  • A dry-run mode is supported, allowing administrators to preview the pruning actions without actually deleting any resources.

What issues does this PR fix or reference?

resolves #1376

Is it tested? How?

  1. Deploy the operator with this new code.
  2. Ensure that the DevWorksapceOperatorConfig initially does not have pruning enabled by default
    • there is no CleanupCronJob section in the config.workspace section of the DWOC.
    • or, if there is the CleanupCronJob section, ensure that enable: false.
  3. Patch the DevWorkspaceOperatorConfig to enable pruning and set parameters:
kubectl patch DevWorkspaceOperatorConfig devworkspace-operator-config \
-n devworkspace-controller \
--type=merge \
-p '{"config": {"workspace": {"cleanupCronJob": {"enable": true, "dryRun": true, "retainTime": 60, "schedule": "* * * * *"}}}}'
  1. Create several DevWorkspaces. Some should be started, and some should not be started.
  2. Wait for the cron schedule to trigger the pruning - at least 1 minute.
  3. Check logs and verify that the correct DevWorkspaces are identified but not deleted in dry-run mode.
  4. Disable dry-run mode and verify that all eligible DevWorkspaces are actually deleted:
kubectl patch DevWorkspaceOperatorConfig devworkspace-operator-config \
-n devworkspace-controller \
--type=merge \
-p '{"config": {"workspace": {"cleanupCronJob": {"dryRun": false }}}}'

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

Sorry, something went wrong.

Copy link

openshift-ci bot commented Mar 18, 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 changed the title Operator lib prune package Add DevWorkspace Pruner (operator-lib/prune package) Mar 18, 2025
@akurinnoy akurinnoy force-pushed the operator-lib-prune-package branch 9 times, most recently from 4a44124 to 4dc83c6 Compare March 25, 2025 14:05

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
Signed-off-by: Oleksii Kurinnyi <[email protected]>
Signed-off-by: Oleksii Kurinnyi <[email protected]>
@akurinnoy akurinnoy force-pushed the operator-lib-prune-package branch from 4dc83c6 to cdbf388 Compare March 27, 2025 11:57
Signed-off-by: Oleksii Kurinnyi <[email protected]>
@akurinnoy akurinnoy force-pushed the operator-lib-prune-package branch from 78b0e3d to 3218747 Compare April 1, 2025 09:04
@akurinnoy akurinnoy marked this pull request as ready for review April 1, 2025 13:29
@akurinnoy akurinnoy requested a review from ibuziuk as a code owner April 1, 2025 13:29
@openshift-ci openshift-ci bot requested a review from dkwon17 April 1, 2025 13:29
Signed-off-by: Oleksii Kurinnyi <[email protected]>
fixes
Signed-off-by: Oleksii Kurinnyi <[email protected]>
Signed-off-by: Oleksii Kurinnyi <[email protected]>
Signed-off-by: Oleksii Kurinnyi <[email protected]>
@dkwon17
Copy link
Collaborator

dkwon17 commented Apr 22, 2025

/retest

Copy link

openshift-ci bot commented Apr 22, 2025

@akurinnoy: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/v14-devworkspace-operator-e2e 0decf40 link true /test v14-devworkspace-operator-e2e
ci/prow/v14-images 0decf40 link true /test v14-images

Full PR test history. Your PR dashboard.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

Copy link
Contributor

@ibuziuk ibuziuk left a comment

Choose a reason for hiding this comment

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

Copy link

openshift-ci bot commented Apr 24, 2025

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: akurinnoy, ibuziuk
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.

Add a devworkspace pruner to the DevWorkspace Operator
3 participants