Skip to content
Snippets Groups Projects
Commit 0baa78b5 authored by Bo-Chun Chen's avatar Bo-Chun Chen
Browse files

Merge branch 'fix-clean-own-image' into 'main'

Only list images owned by the user

Closes #112

See merge request rc/packer-openstack-hpc-image!79
parents 848d8839 899a39e0
No related branches found
No related tags found
No related merge requests found
...@@ -385,11 +385,12 @@ cleanup_knightly: ...@@ -385,11 +385,12 @@ cleanup_knightly:
tags: tags:
- build - build
script: script:
- OS_PROJECT_ID=$(openstack application credential show $OS_APPLICATION_CREDENTIAL_ID -f value -c project_id)
- > - >
SERVER_TO_BE_DELETE=($(openstack server list --name $OOD_INSTANCE_NAME --sort-column Image --sort-descending -f value -c ID SERVER_TO_BE_DELETE=($(openstack server list --name $OOD_INSTANCE_NAME --sort-column Image --sort-descending -f value -c ID
| awk -v NSTK=$NUM_SERVER_TO_KEEP '{count++} | awk -v NSTK=$NUM_SERVER_TO_KEEP '{count++}
{if (count>NSTK) print}')) {if (count>NSTK) print}'))
- openstack image list --sort-column Name --sort-descending -f value -c Name -c ID > images.txt - openstack image list --sort-column Name --sort-descending -f value -c Name -c ID --property owner=$OS_PROJECT_ID > images.txt
- > - >
OOD_IMAGE_TO_BE_DELETE=($(cat images.txt OOD_IMAGE_TO_BE_DELETE=($(cat images.txt
| awk -v NITK=$NUM_IMAGE_TO_KEEP -v REGEX=ood-$TIMESTAMP_REGEX | awk -v NITK=$NUM_IMAGE_TO_KEEP -v REGEX=ood-$TIMESTAMP_REGEX
...@@ -439,8 +440,9 @@ cleanup_mr: ...@@ -439,8 +440,9 @@ cleanup_mr:
tags: tags:
- build - build
script: script:
- OS_PROJECT_ID=$(openstack application credential show $OS_APPLICATION_CREDENTIAL_ID -f value -c project_id)
- > - >
IMAGE_TO_BE_DELETE=($(openstack image list --sort-column Name --sort-descending -f value -c Name -c ID IMAGE_TO_BE_DELETE=($(openstack image list --sort-column Name --sort-descending -f value -c Name -c ID --property owner=$OS_PROJECT_ID
| awk -v REGEX="(ood|base|compute|gpu)-PR-$CI_MERGE_REQUEST_IID" '{if ($0 ~ REGEX) print $1}')) | awk -v REGEX="(ood|base|compute|gpu)-PR-$CI_MERGE_REQUEST_IID" '{if ($0 ~ REGEX) print $1}'))
- | - |
for img in ${IMAGE_TO_BE_DELETE[@]}; do for img in ${IMAGE_TO_BE_DELETE[@]}; do
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment