diff --git a/runsc/boot/loader.go b/runsc/boot/loader.go index 76ee3c5b0..89757e592 100644 --- a/runsc/boot/loader.go +++ b/runsc/boot/loader.go @@ -237,7 +237,7 @@ type Loader struct { // containerSpecs stores container specs for each container in sandbox. // - // Mapping: cid -> spec. + // Mapping: name -> spec. // +checklocks:mu containerSpecs map[string]*specs.Spec @@ -1920,14 +1920,14 @@ func (l *Loader) registerContainerLocked(spec *specs.Spec, cid string) string { } l.containerIDs[containerName] = cid - l.containerSpecs[cid] = spec + l.containerSpecs[containerName] = spec return containerName } -func (l *Loader) getContainerSpec(cid string) *specs.Spec { +func (l *Loader) getContainerSpec(containerName string) *specs.Spec { l.mu.Lock() defer l.mu.Unlock() - return l.containerSpecs[cid] + return l.containerSpecs[containerName] } func (l *Loader) containerRuntimeState(cid string) ContainerRuntimeState { diff --git a/runsc/boot/restore.go b/runsc/boot/restore.go index e8af1d2d4..9389a1d59 100644 --- a/runsc/boot/restore.go +++ b/runsc/boot/restore.go @@ -139,8 +139,10 @@ func createNetworkStackForRestore(l *Loader) (*stack.Stack, inet.Stack) { // Validate OCI specs before restoring the containers. func validateSpecs(oldSpecs, newSpecs map[string]*specs.Spec) error { - if len(oldSpecs) != len(newSpecs) { - return fmt.Errorf("incorrect number of specs during checkpoint and restore") + for name := range newSpecs { + if _, ok := oldSpecs[name]; !ok { + return fmt.Errorf("checkpoint image does not contain spec for container: %q", name) + } } return nil }