Browse Source

adds tools/cleanup-containers regex support

- this change extends the tools/cleanup-containers script to
  support a grep extended regex as a first paramater.
- if tools/cleanup-containers is called with a grep extended
  regex string as a first paramater, only containers mataching
  that regex will be cleaned up.
- e.g. tools/cleanup-containers "neutron|openvswitch"
  will cleanup all container whoes name contains either neutron
  or openvswitch.

Change-Id: Iadb68c0a8de40e9ec2c0a27568e3a372ec0e8303
Closes-Bug: #1522168
tags/2.0.0.0b1
Sean Mooney 3 years ago
parent
commit
2ffb35ee53
1 changed files with 24 additions and 20 deletions
  1. 24
    20
      tools/cleanup-containers

+ 24
- 20
tools/cleanup-containers View File

@@ -6,26 +6,30 @@ if [[ $(pgrep qemu) ]]; then
6 6
     exit 1
7 7
 fi
8 8
 
9
-containers_to_kill=(
10
-    glance_{api,registry,data} \
11
-    haproxy \
12
-    heat_{api{,_cfn},engine} \
13
-    horizon \
14
-    keepalived
15
-    keystone \
16
-    kolla_ansible \
17
-    log_data \
18
-    magnum_{api,conductor} \
19
-    mariadb{,_data} \
20
-    murano_{api,engine} \
21
-    neutron_{server,agents,linuxbridge_agent,openvswitch_agent} \
22
-    nova_{data,scheduler,novncproxy,consoleauth,conductor,api,compute,libvirt} \
23
-    openvswitch_{vswitchd,db,data} \
24
-    rabbitmq{,_data} \
25
-    rsyslog \
26
-    swift_{account_{auditor,reaper,replicator,server},container_{auditor,expirer,replicator,server,updater},proxy_server,rsyncd} \
27
-    memcached
28
-)
9
+if [ -n "$1" ]; then
10
+    containers_to_kill=($(docker ps | grep -E "$1" | awk '{print $1}'))
11
+else
12
+    containers_to_kill=(
13
+        glance_{api,registry,data} \
14
+        haproxy \
15
+        heat_{api{,_cfn},engine} \
16
+        horizon \
17
+        keepalived
18
+        keystone \
19
+        kolla_ansible \
20
+        log_data \
21
+        magnum_{api,conductor} \
22
+        mariadb{,_data} \
23
+        murano_{api,engine} \
24
+        neutron_{server,agents,linuxbridge_agent,openvswitch_agent} \
25
+        nova_{data,scheduler,novncproxy,consoleauth,conductor,api,compute,libvirt} \
26
+        openvswitch_{vswitchd,db,data} \
27
+        rabbitmq{,_data} \
28
+        rsyslog \
29
+        swift_{account_{auditor,reaper,replicator,server},container_{auditor,expirer,replicator,server,updater},proxy_server,rsyncd} \
30
+        memcached
31
+    )
32
+fi
29 33
 
30 34
 echo "Stopping containers..."
31 35
 (docker stop -t 2 ${containers_to_kill[@]} 2>&1) > /dev/null

Loading…
Cancel
Save