From: Tom Clegg Date: Wed, 13 Feb 2019 16:11:03 +0000 (-0500) Subject: 14807: Fix crunch-run --list output when /var/lock is a symlink. X-Git-Tag: 1.4.0~142^2~20 X-Git-Url: https://git.arvados.org/arvados.git/commitdiff_plain/de9a5e2703cca69b0ba6e8e3e6102ee267b7447e 14807: Fix crunch-run --list output when /var/lock is a symlink. filepath.Walk(/var/lock) does not return entries inside /var/lock if /var/lock is a symlink, as it is on debian:9. Arvados-DCO-1.1-Signed-off-by: Tom Clegg --- diff --git a/services/crunch-run/background.go b/services/crunch-run/background.go index a508538370..0d4612908c 100644 --- a/services/crunch-run/background.go +++ b/services/crunch-run/background.go @@ -155,8 +155,11 @@ func kill(uuid string, signal syscall.Signal, stdout, stderr io.Writer) error { // List UUIDs of active crunch-run processes. func ListProcesses(stdout, stderr io.Writer) int { - return exitcode(stderr, filepath.Walk(lockdir, func(path string, info os.FileInfo, err error) error { - if info.IsDir() { + // filepath.Walk does not follow symlinks, so we must walk + // lockdir+"/." in case lockdir itself is a symlink. + walkdir := lockdir + "/." + return exitcode(stderr, filepath.Walk(walkdir, func(path string, info os.FileInfo, err error) error { + if info.IsDir() && path != walkdir { return filepath.SkipDir } if name := info.Name(); !strings.HasPrefix(name, lockprefix) || !strings.HasSuffix(name, locksuffix) {