aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGiuseppe Scrivano <gscrivan@redhat.com>2022-08-08 14:29:13 +0200
committerMatthew Heon <mheon@redhat.com>2022-08-10 16:46:05 -0400
commita3778b05123e061d787ba1b36ef4e077e852c91a (patch)
treefa8c6c4c956b28f98621dc8e4cd41acd82c08417
parentfa1085ed01e2b901bfd3963ea4e1952a9d27a694 (diff)
downloadpodman-a3778b05123e061d787ba1b36ef4e077e852c91a.tar.gz
podman-a3778b05123e061d787ba1b36ef4e077e852c91a.tar.bz2
podman-a3778b05123e061d787ba1b36ef4e077e852c91a.zip
specgen: use sandbox id instead of name for annotation
use the sandbox id instead of the name for the io.kubernetes.cri-o.SandboxID annotation used by gVisor. Closes: https://github.com/containers/podman/issues/15223 [NO NEW TESTS NEEDED] it is specific to gVisor Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
-rw-r--r--pkg/specgen/generate/container.go18
1 files changed, 13 insertions, 5 deletions
diff --git a/pkg/specgen/generate/container.go b/pkg/specgen/generate/container.go
index 2248c9235..b6701b1ce 100644
--- a/pkg/specgen/generate/container.go
+++ b/pkg/specgen/generate/container.go
@@ -191,16 +191,24 @@ func CompleteSpec(ctx context.Context, r *libpod.Runtime, s *specgen.SpecGenerat
// - "container" denotes the container should join the VM of the SandboxID
// (the infra container)
if len(s.Pod) > 0 {
- annotations[ann.SandboxID] = s.Pod
+ p, err := r.LookupPod(s.Pod)
+ if err != nil {
+ return nil, err
+ }
+ sandboxID := p.ID()
+ if p.HasInfraContainer() {
+ infra, err := p.InfraContainer()
+ if err != nil {
+ return nil, err
+ }
+ sandboxID = infra.ID()
+ }
+ annotations[ann.SandboxID] = sandboxID
annotations[ann.ContainerType] = ann.ContainerTypeContainer
// Check if this is an init-ctr and if so, check if
// the pod is running. we do not want to add init-ctrs to
// a running pod because it creates confusion for us.
if len(s.InitContainerType) > 0 {
- p, err := r.LookupPod(s.Pod)
- if err != nil {
- return nil, err
- }
containerStatuses, err := p.Status()
if err != nil {
return nil, err