Repository: moby/moby
File: daemon/image_store_choice.go (Go)

Code before:
	if driverName == "" {
		driverName = cfgStore.GraphDriver
	}

	if enabled, ok := cfgStore.Features["containerd-snapshotter"]; ok {
		if enabled {
			if out == imageStoreChoiceContainerd {
				log.G(context.TODO()).Warn(`"containerd-snapshotter" is now the default and no longer needed to be set`)
			}
			out = imageStoreChoiceContainerdExplicit
		} else {
			out = imageStoreChoiceGraphdriverExplicit
		}
	}

	if os.Getenv("TEST_INTEGRATION_USE_GRAPHDRIVER") != "" {
		out = imageStoreChoiceGraphdriverExplicit
	}

	if driverName != "" {
		if !out.IsExplicit() {
			switch driverName {
			case "vfs", "overlay2":
				out = imageStoreChoiceGraphdriverExplicit
			case "btrfs":
				// TODO: what to do with btrfs which is both a graphdriver and a snapshotter name?
			}
		}
		if out.IsGraphDriver() {
			if graphdriver.IsRegistered(cfgStore.GraphDriver) {
				return imageStoreChoiceGraphdriverExplicit, nil
			} else {
				return imageStoreChoiceGraphdriverExplicit, fmt.Errorf("graphdriver is explicitly enabled but %q is not registered, %v %v", driverName, cfgStore.Features, os.Getenv("TEST_INTEGRATION_USE_GRAPHDRIVER"))
			}
		}

		if runtime.GOOS == "windows" && !out.IsExplicit() {
			switch driverName {
			case "windows":
				return imageStoreChoiceContainerdExplicit, nil
			case "windowsfilter":
				return imageStoreChoiceGraphdriverExplicit, nil
			}
		}

		// Assume snapshotter is chosen
		return imageStoreChoiceContainerdExplicit, nil
	}

	if out == imageStoreChoiceContainerd {
		if graphdriver.HasPriorDriver(cfgStore.Root) {

Review comment (suggestion):
I would set it to graph driver explicit unless containerd explicit is already set. The btrfs driver is not heavily used in containerd and has no advantage of overlayfs anymore since overlay works fine on btrfs now.

Code after:
	if driverName == "" {
		driverName = cfgStore.GraphDriver
	}

	if enabled, ok := cfgStore.Features["containerd-snapshotter"]; ok {
		if enabled {
			if out == imageStoreChoiceContainerd {
				log.G(context.TODO()).Warn(`"containerd-snapshotter" is now the default and no longer needed to be set`)
			}
			out = imageStoreChoiceContainerdExplicit
		} else {
			out = imageStoreChoiceGraphdriverExplicit
		}
	}

	if os.Getenv("TEST_INTEGRATION_USE_GRAPHDRIVER") != "" {
		out = imageStoreChoiceGraphdriverExplicit
	}

	if driverName != "" {
		if !out.IsExplicit() {
			switch driverName {
			case "vfs", "overlay2":
				out = imageStoreChoiceGraphdriverExplicit
			case "btrfs":
				// The btrfs driver is not heavily used in containerd and has no
				// advantage over overlayfs anymore since overlay works fine.
				// If btrfs is explicitly chosen, the user most likely means graphdrivers.
				out = imageStoreChoiceGraphdriverExplicit
			}
		}
		if out.IsGraphDriver() {
			if graphdriver.IsRegistered(driverName) {
				return imageStoreChoiceGraphdriverExplicit, nil
			} else {
				return imageStoreChoiceGraphdriverExplicit, fmt.Errorf("graphdriver is explicitly enabled but %q is not registered, %v %v", driverName, cfgStore.Features, os.Getenv("TEST_INTEGRATION_USE_GRAPHDRIVER"))
			}
		}

		if runtime.GOOS == "windows" && !out.IsExplicit() {
			switch driverName {
			case "windows":
				return imageStoreChoiceContainerdExplicit, nil
			case "windowsfilter":
				return imageStoreChoiceGraphdriverExplicit, nil
			}
		}

		// Assume snapshotter is chosen
		return imageStoreChoiceContainerdExplicit, nil
	}