csantanapr commented on a change in pull request #3007: Clean orphaned
ifstate.veth* files on Ubuntu 14.04
URL:
https://github.com/apache/incubator-openwhisk/pull/3007#discussion_r153210835
##########
File path: ansible/roles/invoker/tasks/clean.yml
##########
@@ -38,3 +38,14 @@
path: "{{ whisk_logs_dir }}/invoker{{
groups['invokers'].index(inventory_hostname) }}"
state: absent
become: "{{ logs.dir.become }}"
+
+# Workaround for orphaned ifstate.veth* files on Ubuntu 14.04
+# See https://github.com/moby/moby/issues/22513
+# Remove inactive files older than 60 minutes
+- name: "Clean orphaned ifstate.veth* files on Ubuntu 14.04"
+ shell: |
+ 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\.({})')
+ find /run/network -regextype posix-egrep \( -not -regex
${ACTIVE_IFACES_REGEXP} \) -and -name 'ifstate.veth*' -and -mmin +60 -delete
Review comment:
This shell errors if it doesn't find any files to delete.
Like this:
```
TASK [invoker : Clean orphaned ifstate.veth* files on Ubuntu 14.04]
************
Monday 27 November 2017 14:13:41 +0000 (0:00:00.223) 0:00:03.673
*******
fatal: [invoker0]: FAILED! => {"changed": true, "cmd":
"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\\.({})')\n find /run/network -regextype
posix-egrep \\( -not -regex ${ACTIVE_IFACES_REGEXP} \\) -and -name
'ifstate.veth*' -and -mmin +60 -delete", "delta": "0:00:00.006411", "end":
"2017-11-27 14:13:42.017347", "failed": true, "rc": 1, "start": "2017-11-27
14:13:42.010936", "stderr": "find: Unmatched ) or \\)", "stderr_lines": ["find:
Unmatched ) or \\)"], "stdout": "", "stdout_lines": []}
...ignoring
[FAILED]
```
Add a check on the variable `ACTIVE_IFACES_REGEXP`
```
shell: |
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\.({})')
if [ -n "$ACTIVE_IFACES_REGEXP" ]; then find /run/network -regextype
posix-egrep \( -not -regex ${ACTIVE_IFACES_REGEXP} \) -and -name
'ifstate.veth*' -and -mmin +60 -delete; fi
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services