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

Split image clean up job to integration project

parent 4e881e50
No related branches found
No related tags found
No related merge requests found
......@@ -437,6 +437,8 @@ deploy_cheaha:
cleanup_knightly:
stage: cleanup
environment:
name: knightly
tags:
- build
script:
......@@ -445,6 +447,20 @@ cleanup_knightly:
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++}
{if (count>NSTK) print}'))
- |
for svr in ${SERVER_TO_BE_DELETE[@]}; do
openstack server delete ${svr}
done
rules:
- if: $CI_PIPELINE_SOURCE == "schedule"
when: always
cleanup_integration:
stage: cleanup
tags:
- build
script:
- OS_PROJECT_ID=$(openstack application credential show $OS_APPLICATION_CREDENTIAL_ID -f value -c project_id)
- 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
......@@ -466,10 +482,6 @@ cleanup_knightly:
| awk -v NITK=$NUM_IMAGE_TO_KEEP -v REGEX=gpu-$TIMESTAMP_REGEX
'{if ($0 ~ REGEX) result[count++] = $1}
END {for(i=NITK;i<count;i++) print result[i]}'))
- |
for svr in ${SERVER_TO_BE_DELETE[@]}; do
openstack server delete ${svr}
done
- |
for img in ${OOD_IMAGE_TO_BE_DELETE[@]}; do
openstack image delete ${img}
......
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