From 647092b483c928cff152757c2bb56da8b2cbb0e0 Mon Sep 17 00:00:00 2001 From: Kay Yan Date: Sat, 22 Jun 2024 01:30:55 +0800 Subject: [PATCH] fix openstack cleanup (#11299) Signed-off-by: Kay Yan --- .gitlab-ci.yml | 2 +- scripts/openstack-cleanup/main.py | 11 +++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 7020d3eb3..b838c6fc2 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -71,7 +71,7 @@ ci-not-authorized: after_script: [] rules: # LGTM or ok-to-test labels - - if: $PR_LABELS =~ /.*,(lgtm|ok-to-test).*|^(lgtm|ok-to-test).*/i + - if: $PR_LABELS =~ /.*,(lgtm|approved|ok-to-test).*|^(lgtm|approved|ok-to-test).*/i variables: CI_OK_TO_TEST: '0' when: always diff --git a/scripts/openstack-cleanup/main.py b/scripts/openstack-cleanup/main.py index ba3d4586e..28820de02 100755 --- a/scripts/openstack-cleanup/main.py +++ b/scripts/openstack-cleanup/main.py @@ -38,8 +38,15 @@ def main(): conn.compute.servers()) print('Security groups...') - map_if_old(conn.network.delete_security_group, - conn.network.security_groups()) + try: + map_if_old(conn.network.delete_security_group, + conn.network.security_groups()) + except openstack.exceptions.ConflictException as ex: + # Need to delete port when security groups is in used + map_if_old(conn.network.delete_port, + conn.network.ports()) + map_if_old(conn.network.delete_security_group, + conn.network.security_groups()) print('Ports...') try: