Skip to content

Commit 3d92ec2

Browse files
sven-lange-lastcsantanapr
authored andcommitted
Don't fail if no Docker containers running (#3074)
The initial version failed if no Docker containers were running because an invalid regular expression was constructed for `find` command. With this change, the regular expression for filtering active virtual ethernet interfaces is only included active interfaces can be found. If Docker containers are running, there are always active interfaces. If no Docker containers are running, there may be no actives interfaces.
1 parent 497567b commit 3d92ec2

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

ansible/roles/invoker/tasks/clean.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@
4444
# Remove inactive files older than 60 minutes
4545
- name: "Clean orphaned ifstate.veth* files on Ubuntu 14.04"
4646
shell: |
47-
ACTIVE_IFACES_REGEXP=$(ip -oneline link show | grep --only-matching --extended-regexp 'veth[0-9a-f]+' | tr '\n' '|' | sed -e 's/.$//' | xargs -I '{}' /bin/echo '/run/network/ifstate\.({})')
48-
find /run/network -regextype posix-egrep \( -not -regex ${ACTIVE_IFACES_REGEXP} \) -and -name 'ifstate.veth*' -and -mmin +60 -delete
49-
ignore_errors: True
47+
ACTIVE_VETH_IFACES=$(ip -oneline link show | grep --only-matching --extended-regexp 'veth[0-9a-f]+' | tr '\n' '|' | sed -e 's/.$//')
48+
EXCLUDE_REGEX=$(if [ -z ${ACTIVE_VETH_IFACES} ]; then echo 'No active veth interfaces found' >&2; else printf '( -not -regex /run/network/ifstate\.(%s) ) -and ' ${ACTIVE_VETH_IFACES}; fi)
49+
find /run/network -regextype posix-egrep ${EXCLUDE_REGEX} -name 'ifstate.veth*' -and -mmin +60 -delete
5050
become: True
5151
when: ansible_distribution == 'Ubuntu' and ansible_distribution_version == '14.04'

0 commit comments

Comments
 (0)