Bläddra i källkod

Fixed migrate defect, allow migrate the empty directory

If there is an empty directory exists in the $DOCKER_ROOT/containers ,
that will cause migrate fail. Then docker daemon will initialize failed.
This commit allow skips the empty directory.

Signed-off-by: Andy Zhang <andy.zhangtao@hotmail.com>

Change error messages from uppercase to lowercase

Change error messages from uppercase to lowercase

Signed-off-by: andy <ztao@tibco-support.com>
andy 9 år sedan
förälder
incheckning
098fdb6408
1 ändrade filer med 7 tillägg och 3 borttagningar
  1. 7 3
      migrate/v1/migratev1.go

+ 7 - 3
migrate/v1/migratev1.go

@@ -238,12 +238,14 @@ func migrateContainers(root string, ls graphIDMounter, is image.Store, imageMapp
 
 
 		containerJSON, err := ioutil.ReadFile(filepath.Join(containersDir, id, configFileNameLegacy))
 		containerJSON, err := ioutil.ReadFile(filepath.Join(containersDir, id, configFileNameLegacy))
 		if err != nil {
 		if err != nil {
-			return err
+			logrus.Errorf("migrate container error: %v", err)
+			continue
 		}
 		}
 
 
 		var c map[string]*json.RawMessage
 		var c map[string]*json.RawMessage
 		if err := json.Unmarshal(containerJSON, &c); err != nil {
 		if err := json.Unmarshal(containerJSON, &c); err != nil {
-			return err
+			logrus.Errorf("migrate container error: %v", err)
+			continue
 		}
 		}
 
 
 		imageStrJSON, ok := c["Image"]
 		imageStrJSON, ok := c["Image"]
@@ -253,8 +255,10 @@ func migrateContainers(root string, ls graphIDMounter, is image.Store, imageMapp
 
 
 		var image string
 		var image string
 		if err := json.Unmarshal([]byte(*imageStrJSON), &image); err != nil {
 		if err := json.Unmarshal([]byte(*imageStrJSON), &image); err != nil {
-			return err
+			logrus.Errorf("migrate container error: %v", err)
+			continue
 		}
 		}
+
 		imageID, ok := imageMappings[image]
 		imageID, ok := imageMappings[image]
 		if !ok {
 		if !ok {
 			logrus.Errorf("image not migrated %v", imageID) // non-fatal error
 			logrus.Errorf("image not migrated %v", imageID) // non-fatal error