Closed weakcamel closed 2 years ago
docker-test/test/v1/manifest.json creat=2022-01-17T10:08:28.118Z modified=2022-01-17T10:10:17.194Z maxDays=1
docker-test/test/v2/manifest.json creat=2022-01-17T10:12:18.444Z modified=2022-01-17T10:12:18.439Z maxDays=1
docker-test/test/v3/manifest.json creat=2022-01-17T10:14:19.751Z modified=2022-01-17T10:14:19.747Z maxDays=1
docker-test/test/v4/manifest.json creat=2022-01-17T10:16:21.080Z modified=2022-01-17T10:16:21.075Z maxDays=1
docker-test/test/v5/manifest.json creat=2022-01-17T10:18:22.315Z modified=2022-01-17T10:18:22.311Z maxDays=1
docker-test/test/v6/manifest.json creat=2022-01-17T10:20:23.568Z modified=2022-01-17T10:20:23.564Z maxDays=1
docker-test/test/v7/manifest.json creat=2022-01-17T10:22:24.817Z modified=2022-01-17T10:22:24.813Z maxDays=1
docker-test/test/v8/manifest.json creat=2022-01-17T10:24:26.491Z modified=2022-01-17T10:24:26.486Z maxDays=1
docker-test/test/v9/manifest.json creat=2022-01-17T10:28:01.737Z modified=2022-01-17T10:28:01.731Z maxDays=1
Out of these images, none have been downloaded except for:
docker-test/test/v5/manifest.json
downloaded 20-01-22 16:41:48 +00:00
docker-test/test/v8/manifest.json
downloaded 20-01-22 16:44:03 +00:00
+ /usr/bin/curl -sSfL -X POST -u admin:<REDACTED> 'http://localhost:8081/artifactory/api/plugins/execute/cleanDockerImages?params=dryRun=true'
+ jq .
{
"status": "okay",
"dryRun": true,
"deleted": [
"docker-test:test/v1",
"docker-test:test/v2",
"docker-test:test/v3",
"docker-test:test/v4",
"docker-test:test/v5",
"docker-test:test/v6",
"docker-test:test/v7",
"docker-test:test/v8",
"docker-test:test/v9"
]
}
Trigger the plugin - byDownloadDate mode
+ /usr/bin/curl -sSfL -X POST -u admin:<REDACTED> 'http://localhost:8081/artifactory/api/plugins/execute/cleanDockerImages?params=dryRun=true;byDownloadDate=true'
+ jq .
{
"status": "okay",
"dryRun": true,
"deleted": [
"docker-test:test/v1",
"docker-test:test/v2",
"docker-test:test/v3",
"docker-test:test/v4",
"docker-test:test/v6",
"docker-test:test/v7",
"docker-test:test/v9"
]
}
#!/bin/bash
set -eEuo pipefail
for i in $(seq 1 9 | tac); do
echo "- - - - - - - - - - - - - - - - - - - - - - - - - - -"
echo "Changing maxCount to ${i}"
./jfrog rt set-props docker-test/test/**/manifest.json "docker.label.com.jfrog.artifactory.retention.maxCount=${i}" >/dev/null 2>&1
#echo "Trigger the plugin - default mode"
#./jfrog rt curl -sSfL -X POST "api/plugins/execute/cleanDockerImages?params=dryRun=true" | jq -r ".deleted | .[]"
echo "Trigger the plugin - byDownloadDate mode"
./jfrog rt curl -sSfL -X POST "api/plugins/execute/cleanDockerImages?params=dryRun=true;byDownloadDate=true" | jq -r ".deleted | .[]"
done
Image versions v1 - v9 were created in order (v1 oldest to v9 latest)
docker-test/test/v1/manifest.json creat=2022-01-17T10:08:28.118Z modified=2022-01-17T10:10:17.194Z maxDays=10
docker-test/test/v2/manifest.json creat=2022-01-17T10:12:18.444Z modified=2022-01-17T10:12:18.439Z maxDays=10
docker-test/test/v3/manifest.json creat=2022-01-17T10:14:19.751Z modified=2022-01-17T10:14:19.747Z maxDays=10
docker-test/test/v4/manifest.json creat=2022-01-17T10:16:21.080Z modified=2022-01-17T10:16:21.075Z maxDays=10
docker-test/test/v5/manifest.json creat=2022-01-17T10:18:22.315Z modified=2022-01-17T10:18:22.311Z maxDays=10
docker-test/test/v6/manifest.json creat=2022-01-17T10:20:23.568Z modified=2022-01-17T10:20:23.564Z maxDays=10
docker-test/test/v7/manifest.json creat=2022-01-17T10:22:24.817Z modified=2022-01-17T10:22:24.813Z maxDays=10
docker-test/test/v8/manifest.json creat=2022-01-17T10:24:26.491Z modified=2022-01-17T10:24:26.486Z maxDays=10
docker-test/test/v9/manifest.json creat=2022-01-17T10:28:01.737Z modified=2022-01-17T10:28:01.731Z maxDays=10
Out of these images, only these 2 have been downloaded:
docker-test/test/v5/manifest.json
downloaded 20-01-22 16:41:48 +00:00
(earlier)docker-test/test/v8/manifest.json
downloaded 20-01-22 16:44:03 +00:00
(later)byDownloadDate
root@artifactory:~# ./trigger_clean.sh
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Changing maxCount to 9
Trigger the plugin - byDownloadDate mode
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Changing maxCount to 8
Trigger the plugin - byDownloadDate mode
docker-test:test/v1
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Changing maxCount to 7
Trigger the plugin - byDownloadDate mode
docker-test:test/v1
docker-test:test/v2
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Changing maxCount to 6
Trigger the plugin - byDownloadDate mode
docker-test:test/v1
docker-test:test/v2
docker-test:test/v3
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Changing maxCount to 5
Trigger the plugin - byDownloadDate mode
docker-test:test/v1
docker-test:test/v2
docker-test:test/v3
docker-test:test/v4
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Changing maxCount to 4
Trigger the plugin - byDownloadDate mode
docker-test:test/v1
docker-test:test/v2
docker-test:test/v3
docker-test:test/v4
docker-test:test/v6
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Changing maxCount to 3
Trigger the plugin - byDownloadDate mode
docker-test:test/v1
docker-test:test/v2
docker-test:test/v3
docker-test:test/v4
docker-test:test/v6
docker-test:test/v7
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Changing maxCount to 2
Trigger the plugin - byDownloadDate mode
docker-test:test/v1
docker-test:test/v2
docker-test:test/v3
docker-test:test/v4
docker-test:test/v6
docker-test:test/v7
docker-test:test/v9
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Changing maxCount to 1
Trigger the plugin - byDownloadDate mode
docker-test:test/v1
docker-test:test/v2
docker-test:test/v3
docker-test:test/v4
docker-test:test/v6
docker-test:test/v7
docker-test:test/v9
docker-test:test/v5
root@artifactory:~#
Note the 2 last cases: image v5
was identified for removal as last and the last downloaded image v8
was not marked for removal at all.
oot@artifactory:~# ./trigger_clean.sh
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Changing maxCount to 9
Trigger the plugin - default mode
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Changing maxCount to 8
Trigger the plugin - default mode
docker-test:test/v1
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Changing maxCount to 7
Trigger the plugin - default mode
docker-test:test/v1
docker-test:test/v2
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Changing maxCount to 6
Trigger the plugin - default mode
docker-test:test/v1
docker-test:test/v2
docker-test:test/v3
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Changing maxCount to 5
Trigger the plugin - default mode
docker-test:test/v1
docker-test:test/v2
docker-test:test/v3
docker-test:test/v4
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Changing maxCount to 4
Trigger the plugin - default mode
docker-test:test/v1
docker-test:test/v2
docker-test:test/v3
docker-test:test/v4
docker-test:test/v5
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Changing maxCount to 3
Trigger the plugin - default mode
docker-test:test/v1
docker-test:test/v2
docker-test:test/v3
docker-test:test/v4
docker-test:test/v5
docker-test:test/v6
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Changing maxCount to 2
Trigger the plugin - default mode
docker-test:test/v1
docker-test:test/v2
docker-test:test/v3
docker-test:test/v4
docker-test:test/v5
docker-test:test/v6
docker-test:test/v7
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Changing maxCount to 1
Trigger the plugin - default mode
docker-test:test/v1
docker-test:test/v2
docker-test:test/v3
docker-test:test/v4
docker-test:test/v5
docker-test:test/v6
docker-test:test/v7
docker-test:test/v8
root@artifactory:~#
A draft only pull request to be able to review the changes more easily.
Implements byDownloadDate mode of operation - see https://github.com/jfrog/artifactory-user-plugins/issues/333