Created
February 3, 2023 13:42
-
-
Save fuweid/d2b71d973c5e39f09a423b6b3d4e9e41 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
set -euo pipefail | |
target_snapshot_id=$1 | |
parent_id="" | |
snapshot_ids="" | |
# ensure that it is valid input | |
ctr -n k8s.io snapshot usage $target_snapshot_id > /dev/null | |
snapshot_ids=$target_snapshot_id | |
while true; do | |
parent_id=$(ctr -n k8s.io snapshot info $target_snapshot_id | jq '.Parent | if . then . else "" end' -r) | |
if [[ ${parent_id} == "" ]]; then | |
break | |
fi | |
target_snapshot_id=$parent_id | |
parent_id="" | |
snapshot_ids="${snapshot_ids} ${target_snapshot_id}" | |
done | |
ctr -n k8s.io snapshot usage $snapshot_ids |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment