Browse code

add some debug to runtime.restore()

Victor Vieux authored on 2013/12/19 03:43:42
Showing 2 changed files
... ...
@@ -56,6 +56,7 @@ func (graph *Graph) restore() error {
56 56
 			graph.idIndex.Add(id)
57 57
 		}
58 58
 	}
59
+	utils.Debugf("Restored %d elements", len(dir))
59 60
 	return nil
60 61
 }
61 62
 
... ...
@@ -189,7 +189,6 @@ func (runtime *Runtime) Register(container *Container) error {
189 189
 			}
190 190
 
191 191
 			container.waitLock = make(chan struct{})
192
-
193 192
 			go container.monitor()
194 193
 		}
195 194
 	}
... ...
@@ -263,9 +262,8 @@ func (runtime *Runtime) Destroy(container *Container) error {
263 263
 }
264 264
 
265 265
 func (runtime *Runtime) restore() error {
266
-	wheel := "-\\|/"
267 266
 	if os.Getenv("DEBUG") == "" && os.Getenv("TEST") == "" {
268
-		fmt.Printf("Loading containers:  ")
267
+		fmt.Printf("Loading containers: ")
269 268
 	}
270 269
 	dir, err := ioutil.ReadDir(runtime.repository)
271 270
 	if err != nil {
... ...
@@ -274,11 +272,11 @@ func (runtime *Runtime) restore() error {
274 274
 	containers := make(map[string]*Container)
275 275
 	currentDriver := runtime.driver.String()
276 276
 
277
-	for i, v := range dir {
277
+	for _, v := range dir {
278 278
 		id := v.Name()
279 279
 		container, err := runtime.load(id)
280
-		if i%21 == 0 && os.Getenv("DEBUG") == "" && os.Getenv("TEST") == "" {
281
-			fmt.Printf("\b%c", wheel[i%4])
280
+		if os.Getenv("DEBUG") == "" && os.Getenv("TEST") == "" {
281
+			fmt.Print(".")
282 282
 		}
283 283
 		if err != nil {
284 284
 			utils.Errorf("Failed to load container %v: %v", id, err)
... ...
@@ -302,6 +300,9 @@ func (runtime *Runtime) restore() error {
302 302
 
303 303
 	if entities := runtime.containerGraph.List("/", -1); entities != nil {
304 304
 		for _, p := range entities.Paths() {
305
+			if os.Getenv("DEBUG") == "" && os.Getenv("TEST") == "" {
306
+				fmt.Print(".")
307
+			}
305 308
 			e := entities[p]
306 309
 			if container, ok := containers[e.ID()]; ok {
307 310
 				register(container)
... ...
@@ -325,7 +326,7 @@ func (runtime *Runtime) restore() error {
325 325
 	}
326 326
 
327 327
 	if os.Getenv("DEBUG") == "" && os.Getenv("TEST") == "" {
328
-		fmt.Printf("\bdone.\n")
328
+		fmt.Printf(": done.\n")
329 329
 	}
330 330
 
331 331
 	return nil
... ...
@@ -676,14 +677,17 @@ func NewRuntimeFromDirectory(config *DaemonConfig) (*Runtime, error) {
676 676
 	}
677 677
 
678 678
 	if ad, ok := driver.(*aufs.Driver); ok {
679
+		utils.Debugf("Migrating existing containers")
679 680
 		if err := ad.Migrate(config.Root, setupInitLayer); err != nil {
680 681
 			return nil, err
681 682
 		}
682 683
 	}
683 684
 
685
+	utils.Debugf("Escaping AppArmor confinement")
684 686
 	if err := linkLxcStart(config.Root); err != nil {
685 687
 		return nil, err
686 688
 	}
689
+	utils.Debugf("Creating images graph")
687 690
 	g, err := NewGraph(path.Join(config.Root, "graph"), driver)
688 691
 	if err != nil {
689 692
 		return nil, err
... ...
@@ -695,10 +699,12 @@ func NewRuntimeFromDirectory(config *DaemonConfig) (*Runtime, error) {
695 695
 	if err != nil {
696 696
 		return nil, err
697 697
 	}
698
+	utils.Debugf("Creating volumes graph")
698 699
 	volumes, err := NewGraph(path.Join(config.Root, "volumes"), volumesDriver)
699 700
 	if err != nil {
700 701
 		return nil, err
701 702
 	}
703
+	utils.Debugf("Creating repository list")
702 704
 	repositories, err := NewTagStore(path.Join(config.Root, "repositories-"+driver.String()), g)
703 705
 	if err != nil {
704 706
 		return nil, fmt.Errorf("Couldn't create Tag store: %s", err)