mirror of
https://github.com/moby/moby.git
synced 2026-01-11 18:51:37 +00:00
Move container platform migration logic
Defer the logic to fill in the container platform information from the image service until container restore. During container restore the image backend is fully initialized and can be used to fill in the missing platform fields for older containers. Signed-off-by: Derek McGowan <derek@mcg.dev>
This commit is contained in:
@@ -79,16 +79,6 @@ func (daemon *Daemon) load(id string) (*container.Container, error) {
|
||||
}
|
||||
selinux.ReserveLabel(ctr.ProcessLabel)
|
||||
|
||||
if ctr.ImagePlatform.Architecture == "" {
|
||||
migration := daemonPlatformReader{
|
||||
imageService: daemon.imageService,
|
||||
}
|
||||
if daemon.containerdClient != nil {
|
||||
migration.content = daemon.containerdClient.ContentStore()
|
||||
}
|
||||
migrateContainerOS(context.TODO(), migration, ctr)
|
||||
}
|
||||
|
||||
if ctr.ID != id {
|
||||
return ctr, fmt.Errorf("Container %s is stored at %s", ctr.ID, id)
|
||||
}
|
||||
|
||||
@@ -327,6 +327,18 @@ func (daemon *Daemon) restore(ctx context.Context, cfg *configStore, containers
|
||||
|
||||
baseLogger := log.G(ctx).WithField("container", c.ID)
|
||||
|
||||
// Fill in missing platform information with platform from image for older containers
|
||||
// Remove this in a future release
|
||||
if c.ImagePlatform.Architecture == "" {
|
||||
migration := daemonPlatformReader{
|
||||
imageService: daemon.imageService,
|
||||
}
|
||||
if daemon.containerdClient != nil {
|
||||
migration.content = daemon.containerdClient.ContentStore()
|
||||
}
|
||||
migrateContainerOS(ctx, migration, c)
|
||||
}
|
||||
|
||||
if c.HostConfig != nil {
|
||||
// Migrate containers that don't have the default ("no") restart-policy set.
|
||||
// The RestartPolicy.Name field may be empty for containers that were
|
||||
|
||||
Reference in New Issue
Block a user