Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Full CNI DHCP plugin support #2925

Open
dtrudg opened this issue May 16, 2024 · 3 comments
Open

Full CNI DHCP plugin support #2925

dtrudg opened this issue May 16, 2024 · 3 comments
Assignees
Labels
maybe Features / changes that maybe implemented in future, depending on need & resources needs investigation

Comments

@dtrudg
Copy link
Member

dtrudg commented May 16, 2024

Version of Singularity

main / 4.1

Describe the bug

If a CNI plugin is run using dhcp IPAM, two portions of the dhcp plugin are in play:

  • The dhcp client plugin is used to setup the container network namespace.
  • The dhcp plugin daemon is run on the host, and will hold / renew reservations for addresses consumed by containers.

The dhcp client plugin will communicate with the daemon, and pass the path to a bound network namespace associated with the container. The daemon requires access to this network namespace.

When setting up CNI networks we currently:

  • Add a bind point from /proc/self/ns/net into the singularity session directory.
  • Call the CNI network setup using the path in the session directory.

There are two problems here:

  • The bind is not actually applied at CNI setup time, leading to an error such as:

    FATAL:   container creation failed: plugin type="macvlan" failed (add): error calling DHCP.Allocate: failed to Statfs "/usr/local/var/singularity/mnt/session/netns": no such file or directory
    
  • The session directory is not accessible to the dhcp daemon on the host, so it cannot access the container's network namespace.

To support the dhcp plugin we must:

  • Bind mount the network namespace to a location that is shared with / accessible from the host - not only inside the per-container session mount namespace.
  • Ensure the bind happens before the dhcp plugin is called, and that the correct path is passed through to the plugin, which will in turn pass it to the dhcp daemon on the host.
@dtrudg dtrudg added the bug Something isn't working label May 16, 2024
@dtrudg dtrudg added this to the SingularityCE 4.2.0 milestone May 16, 2024
@dtrudg dtrudg self-assigned this May 16, 2024
@dtrudg
Copy link
Member Author

dtrudg commented Aug 8, 2024

A full fix for this is complex, requiring invasive changes to the runtime.

As an initial workaround, will add the ability for admins to specify existing network namespaces which a user may join, and a flag for a user to request namespace join rather than creation.

@dtrudg dtrudg changed the title CNI dhcp plugin does not work - netns bind issues Full CNI DHCP plugin support Aug 8, 2024
@dtrudg dtrudg added needs investigation maybe Features / changes that maybe implemented in future, depending on need & resources and removed bug Something isn't working labels Aug 8, 2024
@dtrudg
Copy link
Member Author

dtrudg commented Aug 8, 2024

An alternative workaround may be to pass /proc/<pid>/ns paths to the CNI code that eventually passes them to the DHCP daemon... in the situation that it can be guaranteed that the DHCP CNI daemon and the container are in the same PID namespace.

We have the ability to disable PID namespace creation in singularity.conf, in which case only a user with privilege can run a container in a different PID namespace. This still needs careful thought for security concerns.. i.e. is PID reuse a possible issue here?

@dtrudg dtrudg removed this from the SingularityCE 4.2.0 milestone Aug 12, 2024
@dtrudg
Copy link
Member Author

dtrudg commented Aug 12, 2024

For CE 4.2 we're going for the workaround in #3189 - so a netns with CNI DHCP can be setup separately, and then joined.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
maybe Features / changes that maybe implemented in future, depending on need & resources needs investigation
Projects
None yet
Development

No branches or pull requests

1 participant