From 2b50b14aebc12722f81db8d8f66415e1fa7b954a Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Tue, 26 Sep 2017 11:45:54 +0200 Subject: [PATCH] Suppress warning for renaming missing tmp directory When starting `dockerd` on a host that has no `/var/lib/docker/tmp` directory, a warning was printed in the logs: $ dockerd --data-root=/no-such-directory ... WARN[2017-09-26T09:37:00.045153377Z] failed to rename /no-such-directory/tmp for background deletion: rename /no-such-directory/tmp /no-such-directory/tmp-old: no such file or directory. Deleting synchronously Although harmless, the warning does not show any useful information, so can be skipped. This patch checks thetype of error, so that warning is not printed. Other errors will still show up: $ touch /i-am-a-file $ dockerd --data-root=/i-am-a-file Unable to get the full path to root (/i-am-a-file): canonical path points to a file '/i-am-a-file' Signed-off-by: Sebastiaan van Stijn --- daemon/daemon.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/daemon/daemon.go b/daemon/daemon.go index 19d22bf702..c187f29ceb 100644 --- a/daemon/daemon.go +++ b/daemon/daemon.go @@ -1044,7 +1044,7 @@ func prepareTempDir(rootDir string, rootIDs idtools.IDPair) (string, error) { logrus.Warnf("failed to delete old tmp directory: %s", newName) } }() - } else { + } else if !os.IsNotExist(err) { logrus.Warnf("failed to rename %s for background deletion: %s. Deleting synchronously", tmpDir, err) if err := os.RemoveAll(tmpDir); err != nil { logrus.Warnf("failed to delete old tmp directory: %s", tmpDir)