@@ -64,6 +64,7 @@ import (
6464 "github.com/containerd/containerd/v2/plugins"
6565 "github.com/containerd/containerd/v2/plugins/content/local"
6666 "github.com/containerd/containerd/v2/plugins/services/warning"
67+ "github.com/containerd/containerd/v2/version"
6768 "github.com/containerd/platforms"
6869 "github.com/containerd/plugin"
6970 "github.com/containerd/plugin/dynamic"
@@ -112,10 +113,10 @@ func CreateTopLevelDirectories(config *srvconfig.Config) error {
112113// New creates and initializes a new containerd server
113114func New (ctx context.Context , config * srvconfig.Config ) (* Server , error ) {
114115 var (
115- version = config .Version
116- migrationT time.Duration
116+ currentVersion = config .Version
117+ migrationT time.Duration
117118 )
118- if version < srvconfig . CurrentConfigVersion {
119+ if currentVersion < version . ConfigVersion {
119120 // Migrate config to latest version
120121 t1 := time .Now ()
121122 err := config .MigrateConfig (ctx )
@@ -224,12 +225,12 @@ func New(ctx context.Context, config *srvconfig.Config) (*Server, error) {
224225 required [r ] = struct {}{}
225226 }
226227
227- if version < srvconfig . CurrentConfigVersion {
228+ if currentVersion < version . ConfigVersion {
228229 t1 := time .Now ()
229230 // Run migration for each configuration version
230231 // Run each plugin migration for each version to ensure that migration logic is simple and
231232 // focused on upgrading from one version at a time.
232- for v := version ; v < srvconfig . CurrentConfigVersion ; v ++ {
233+ for v := currentVersion ; v < version . ConfigVersion ; v ++ {
233234 for _ , p := range loaded {
234235 if p .ConfigMigration != nil {
235236 if err := p .ConfigMigration (ctx , v , config .Plugins ); err != nil {
@@ -241,7 +242,7 @@ func New(ctx context.Context, config *srvconfig.Config) (*Server, error) {
241242 migrationT = migrationT + time .Since (t1 )
242243 }
243244 if migrationT > 0 {
244- log .G (ctx ).WithField ("t" , migrationT ).Warnf ("Configuration migrated from version %d, use `containerd config migrate` to avoid migration" , version )
245+ log .G (ctx ).WithField ("t" , migrationT ).Warnf ("Configuration migrated from version %d, use `containerd config migrate` to avoid migration" , currentVersion )
245246 }
246247
247248 for _ , p := range loaded {
0 commit comments