From 3416e9f19466c76a42abfff7e06422a929e3b79b Mon Sep 17 00:00:00 2001 From: Daniel J Walsh Date: Sat, 2 Jun 2018 06:02:34 -0400 Subject: Want to change the log level on buildah by default to warnf Change the level of missing /etc/containers/mount.conf to a debug, since this is expected on most machines. Also raised the level of some warnings to errors, so they will be better seen, even if we are skipping. Fixed the wording of one error, since stating is not the correct word. Signed-off-by: Daniel J Walsh Closes: #882 Approved by: mheon --- pkg/secrets/secrets.go | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/pkg/secrets/secrets.go b/pkg/secrets/secrets.go index 12609c7e3..ba0f3b925 100644 --- a/pkg/secrets/secrets.go +++ b/pkg/secrets/secrets.go @@ -101,13 +101,14 @@ func getHostSecretData(hostDir string) ([]secretData, error) { func getMounts(filePath string) []string { file, err := os.Open(filePath) if err != nil { - logrus.Warnf("file %q not found, skipping...", filePath) + // This is expected on most systems + logrus.Debugf("file %q not found, skipping...", filePath) return nil } defer file.Close() scanner := bufio.NewScanner(file) if err = scanner.Err(); err != nil { - logrus.Warnf("error reading file %q, skipping...", filePath) + logrus.Errorf("error reading file %q, %v skipping...", filePath, err) return nil } var mounts []string @@ -157,12 +158,12 @@ func SecretMountsWithUIDGID(mountLabel, containerWorkingDir, mountFile, mountPre _, err := os.Stat("/etc/system-fips") if err == nil { if err := addFIPSModeSecret(&secretMounts, containerWorkingDir); err != nil { - logrus.Warnf("error adding FIPS mode secret to container: %v", err) + logrus.Errorf("error adding FIPS mode secret to container: %v", err) } } else if os.IsNotExist(err) { logrus.Debug("/etc/system-fips does not exist on host, not mounting FIPS mode secret") } else { - logrus.Errorf("error stating /etc/system-fips for FIPS mode secret: %v", err) + logrus.Errorf("stat /etc/system-fips failed for FIPS mode secret: %v", err) } return secretMounts } @@ -184,9 +185,12 @@ func addSecretsFromMountsFile(filePath, mountLabel, containerWorkingDir, mountPr return nil, err } // skip if the hostDir path doesn't exist - if _, err = os.Stat(hostDir); os.IsNotExist(err) { - logrus.Warnf("%q doesn't exist, skipping", hostDir) - continue + if _, err = os.Stat(hostDir); err != nil { + if os.IsNotExist(err) { + logrus.Warnf("Path %q from %q doesn't exist, skipping", hostDir, filePath) + continue + } + return nil, errors.Wrapf(err, "failed to stat %q", hostDir) } ctrDirOnHost := filepath.Join(containerWorkingDir, ctrDir) @@ -195,7 +199,7 @@ func addSecretsFromMountsFile(filePath, mountLabel, containerWorkingDir, mountPr _, err = os.Stat(ctrDirOnHost) if os.IsNotExist(err) { if err = os.MkdirAll(ctrDirOnHost, 0755); err != nil { - return nil, errors.Wrapf(err, "making container directory failed") + return nil, errors.Wrapf(err, "making container directory %q failed", ctrDirOnHost) } hostDir, err = resolveSymbolicLink(hostDir) if err != nil { -- cgit v1.2.3-54-g00ecf