Skip to content

env lost when call createcontainers for different pod with the same image for a high concurrency #5023

@yadzhang

Description

@yadzhang

Env lost when call createcontainers for different pod with the same image by high concurrency

Description

Steps to reproduce the issue:

  1. Create mutiple pods with the same image but different envs in container spec on the one node at the same time for high concurrency
  2. (Maybe it is hard to reproduce, but if the scale of the cluster is too big, the probability of appearance is considerable)

Describe the results you received:
The first few envs of the previous container is overlapped by the next container env of the other pods with some probability if the two container has the same image and created at the very near same time for a high concurrency.

Describe the results you expected:
The different container from the relative pods has the different env.

Output of containerd --version:
containerd 1.4.3

Any other relevant information:
container_create_linux.go#L164
The root cause is append to the same env slice object for different containers

env := imageConfig.Env
for _, e := range config.GetEnvs() {
    env = append(env, e.GetKey()+"="+e.GetValue())
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/criContainer Runtime Interface (CRI)kind/bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions