Skip to content

Commit

Permalink
fix retain label sorting: recreated vs / prepopulated vsc creationTim…
Browse files Browse the repository at this point in the history
…e must be properly respected (via status)
  • Loading branch information
majodev committed Oct 31, 2024
1 parent 7fa7fb9 commit c0e7400
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ alias:
- &IMAGE_DEPLOY_ID ${DRONE_REPO,,}:${DRONE_COMMIT_SHA}

# Defines which branches will trigger a docker image push our Google Cloud Registry (tags are always published)
- &GCR_PUBLISH_BRANCHES [main, mr/go]
- &GCR_PUBLISH_BRANCHES [main, dev]

# Docker registry publish default settings
- &GCR_REGISTRY_SETTINGS
Expand Down
3 changes: 2 additions & 1 deletion reference/lib/vs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,8 @@ vs_apply_retain_policy() {
log "processing ns='${ns}' pvc_label='${pvc_label}' retain_label='${retain_label}' retain_count='${retain_count}'..."

# we keep the last $retain_count daily snapshots, let's get all current volumesnapshots with the label "$retain_label" sorted by latest asc
local sorted_snapshots; sorted_snapshots=$(kubectl -n "$ns" get volumesnapshot -l"$retain_label","$pvc_label" -o=jsonpath='{range .items[*]}{.metadata.name}{"\n"}{end}' --sort-by=.metadata.creationTimestamp | tac)
# ensure to use .status.creationTime instead of .metadata.creationTimestamp as restored vs from dangling vsc (new preprovided vsc) are correctly sorted again!
local sorted_snapshots; sorted_snapshots=$(kubectl -n "$ns" get volumesnapshot -l"$retain_label","$pvc_label" -o=jsonpath='{range .items[*]}{.metadata.name}{"\n"}{end}' --sort-by=.status.creationTime | tac)

local snapshots_retained; snapshots_retained=$(echo "$sorted_snapshots" | head -n "$retain_count")

Expand Down

0 comments on commit c0e7400

Please sign in to comment.