Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
| ... | ... |
@@ -485,10 +485,7 @@ func (s *fsCacheStore) delete(id string) error {
|
| 485 | 485 |
}); err != nil {
|
| 486 | 486 |
return err |
| 487 | 487 |
} |
| 488 |
- if err := s.fs.Remove(src.BackendID); err != nil {
|
|
| 489 |
- return err |
|
| 490 |
- } |
|
| 491 |
- return nil |
|
| 488 |
+ return s.fs.Remove(src.BackendID) |
|
| 492 | 489 |
} |
| 493 | 490 |
|
| 494 | 491 |
type sourceMeta struct {
|
| ... | ... |
@@ -14,9 +14,8 @@ import ( |
| 14 | 14 |
) |
| 15 | 15 |
|
| 16 | 16 |
const ( |
| 17 |
- memdbContainersTable = "containers" |
|
| 18 |
- memdbNamesTable = "names" |
|
| 19 |
- |
|
| 17 |
+ memdbContainersTable = "containers" |
|
| 18 |
+ memdbNamesTable = "names" |
|
| 20 | 19 |
memdbIDIndex = "id" |
| 21 | 20 |
memdbContainerIDIndex = "containerid" |
| 22 | 21 |
) |
| ... | ... |
@@ -191,11 +190,7 @@ func (db *memDB) ReserveName(name, containerID string) error {
|
| 191 | 191 |
} |
| 192 | 192 |
return nil |
| 193 | 193 |
} |
| 194 |
- |
|
| 195 |
- if err := txn.Insert(memdbNamesTable, nameAssociation{name: name, containerID: containerID}); err != nil {
|
|
| 196 |
- return err |
|
| 197 |
- } |
|
| 198 |
- return nil |
|
| 194 |
+ return txn.Insert(memdbNamesTable, nameAssociation{name: name, containerID: containerID})
|
|
| 199 | 195 |
}) |
| 200 | 196 |
} |
| 201 | 197 |
|
| ... | ... |
@@ -262,11 +262,7 @@ func (c *containerAdapter) create(ctx context.Context) error {
|
| 262 | 262 |
return err |
| 263 | 263 |
} |
| 264 | 264 |
|
| 265 |
- if err := c.backend.UpdateContainerServiceConfig(cr.ID, c.container.serviceConfig()); err != nil {
|
|
| 266 |
- return err |
|
| 267 |
- } |
|
| 268 |
- |
|
| 269 |
- return nil |
|
| 265 |
+ return c.backend.UpdateContainerServiceConfig(cr.ID, c.container.serviceConfig()) |
|
| 270 | 266 |
} |
| 271 | 267 |
|
| 272 | 268 |
// checkMounts ensures that the provided mounts won't have any host-specific |
| ... | ... |
@@ -511,11 +511,7 @@ func Validate(config *Config) error {
|
| 511 | 511 |
} |
| 512 | 512 |
|
| 513 | 513 |
// validate platform-specific settings |
| 514 |
- if err := config.ValidatePlatformConfig(); err != nil {
|
|
| 515 |
- return err |
|
| 516 |
- } |
|
| 517 |
- |
|
| 518 |
- return nil |
|
| 514 |
+ return config.ValidatePlatformConfig() |
|
| 519 | 515 |
} |
| 520 | 516 |
|
| 521 | 517 |
// ModifiedDiscoverySettings returns whether the discovery configuration has been modified or not. |
| ... | ... |
@@ -1046,11 +1046,7 @@ func (daemon *Daemon) Shutdown() error {
|
| 1046 | 1046 |
daemon.netController.Stop() |
| 1047 | 1047 |
} |
| 1048 | 1048 |
|
| 1049 |
- if err := daemon.cleanupMounts(); err != nil {
|
|
| 1050 |
- return err |
|
| 1051 |
- } |
|
| 1052 |
- |
|
| 1053 |
- return nil |
|
| 1049 |
+ return daemon.cleanupMounts() |
|
| 1054 | 1050 |
} |
| 1055 | 1051 |
|
| 1056 | 1052 |
// Mount sets container.BaseFS |
| ... | ... |
@@ -1501,10 +1501,7 @@ func (daemon *Daemon) initCgroupsPath(path string) error {
|
| 1501 | 1501 |
if err := maybeCreateCPURealTimeFile(sysinfo.CPURealtimePeriod, daemon.configStore.CPURealtimePeriod, "cpu.rt_period_us", path); err != nil {
|
| 1502 | 1502 |
return err |
| 1503 | 1503 |
} |
| 1504 |
- if err := maybeCreateCPURealTimeFile(sysinfo.CPURealtimeRuntime, daemon.configStore.CPURealtimeRuntime, "cpu.rt_runtime_us", path); err != nil {
|
|
| 1505 |
- return err |
|
| 1506 |
- } |
|
| 1507 |
- return nil |
|
| 1504 |
+ return maybeCreateCPURealTimeFile(sysinfo.CPURealtimeRuntime, daemon.configStore.CPURealtimeRuntime, "cpu.rt_runtime_us", path) |
|
| 1508 | 1505 |
} |
| 1509 | 1506 |
|
| 1510 | 1507 |
func maybeCreateCPURealTimeFile(sysinfoPresent bool, configValue int64, file string, path string) error {
|
| ... | ... |
@@ -579,10 +579,7 @@ func (a *Driver) unmount(mountPath string) error {
|
| 579 | 579 |
if mounted, err := a.mounted(mountPath); err != nil || !mounted {
|
| 580 | 580 |
return err |
| 581 | 581 |
} |
| 582 |
- if err := Unmount(mountPath); err != nil {
|
|
| 583 |
- return err |
|
| 584 |
- } |
|
| 585 |
- return nil |
|
| 582 |
+ return Unmount(mountPath) |
|
| 586 | 583 |
} |
| 587 | 584 |
|
| 588 | 585 |
func (a *Driver) mounted(mountpoint string) (bool, error) {
|
| ... | ... |
@@ -14,8 +14,5 @@ func Unmount(target string) error {
|
| 14 | 14 |
if err := exec.Command("auplink", target, "flush").Run(); err != nil {
|
| 15 | 15 |
logrus.Warnf("Couldn't run auplink before unmount %s: %s", target, err)
|
| 16 | 16 |
} |
| 17 |
- if err := unix.Unmount(target, 0); err != nil {
|
|
| 18 |
- return err |
|
| 19 |
- } |
|
| 20 |
- return nil |
|
| 17 |
+ return unix.Unmount(target, 0) |
|
| 21 | 18 |
} |
| ... | ... |
@@ -598,16 +598,10 @@ func (d *Driver) setStorageSize(dir string, driver *Driver) error {
|
| 598 | 598 |
if d.options.minSpace > 0 && driver.options.size < d.options.minSpace {
|
| 599 | 599 |
return fmt.Errorf("btrfs: storage size cannot be less than %s", units.HumanSize(float64(d.options.minSpace)))
|
| 600 | 600 |
} |
| 601 |
- |
|
| 602 | 601 |
if err := d.subvolEnableQuota(); err != nil {
|
| 603 | 602 |
return err |
| 604 | 603 |
} |
| 605 |
- |
|
| 606 |
- if err := subvolLimitQgroup(dir, driver.options.size); err != nil {
|
|
| 607 |
- return err |
|
| 608 |
- } |
|
| 609 |
- |
|
| 610 |
- return nil |
|
| 604 |
+ return subvolLimitQgroup(dir, driver.options.size) |
|
| 611 | 605 |
} |
| 612 | 606 |
|
| 613 | 607 |
// Remove the filesystem with given id. |
| ... | ... |
@@ -634,10 +628,7 @@ func (d *Driver) Remove(id string) error {
|
| 634 | 634 |
if err := system.EnsureRemoveAll(dir); err != nil {
|
| 635 | 635 |
return err |
| 636 | 636 |
} |
| 637 |
- if err := d.subvolRescanQuota(); err != nil {
|
|
| 638 |
- return err |
|
| 639 |
- } |
|
| 640 |
- return nil |
|
| 637 |
+ return d.subvolRescanQuota() |
|
| 641 | 638 |
} |
| 642 | 639 |
|
| 643 | 640 |
// Get the requested filesystem id. |
| ... | ... |
@@ -273,8 +273,5 @@ func doCopyXattrs(srcPath, dstPath string) error {
|
| 273 | 273 |
// this function is used to copy those. It is set by overlay if a directory |
| 274 | 274 |
// is removed and then re-created and should not inherit anything from the |
| 275 | 275 |
// same dir in the lower dir. |
| 276 |
- if err := copyXattr(srcPath, dstPath, "trusted.overlay.opaque"); err != nil {
|
|
| 277 |
- return err |
|
| 278 |
- } |
|
| 279 |
- return nil |
|
| 276 |
+ return copyXattr(srcPath, dstPath, "trusted.overlay.opaque") |
|
| 280 | 277 |
} |
| ... | ... |
@@ -129,15 +129,10 @@ func verifyBlockDevice(dev string, force bool) error {
|
| 129 | 129 |
if err := checkDevInVG(dev); err != nil {
|
| 130 | 130 |
return err |
| 131 | 131 |
} |
| 132 |
- |
|
| 133 | 132 |
if force {
|
| 134 | 133 |
return nil |
| 135 | 134 |
} |
| 136 |
- |
|
| 137 |
- if err := checkDevHasFS(dev); err != nil {
|
|
| 138 |
- return err |
|
| 139 |
- } |
|
| 140 |
- return nil |
|
| 135 |
+ return checkDevHasFS(dev) |
|
| 141 | 136 |
} |
| 142 | 137 |
|
| 143 | 138 |
func readLVMConfig(root string) (directLVMConfig, error) {
|
| ... | ... |
@@ -355,10 +355,7 @@ func (devices *DeviceSet) saveMetadata(info *devInfo) error {
|
| 355 | 355 |
if err != nil {
|
| 356 | 356 |
return fmt.Errorf("devmapper: Error encoding metadata to json: %s", err)
|
| 357 | 357 |
} |
| 358 |
- if err := devices.writeMetaFile(jsonData, devices.metadataFile(info)); err != nil {
|
|
| 359 |
- return err |
|
| 360 |
- } |
|
| 361 |
- return nil |
|
| 358 |
+ return devices.writeMetaFile(jsonData, devices.metadataFile(info)) |
|
| 362 | 359 |
} |
| 363 | 360 |
|
| 364 | 361 |
func (devices *DeviceSet) markDeviceIDUsed(deviceID int) {
|
| ... | ... |
@@ -889,11 +886,7 @@ func (devices *DeviceSet) takeSnapshot(hash string, baseInfo *devInfo, size uint |
| 889 | 889 |
defer devicemapper.ResumeDevice(baseInfo.Name()) |
| 890 | 890 |
} |
| 891 | 891 |
|
| 892 |
- if err = devices.createRegisterSnapDevice(hash, baseInfo, size); err != nil {
|
|
| 893 |
- return err |
|
| 894 |
- } |
|
| 895 |
- |
|
| 896 |
- return nil |
|
| 892 |
+ return devices.createRegisterSnapDevice(hash, baseInfo, size) |
|
| 897 | 893 |
} |
| 898 | 894 |
|
| 899 | 895 |
func (devices *DeviceSet) createRegisterSnapDevice(hash string, baseInfo *devInfo, size uint64) error {
|
| ... | ... |
@@ -1233,12 +1226,7 @@ func (devices *DeviceSet) setupBaseImage() error {
|
| 1233 | 1233 |
if err := devices.setupVerifyBaseImageUUIDFS(oldInfo); err != nil {
|
| 1234 | 1234 |
return err |
| 1235 | 1235 |
} |
| 1236 |
- |
|
| 1237 |
- if err := devices.checkGrowBaseDeviceFS(oldInfo); err != nil {
|
|
| 1238 |
- return err |
|
| 1239 |
- } |
|
| 1240 |
- |
|
| 1241 |
- return nil |
|
| 1236 |
+ return devices.checkGrowBaseDeviceFS(oldInfo) |
|
| 1242 | 1237 |
} |
| 1243 | 1238 |
|
| 1244 | 1239 |
logrus.Debug("devmapper: Removing uninitialized base image")
|
| ... | ... |
@@ -1259,11 +1247,7 @@ func (devices *DeviceSet) setupBaseImage() error {
|
| 1259 | 1259 |
} |
| 1260 | 1260 |
|
| 1261 | 1261 |
// Create new base image device |
| 1262 |
- if err := devices.createBaseImage(); err != nil {
|
|
| 1263 |
- return err |
|
| 1264 |
- } |
|
| 1265 |
- |
|
| 1266 |
- return nil |
|
| 1262 |
+ return devices.createBaseImage() |
|
| 1267 | 1263 |
} |
| 1268 | 1264 |
|
| 1269 | 1265 |
func setCloseOnExec(name string) {
|
| ... | ... |
@@ -2082,11 +2066,7 @@ func (devices *DeviceSet) deleteDevice(info *devInfo, syncDelete bool) error {
|
| 2082 | 2082 |
return err |
| 2083 | 2083 |
} |
| 2084 | 2084 |
|
| 2085 |
- if err := devices.deleteTransaction(info, syncDelete); err != nil {
|
|
| 2086 |
- return err |
|
| 2087 |
- } |
|
| 2088 |
- |
|
| 2089 |
- return nil |
|
| 2085 |
+ return devices.deleteTransaction(info, syncDelete) |
|
| 2090 | 2086 |
} |
| 2091 | 2087 |
|
| 2092 | 2088 |
// DeleteDevice will return success if device has been marked for deferred |
| ... | ... |
@@ -146,12 +146,7 @@ func (d *Driver) Create(id, parent string, opts *graphdriver.CreateOpts) error {
|
| 146 | 146 |
if opts != nil {
|
| 147 | 147 |
storageOpt = opts.StorageOpt |
| 148 | 148 |
} |
| 149 |
- |
|
| 150 |
- if err := d.DeviceSet.AddDevice(id, parent, storageOpt); err != nil {
|
|
| 151 |
- return err |
|
| 152 |
- } |
|
| 153 |
- |
|
| 154 |
- return nil |
|
| 149 |
+ return d.DeviceSet.AddDevice(id, parent, storageOpt) |
|
| 155 | 150 |
} |
| 156 | 151 |
|
| 157 | 152 |
// Remove removes a device with a given id, unmounts the filesystem. |
| ... | ... |
@@ -263,11 +263,7 @@ func addLayerFiles(drv graphdriver.Driver, layer, parent string, i int) error {
|
| 263 | 263 |
if err := driver.WriteFile(root, root.Join(layerDir, "layer-id"), []byte(layer), 0755); err != nil {
|
| 264 | 264 |
return err |
| 265 | 265 |
} |
| 266 |
- if err := driver.WriteFile(root, root.Join(layerDir, "parent-id"), []byte(parent), 0755); err != nil {
|
|
| 267 |
- return err |
|
| 268 |
- } |
|
| 269 |
- |
|
| 270 |
- return nil |
|
| 266 |
+ return driver.WriteFile(root, root.Join(layerDir, "parent-id"), []byte(parent), 0755) |
|
| 271 | 267 |
} |
| 272 | 268 |
|
| 273 | 269 |
func addManyLayers(drv graphdriver.Driver, baseLayer string, count int) (string, error) {
|
| ... | ... |
@@ -309,10 +309,7 @@ func (d *Driver) Create(id, parent string, opts *graphdriver.CreateOpts) (retErr |
| 309 | 309 |
if err := idtools.MkdirAndChown(path.Join(dir, "work"), 0700, root); err != nil {
|
| 310 | 310 |
return err |
| 311 | 311 |
} |
| 312 |
- if err := ioutil.WriteFile(path.Join(dir, "lower-id"), []byte(parent), 0666); err != nil {
|
|
| 313 |
- return err |
|
| 314 |
- } |
|
| 315 |
- return nil |
|
| 312 |
+ return ioutil.WriteFile(path.Join(dir, "lower-id"), []byte(parent), 0666) |
|
| 316 | 313 |
} |
| 317 | 314 |
|
| 318 | 315 |
// Otherwise, copy the upper and the lower-id from the parent |
| ... | ... |
@@ -14,12 +14,7 @@ func (daemon *Daemon) ContainerPause(name string) error {
|
| 14 | 14 |
if err != nil {
|
| 15 | 15 |
return err |
| 16 | 16 |
} |
| 17 |
- |
|
| 18 |
- if err := daemon.containerPause(container); err != nil {
|
|
| 19 |
- return err |
|
| 20 |
- } |
|
| 21 |
- |
|
| 22 |
- return nil |
|
| 17 |
+ return daemon.containerPause(container) |
|
| 23 | 18 |
} |
| 24 | 19 |
|
| 25 | 20 |
// containerPause pauses the container execution without stopping the process. |
| ... | ... |
@@ -90,11 +90,7 @@ func (daemon *Daemon) ContainerStart(name string, hostConfig *containertypes.Hos |
| 90 | 90 |
return validationError{err}
|
| 91 | 91 |
} |
| 92 | 92 |
} |
| 93 |
- |
|
| 94 |
- if err := daemon.containerStart(container, checkpoint, checkpointDir, true); err != nil {
|
|
| 95 |
- return err |
|
| 96 |
- } |
|
| 97 |
- return nil |
|
| 93 |
+ return daemon.containerStart(container, checkpoint, checkpointDir, true) |
|
| 98 | 94 |
} |
| 99 | 95 |
|
| 100 | 96 |
// containerStart prepares the container to run by setting up everything the |
| ... | ... |
@@ -14,12 +14,7 @@ func (daemon *Daemon) ContainerUnpause(name string) error {
|
| 14 | 14 |
if err != nil {
|
| 15 | 15 |
return err |
| 16 | 16 |
} |
| 17 |
- |
|
| 18 |
- if err := daemon.containerUnpause(container); err != nil {
|
|
| 19 |
- return err |
|
| 20 |
- } |
|
| 21 |
- |
|
| 22 |
- return nil |
|
| 17 |
+ return daemon.containerUnpause(container) |
|
| 23 | 18 |
} |
| 24 | 19 |
|
| 25 | 20 |
// containerUnpause resumes the container execution after the container is paused. |
| ... | ... |
@@ -133,10 +133,7 @@ func (s *fs) Delete(dgst digest.Digest) error {
|
| 133 | 133 |
if err := os.RemoveAll(s.metadataDir(dgst)); err != nil {
|
| 134 | 134 |
return err |
| 135 | 135 |
} |
| 136 |
- if err := os.Remove(s.contentFile(dgst)); err != nil {
|
|
| 137 |
- return err |
|
| 138 |
- } |
|
| 139 |
- return nil |
|
| 136 |
+ return os.Remove(s.contentFile(dgst)) |
|
| 140 | 137 |
} |
| 141 | 138 |
|
| 142 | 139 |
// SetMetadata sets metadata for a given ID. It fails if there's no base file. |
| ... | ... |
@@ -348,11 +348,7 @@ func (d *Daemon) Kill() error {
|
| 348 | 348 |
return err |
| 349 | 349 |
} |
| 350 | 350 |
|
| 351 |
- if err := os.Remove(fmt.Sprintf("%s/docker.pid", d.Folder)); err != nil {
|
|
| 352 |
- return err |
|
| 353 |
- } |
|
| 354 |
- |
|
| 355 |
- return nil |
|
| 351 |
+ return os.Remove(fmt.Sprintf("%s/docker.pid", d.Folder))
|
|
| 356 | 352 |
} |
| 357 | 353 |
|
| 358 | 354 |
// Pid returns the pid of the daemon |
| ... | ... |
@@ -459,11 +455,7 @@ out2: |
| 459 | 459 |
|
| 460 | 460 |
d.cmd.Wait() |
| 461 | 461 |
|
| 462 |
- if err := os.Remove(fmt.Sprintf("%s/docker.pid", d.Folder)); err != nil {
|
|
| 463 |
- return err |
|
| 464 |
- } |
|
| 465 |
- |
|
| 466 |
- return nil |
|
| 462 |
+ return os.Remove(fmt.Sprintf("%s/docker.pid", d.Folder))
|
|
| 467 | 463 |
} |
| 468 | 464 |
|
| 469 | 465 |
// Restart will restart the daemon by first stopping it and the starting it. |
| ... | ... |
@@ -328,9 +328,8 @@ func createNetwork(c *check.C, config types.NetworkCreateRequest, expectedStatus |
| 328 | 328 |
c.Assert(err, checker.IsNil) |
| 329 | 329 |
|
| 330 | 330 |
return nr.ID |
| 331 |
- } else {
|
|
| 332 |
- return "" |
|
| 333 | 331 |
} |
| 332 |
+ return "" |
|
| 334 | 333 |
} |
| 335 | 334 |
|
| 336 | 335 |
func connectNetwork(c *check.C, nid, cid string) {
|
| ... | ... |
@@ -153,10 +153,7 @@ func (tf *testFile) ApplyFile(root containerfs.ContainerFS) error {
|
| 153 | 153 |
return err |
| 154 | 154 |
} |
| 155 | 155 |
} |
| 156 |
- if err := driver.WriteFile(root, fullPath, tf.content, tf.permission); err != nil {
|
|
| 157 |
- return err |
|
| 158 |
- } |
|
| 159 |
- return nil |
|
| 156 |
+ return driver.WriteFile(root, fullPath, tf.content, tf.permission) |
|
| 160 | 157 |
} |
| 161 | 158 |
|
| 162 | 159 |
func initWithFiles(files ...FileApplier) layerInit {
|
| ... | ... |
@@ -68,11 +68,7 @@ func (ls *layerStore) CreateRWLayerByGraphID(name string, graphID string, parent |
| 68 | 68 |
m.initID = initID |
| 69 | 69 |
} |
| 70 | 70 |
|
| 71 |
- if err = ls.saveMount(m); err != nil {
|
|
| 72 |
- return err |
|
| 73 |
- } |
|
| 74 |
- |
|
| 75 |
- return nil |
|
| 71 |
+ return ls.saveMount(m) |
|
| 76 | 72 |
} |
| 77 | 73 |
|
| 78 | 74 |
func (ls *layerStore) ChecksumForGraphID(id, parent, oldTarDataPath, newTarDataPath string) (diffID DiffID, size int64, err error) {
|
| ... | ... |
@@ -143,11 +143,7 @@ func storeLayer(tx MetadataTransaction, layer *roLayer) error {
|
| 143 | 143 |
return err |
| 144 | 144 |
} |
| 145 | 145 |
} |
| 146 |
- if err := tx.SetOS(layer.os); err != nil {
|
|
| 147 |
- return err |
|
| 148 |
- } |
|
| 149 |
- |
|
| 150 |
- return nil |
|
| 146 |
+ return tx.SetOS(layer.os) |
|
| 151 | 147 |
} |
| 152 | 148 |
|
| 153 | 149 |
func newVerifiedReadCloser(rc io.ReadCloser, dgst digest.Digest) (io.ReadCloser, error) {
|
| ... | ... |
@@ -89,11 +89,7 @@ func Migrate(root, driverName string, ls layer.Store, is image.Store, rs refstor |
| 89 | 89 |
return err |
| 90 | 90 |
} |
| 91 | 91 |
|
| 92 |
- if err := migrateRefs(root, driverName, rs, mappings); err != nil {
|
|
| 93 |
- return err |
|
| 94 |
- } |
|
| 95 |
- |
|
| 96 |
- return nil |
|
| 92 |
+ return migrateRefs(root, driverName, rs, mappings) |
|
| 97 | 93 |
} |
| 98 | 94 |
|
| 99 | 95 |
// CalculateLayerChecksums walks an old graph directory and calculates checksums |
| ... | ... |
@@ -323,10 +323,7 @@ func addContainer(dest, jsonConfig string) error {
|
| 323 | 323 |
if err := os.MkdirAll(contDir, 0700); err != nil {
|
| 324 | 324 |
return err |
| 325 | 325 |
} |
| 326 |
- if err := ioutil.WriteFile(filepath.Join(contDir, "config.json"), []byte(jsonConfig), 0600); err != nil {
|
|
| 327 |
- return err |
|
| 328 |
- } |
|
| 329 |
- return nil |
|
| 326 |
+ return ioutil.WriteFile(filepath.Join(contDir, "config.json"), []byte(jsonConfig), 0600) |
|
| 330 | 327 |
} |
| 331 | 328 |
|
| 332 | 329 |
type mockTagAdder struct {
|
| ... | ... |
@@ -27,9 +27,5 @@ func Chtimes(name string, atime time.Time, mtime time.Time) error {
|
| 27 | 27 |
} |
| 28 | 28 |
|
| 29 | 29 |
// Take platform specific action for setting create time. |
| 30 |
- if err := setCTime(name, mtime); err != nil {
|
|
| 31 |
- return err |
|
| 32 |
- } |
|
| 33 |
- |
|
| 34 |
- return nil |
|
| 30 |
+ return setCTime(name, mtime) |
|
| 35 | 31 |
} |