Skip to content

Commit

Permalink
Merge pull request #45616 from thaJeztah/24.0_backport_lock_in_snapsh…
Browse files Browse the repository at this point in the history
…otter_setting

[24.0 backport] daemon: lock in snapshotter setting at daemon init
  • Loading branch information
thaJeztah committed May 25, 2023
2 parents 9d8acb7 + d64bab3 commit 2472277
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions daemon/daemon.go
Expand Up @@ -129,6 +129,8 @@ type Daemon struct {
// It stores metadata for the content store (used for manifest caching)
// This needs to be closed on daemon exit
mdDB *bbolt.DB

usesSnapshotter bool
}

// ID returns the daemon id
Expand Down Expand Up @@ -158,16 +160,7 @@ func (daemon *Daemon) Features() *map[string]bool {

// UsesSnapshotter returns true if feature flag to use containerd snapshotter is enabled
func (daemon *Daemon) UsesSnapshotter() bool {
// TEST_INTEGRATION_USE_SNAPSHOTTER is used for integration tests only.
if os.Getenv("TEST_INTEGRATION_USE_SNAPSHOTTER") != "" {
return true
}
if daemon.configStore.Features != nil {
if b, ok := daemon.configStore.Features["containerd-snapshotter"]; ok {
return b
}
}
return false
return daemon.usesSnapshotter
}

// RegistryHosts returns registry configuration in containerd resolvers format
Expand Down Expand Up @@ -801,6 +794,13 @@ func NewDaemon(ctx context.Context, config *config.Config, pluginStore *plugin.S
startupDone: make(chan struct{}),
}

// TEST_INTEGRATION_USE_SNAPSHOTTER is used for integration tests only.
if os.Getenv("TEST_INTEGRATION_USE_SNAPSHOTTER") != "" {
d.usesSnapshotter = true
} else {
d.usesSnapshotter = config.Features["containerd-snapshotter"]
}

// Ensure the daemon is properly shutdown if there is a failure during
// initialization
defer func() {
Expand Down

0 comments on commit 2472277

Please sign in to comment.