Browse code

Merge pull request #22423 from mlaventure/rm-containers-if-rm-in-progress-on-restart

Reset RemovalInProgress flag on daemon restart

Sebastiaan van Stijn authored on 2016/05/05 06:57:16
Showing 1 changed files
... ...
@@ -313,6 +313,21 @@ func (daemon *Daemon) restore() error {
313 313
 				mapLock.Unlock()
314 314
 			}
315 315
 
316
+			if c.RemovalInProgress {
317
+				// We probably crashed in the middle of a removal, reset
318
+				// the flag.
319
+				//
320
+				// We DO NOT remove the container here as we do not
321
+				// know if the user had requested for either the
322
+				// associated volumes, network links or both to also
323
+				// be removed. So we put the container in the "dead"
324
+				// state and leave further processing up to them.
325
+				logrus.Debugf("Resetting RemovalInProgress flag from %v", c.ID)
326
+				c.ResetRemovalInProgress()
327
+				c.SetDead()
328
+				c.ToDisk()
329
+			}
330
+
316 331
 			// if c.hostConfig.Links is nil (not just empty), then it is using the old sqlite links and needs to be migrated
317 332
 			if c.HostConfig != nil && c.HostConfig.Links == nil {
318 333
 				migrateLegacyLinks = true