Adding check to ensure containerIDs are unique in multi-container mode.

PiperOrigin-RevId: 489073573
This commit is contained in:
Shambhavi Srivastava
2022-11-16 16:49:15 -08:00
committed by gVisor bot
parent 30f74b954c
commit 84548b7893
+5
View File
@@ -303,6 +303,11 @@ func (l *Lifecycle) StartContainer(args *StartContainerArgs, _ *uint32) error {
if l.containerMap == nil {
l.containerMap = make(map[string]*Container)
}
if _, ok := l.containerMap[initArgs.ContainerID]; ok {
return fmt.Errorf("container id: %v already exists", initArgs.ContainerID)
}
l.containerMap[initArgs.ContainerID] = c
l.mu.Unlock()