Browse code

daemon/*.go: fix some Wrap[f]/Warn[f] errors

In particular, these two:
> daemon/daemon_unix.go:1129: Wrapf format %v reads arg #1, but call has 0 args
> daemon/kill.go:111: Warn call has possible formatting directive %s

and a few more.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>

Sebastiaan van Stijn authored on 2018/07/11 22:51:51
Showing 6 changed files
... ...
@@ -538,7 +538,7 @@ func (daemon *Daemon) DaemonLeavesCluster() {
538 538
 		select {
539 539
 		case <-done:
540 540
 		case <-time.After(5 * time.Second):
541
-			logrus.Warnf("timeout while waiting for ingress network removal")
541
+			logrus.Warn("timeout while waiting for ingress network removal")
542 542
 		}
543 543
 	} else {
544 544
 		logrus.Warnf("failed to initiate ingress network removal: %v", err)
... ...
@@ -646,13 +646,13 @@ func (daemon *Daemon) initRuntimes(runtimes map[string]types.Runtime) (err error
646 646
 	os.RemoveAll(runtimeDir + "-old")
647 647
 	tmpDir, err := ioutils.TempDir(daemon.configStore.Root, "gen-runtimes")
648 648
 	if err != nil {
649
-		return errors.Wrapf(err, "failed to get temp dir to generate runtime scripts")
649
+		return errors.Wrap(err, "failed to get temp dir to generate runtime scripts")
650 650
 	}
651 651
 	defer func() {
652 652
 		if err != nil {
653 653
 			if err1 := os.RemoveAll(tmpDir); err1 != nil {
654 654
 				logrus.WithError(err1).WithField("dir", tmpDir).
655
-					Warnf("failed to remove tmp dir")
655
+					Warn("failed to remove tmp dir")
656 656
 			}
657 657
 			return
658 658
 		}
... ...
@@ -661,12 +661,12 @@ func (daemon *Daemon) initRuntimes(runtimes map[string]types.Runtime) (err error
661 661
 			return
662 662
 		}
663 663
 		if err = os.Rename(tmpDir, runtimeDir); err != nil {
664
-			err = errors.Wrapf(err, "failed to setup runtimes dir, new containers may not start")
664
+			err = errors.Wrap(err, "failed to setup runtimes dir, new containers may not start")
665 665
 			return
666 666
 		}
667 667
 		if err = os.RemoveAll(runtimeDir + "-old"); err != nil {
668 668
 			logrus.WithError(err).WithField("dir", tmpDir).
669
-				Warnf("failed to remove old runtimes dir")
669
+				Warn("failed to remove old runtimes dir")
670 670
 		}
671 671
 	}()
672 672
 
... ...
@@ -1126,7 +1126,7 @@ func setupRemappedRoot(config *config.Config) (*idtools.IDMappings, error) {
1126 1126
 
1127 1127
 		mappings, err := idtools.NewIDMappings(username, groupname)
1128 1128
 		if err != nil {
1129
-			return nil, errors.Wrapf(err, "Can't create ID mappings: %v")
1129
+			return nil, errors.Wrap(err, "Can't create ID mappings")
1130 1130
 		}
1131 1131
 		return mappings, nil
1132 1132
 	}
... ...
@@ -108,7 +108,7 @@ func (daemon *Daemon) killWithSignal(container *containerpkg.Container, sig int)
108 108
 	if unpause {
109 109
 		// above kill signal will be sent once resume is finished
110 110
 		if err := daemon.containerd.Resume(context.Background(), container.ID); err != nil {
111
-			logrus.Warn("Cannot unpause container %s: %s", container.ID, err)
111
+			logrus.Warnf("Cannot unpause container %s: %s", container.ID, err)
112 112
 		}
113 113
 	}
114 114
 
... ...
@@ -138,7 +138,7 @@ func (daemon *Daemon) ProcessEvent(id string, e libcontainerd.EventType, ei libc
138 138
 				"container": c.ID,
139 139
 				"exec-id":   ei.ProcessID,
140 140
 				"exec-pid":  ei.Pid,
141
-			}).Warnf("Ignoring Exit Event, no such exec command found")
141
+			}).Warn("Ignoring Exit Event, no such exec command found")
142 142
 		}
143 143
 	case libcontainerd.EventStart:
144 144
 		c.Lock()
... ...
@@ -186,7 +186,7 @@ func (daemon *Daemon) reloadClusterDiscovery(conf *config.Config, attributes map
186 186
 	}
187 187
 	netOptions, err := daemon.networkOptions(daemon.configStore, daemon.PluginStore, nil)
188 188
 	if err != nil {
189
-		logrus.WithError(err).Warnf("failed to get options with network controller")
189
+		logrus.WithError(err).Warn("failed to get options with network controller")
190 190
 		return nil
191 191
 	}
192 192
 	err = daemon.netController.ReloadConfiguration(netOptions...)
... ...
@@ -37,7 +37,7 @@ func (daemon *Daemon) containerUnpause(container *container.Container) error {
37 37
 	daemon.LogContainerEvent(container, "unpause")
38 38
 
39 39
 	if err := container.CheckpointTo(daemon.containersReplica); err != nil {
40
-		logrus.WithError(err).Warnf("could not save container to disk")
40
+		logrus.WithError(err).Warn("could not save container to disk")
41 41
 	}
42 42
 
43 43
 	return nil