Skip to content

CNI bridge plugin broken on containerd restart for existing containers #3355

Closed

Description

@apostasie

Description

This is a breakout of #3352

nerdctl rm -f foo
nerdctl run --net bridge -d --name foo debian sleep Inf
systemctl --user stop containerd
systemctl --user start containerd
nerdctl start foo
failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: error during container init: error running hook #0: error running hook: exit status 1, stdout: , stderr: time="2024-08-23T14:07:01-07:00" level=fatal msg="failed to call cni.Setup: plugin type=\"bridge\" failed (add): failed to allocate for range 0: 10.4.0.237 has been allocated to default-0b6b3a64bf4039828fc9443354f39009befe0240c6d0d458cefe3685ac1996e8, duplicate allocation is not allowed": unknown

The bridge plugin refuses to allocate an ip to this container id, since there is already one allocated...

I do believe the plugin should INSTEAD return the existing already allocated ip, but I am out of my depth here, and would welcome opinion from people more savvy with CNI networking.

Steps to reproduce the issue

na

Describe the results you received and expected

na

What version of nerdctl are you using?

main

Are you using a variant of nerdctl? (e.g., Rancher Desktop)

None

Host information

No response

Activity

  1. apostasie commented on Aug 23, 2024

    @apostasie
    ContributorAuthor

    Furthemore, after the above reproducer, trying to start a new unrelated container the cni plugin will error again:

    nerdctl run -d --name bar debian sleep Inf
    FATA[0000] failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: error during container init: error running hook #0: error running hook: exit status 1, stdout: , stderr: time="2024-08-23T14:21:35-07:00" level=fatal msg="failed to call cni.Setup: plugin type=\"bridge\" failed (add): failed to set bridge addr: could not set bridge's mac: invalid argument": unknown
    
  2. apostasie commented on Aug 24, 2024

    @apostasie
    ContributorAuthor

    Finally, at the third try, it will succeed, although at that point, the namestore is all messed-up, as postStop has been called on (still) existing containers.

    There is likely two problems:

    • the bridge refusing to return the allocated IP (described in the original post here)
    • the other error runc create failed: unable to start container process: error during container init: error running hook #0: error running hook: exit status 1, stdout: , stderr: time="2024-08-23T14:21:35-07:00" level=fatal msg="failed to call cni.Setup: plugin type=\"bridge\" failed (add): failed to set bridge addr: could not set bridge's mac: invalid argument - which suggests something wrong is being sent down to runc / cni plugin
  3. apostasie commented on Aug 24, 2024

    @apostasie
    ContributorAuthor

    This is confirmed on a clean environment built from lima with containerd v2 + nerdctl v2.

  4. Nnarol commented on Nov 1, 2024

    @Nnarol

    I'm still having the issue matching the second description in this thread ("could not set bridge's mac: invalid argument") interspersed with the "allocation for IP range" variant (Issue 665, also believed to be fixed), in version 1.7.7, which is from September 10, while the fix is from August 24.
    These kind of issues are interspersed seemingly randomly, and a different number of tries for each container makes them go away.

    IP range allocation issue example:

    failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: error during container init: error running hook #0: error running hook: exit status 1, stdout: , stderr: time="2024-11-01T13:08:49+01:00" level=fatal msg="failed to call cni.Setup: plugin type=\"bridge\" failed (add): failed to allocate for range 0: 10.4.0.4 has been allocated to default-c738c11ae1a2eda42530ede520e6fe4d954a6113fd5b8574803f5140be906dde, duplicate allocation is not allowed"
    Failed to write to log, write /home/name/.local/share/nerdctl/1935db59/containers/default/c738c11ae1a2eda42530ede520e6fe4d954a6113fd5b8574803f5140be906dde/oci-hook.createRuntime.log: file already closed: unknown
    

    Invalid argument example:

    failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: error during container init: error running hook #0: error running hook: exit status 1, stdout: , stderr: time="2024-11-01T13:13:45+01:00" level=fatal msg="failed to call cni.Setup: plugin type=\"bridge\" failed (add): failed to set bridge addr: could not set bridge's mac: invalid argument"
    Failed to write to log, write /home/name/.local/share/nerdctl/1935db59/containers/default/c738c11ae1a2eda42530ede520e6fe4d954a6113fd5b8574803f5140be906dde/oci-hook.createRuntime.log: file already closed: unknown
    

    EDIT:

    nerdctl package info:

    Name : nerdctl
    Version : 1.7.7-1
    Description : Docker-compatible CLI for containerd
    Architecture : x86_64
    URL : https://github.com/containerd/nerdctl
    Licenses : Apache
    Groups : None
    Provides : None
    Depends On : containerd
    Optional Deps : buildkit: to build OCI images [installed]
    cni-plugins: to run OCI images [installed]
    rootlesskit: for rootless mode [installed]
    slirp4netns: for rootless mode [installed]
    Required By : None
    Optional For : None
    Conflicts With : None
    Replaces : None
    Installed Size : 34,13 MiB
    Packager : Caleb Maclennan [email protected]
    Build Date : Di 10 Sep 2024 16:05:40
    Install Date : Do 31 Okt 2024 23:08:54
    Install Reason : Explicitly installed
    Install Script : No
    Validated By : Signature

    cni-plugins package info:

    Name : nerdctl
    Version : 1.7.7-1
    Description : Docker-compatible CLI for containerd
    Architecture : x86_64
    URL : https://github.com/containerd/nerdctl
    Licenses : Apache
    Groups : None
    Provides : None
    Depends On : containerd
    Optional Deps : buildkit: to build OCI images [installed]
    cni-plugins: to run OCI images [installed]
    rootlesskit: for rootless mode [installed]
    slirp4netns: for rootless mode [installed]
    Required By : None
    Optional For : None
    Conflicts With : None
    Replaces : None
    Installed Size : 34,13 MiB
    Packager : Caleb Maclennan [email protected]
    Build Date : Di 10 Sep 2024 16:05:40
    Install Date : Do 31 Okt 2024 23:08:54
    Install Reason : Explicitly installed
    Install Script : No
    Validated By : Signature

    Platform:

    Linux name-pc 6.10.13-3-MANJARO #1 SMP PREEMPT_DYNAMIC Tue Oct 8 03:24:49 UTC 2024 x86_64 GNU/Linux

  5. AkihiroSuda commented on Nov 1, 2024

    @AkihiroSuda
    Member

    which is from September 10, while the fix is from August 24.

    You can't just compare the date, as the Aug 24 fix is targeted for v2.0 and not backported to v1.7.

    Does https://github.com/containerd/nerdctl/releases/tag/v2.0.0-rc.3 work for you?

  6. Nnarol commented on Nov 1, 2024

    @Nnarol

    Thank you for the quick help, I'll try!
    Sorry for my failure in tracking the workflow! I wish GitHub showed some branch graphs for branches and merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/unconfirmed-bug-claim

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions