pulp-cleanup: add nightly Jenkins job for stale Pulp resource cleanup - #2644
pulp-cleanup: add nightly Jenkins job for stale Pulp resource cleanup#2644vamahaja wants to merge 1 commit into
Conversation
f47e5f6 to
72d89d9
Compare
|
I think we need something more like chacra's retention map. Or at least leave this PR as-is but add |
Updated logic PTAL. |
c62087e to
9d67a99
Compare
a0b55c6 to
a83e10c
Compare
Add a nightly Jenkins job and cleanup script that prune stale `Ceph` project Pulp repositories and distributions using `scripts/purge-policy.yaml`. Also update `pulp_upload.sh` so repository version retention uses `keep_minimum` from the purge policy for the current `BRANCH`, falling back to the default when the ref is not listed. Signed-off-by: Vaibhav Mahajan <vamahaja@redhat.com>
There was a problem hiding this comment.
I think it makes more sense to have this in pulp-cleanup/config
| default: | ||
| days: 14 | ||
| keep_minimum: 3 | ||
| ref: |
There was a problem hiding this comment.
Add main please. Give it the same retention as a release branch
There was a problem hiding this comment.
keep_minimum is never read from anywhere in here
| readonly PULP_RESOURCES=(distribution repository) | ||
|
|
||
| # Default protection time in hours | ||
| readonly PROTECTION_TIME=24 |
There was a problem hiding this comment.
Minutes. Do 1440.
Options:
--content-hrefs TEXT List of specific Contents to delete if they are
orphans
--protection-time INTEGER How long in minutes Pulp should hold orphan
Content and Artifacts before becoming candidates
for cleanup task
|
|
||
| pulp "${type}" "${resource}" list \ | ||
| --limit "${PULP_LIST_LIMIT}" \ | ||
| --ordering '-pulp_created' \ |
There was a problem hiding this comment.
-pulp_created fetches the newest N. We want to delete the oldest N.
| --limit "${PULP_LIST_LIMIT}" \ | ||
| --ordering '-pulp_created' \ | ||
| --label-select project="${project}","${label_select}" \ | ||
| 2>&1 | sed -n '/^\[/,$p' |
There was a problem hiding this comment.
The job/script will fail silently with this. Make a failed pulp call fatal.
| echo "${pulp_json}" | jq -r --arg days "${days}" ' | ||
| .[] | ||
| | select( | ||
| (.pulp_created | split(".")[0] + "Z" | fromdateiso8601) | ||
| < (now - ($days | tonumber) * 86400) | ||
| ) | ||
| | .name | ||
| ' |
There was a problem hiding this comment.
We should filter on pulp_last_updated instead.
Also, we'll have a ceph-tentacle-rocky-10-x86_64 repository forever. We want to clean up all of the distrubutions inside that are older than 14 days but keep a minimum of 10.
So if the repository matches any of the named branches in purge-policy.yaml, we should proceed with cleaning up the distributions inside by following the policy.
If the repository doesn't match a named branch in purge_policy.yaml and its pulp_last_updated is over 14 days ago, delete the repository. If newer than 14 days, we should check inside for distributions and clean up any older than 14 days.
| script { | ||
| echo "Setting up yq..." | ||
| sh """#!/bin/bash -ex | ||
| source ./scripts/setup_yq.sh |
There was a problem hiding this comment.
Sourcing the script just defines the function. Just run it directly.
| display-name: 'Pulp: Cleanup Nightly' | ||
| project-type: pipeline | ||
| description: > | ||
| Nightly parameterized cleanup of stale Teuthology Pulp resources. |
There was a problem hiding this comment.
Suggest Nightly parameterized cleanup of stale ceph builds in Pulp
| @@ -0,0 +1,37 @@ | |||
| - job: | |||
| name: pulp-cleanup-nightly | |||
| disabled: true | |||
There was a problem hiding this comment.
The other job definitions are .yml
| mapfile -t policy_refs < <(get_policy_refs "${project}" "${label}") | ||
| _label_select=$( | ||
| printf "${label}!=%s\n" "${policy_refs[@]}" | paste -sd, - | ||
| ) |
There was a problem hiding this comment.
If anything goes wrong here, this falls back to "delete everything"
Gate on a yq failure, missing file, etc. Any error.
|
Maybe implement a "Leaving distributions X Y Z in repository ceph-tentacle-rocky-10-x86_64 to satisfy keep_minimum: 10" Something like those. I'd like to see some dry-run output before we let this loose even though the artifacts in pulp aren't terribly important yet. Finished with my review for now. |
Summary
pulp-cleanup-nightlyJenkins job that purges stalecephproject Pulp repositories and distributions usingscripts/purge-policy.yaml.label-select, deletes remaining resources past the default retention days (distributions before repositories), then runs orphan cleanup.pulp_upload.shso repository version retention uses perBRANCH&keep_minimumfrom the purge policy, with fallback to the default.Job config
pulp-cleanup-nightly, triggered@midnight.CEPH_BUILD_BRANCH(defaultmain),CEPHbool (defaulttrue) to enablecephproject cleanup.cleanup.shwhenCEPHistrue.Purge policy (
scripts/purge-policy.yaml)cephdays: 14,keep_minimum: 3keep_minimumfor repository version retention