diff --git a/server/sandbox_run.go b/server/sandbox_run.go index 4b832843..23e8b7e4 100644 --- a/server/sandbox_run.go +++ b/server/sandbox_run.go @@ -221,10 +221,13 @@ func (s *Server) RunPodSandbox(ctx context.Context, req *pb.RunPodSandboxRequest labels := req.GetConfig().GetLabels() // Add special container name label for the infra container - labels[types.KubernetesContainerNameLabel] = leaky.PodInfraContainerName - labelsJSON, err := json.Marshal(labels) - if err != nil { - return nil, err + labelsJSON := []byte{} + if labels != nil { + labels[types.KubernetesContainerNameLabel] = leaky.PodInfraContainerName + labelsJSON, err = json.Marshal(labels) + if err != nil { + return nil, err + } } // add annotations