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

Some deployed cni plugins are not statically compiled #2095

Closed
nitrotm opened this issue Apr 15, 2021 · 6 comments · Fixed by #2189
Closed

Some deployed cni plugins are not statically compiled #2095

nitrotm opened this issue Apr 15, 2021 · 6 comments · Fixed by #2189
Assignees
Labels
area/build-release Issues or PRs related to building and releasing kind/bug Categorizes issue or PR as related to a bug. lifecycle/active Indicates that an issue or PR is actively being worked on by a contributor. priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release.

Comments

@nitrotm
Copy link

nitrotm commented Apr 15, 2021

Describe the bug
On an alpine-based native server (which is itself based on busybox), /opt/cni/bin/antrea cannot execute due to being dynamically linked to some system libraries. This is not the case for some other standard plugins, such as loopback.

To Reproduce
Try to run antrea cni plugin binary on a busybox system or alternatively with incompatible libpthread or libc. In particulary, it didn't work on k3os.

Expected
As with other cni plugins, it should be statically compiled so that Antrea can be deployed on any system.

Actual behavior
Antrea cannot be deployed successfully (spawning non-host containers fails when network plugin is calling /opt/cni/bin/antrea).

Versions:

  • Antrea version: 1.0.0
  • Kubernetes version: 1.20
  • Container runtime: containerd
  • Linux kernel version: 5.4.0

Additional context
None.

@nitrotm nitrotm added the kind/bug Categorizes issue or PR as related to a bug. label Apr 15, 2021
@tnqn
Copy link
Member

tnqn commented Apr 15, 2021

Hi @nitrotm, thanks for the report! Making antrea cni binary statically compiled makes sense to me. It applies to other binaries that will run out of container too, e.g. antctl, antrea-octant-plugin.
Or maybe we could just compile all of the binaries statically if no real drawbacks. What do you think? @jianjuns @antoninbas

@nitrotm would you be willing to create a PR for this?

@tnqn
Copy link
Member

tnqn commented Apr 15, 2021

And to confirm, I assume the issue could cause the container runtime fail to call antrea cni, but it shouldn't fail on initContainer of antrea-agent while installing cni. Could you paste the failure of initContainer if there is? I couldn't reproduce it with k3os.

@jianjuns
Copy link
Contributor

Agreed on compiling Antrea CNI statically.

@nitrotm
Copy link
Author

nitrotm commented Apr 15, 2021

@tnqn sorry, that's right, not related to initContainer. I was trying a whole bunch of different cni solutions (calico, cilium, kube-ovn, etc) and forgot the exact root cause of the error. I did the deploy from scratch again and here is more detailed info:

If you deploy antrea and start a simple pod (eg. busybox), then you'll see the following in the events:

│   Warning  FailedCreatePodSandBox  48s   kubelet            Failed to create pod sandbox: rpc error: code = Unknown desc = failed to setup network for sandbox "aa771c57bc881ace3ec1548653ca27f7382940d4c312893576a5432d5b46af9d": netplugin failed with no error message: fork/exec /opt/cni/bin/antrea: no such file or d │

But the file is there on the host /opt/cni/bin/antrea, simply not executable, and ldd reports:

$> ldd /opt/cni/bin/antrea 
        /lib64/ld-linux-x86-64.so.2 (0x7f30d161b000)
        libpthread.so.0 => /lib64/ld-linux-x86-64.so.2 (0x7f30d161b000)
        libc.so.6 => /lib64/ld-linux-x86-64.so.2 (0x7f30d161b000)

which indicates some kind of library issue (eg. it looks like libc/libpthread linkage are impossible to satisfy in this busybox setup).

@nitrotm
Copy link
Author

nitrotm commented Apr 15, 2021

As per the question about creating a PR, I am probably not the right person for doing this right now because I feel I don't know yet enough about CNI internals and practically nothing about the way antrea is built and packaged.

I'll give antrea a try when this is solved and eventually will replace calico in my self-provisioned k8s clusters, depending upon how well it will fit my use-case. In the case a migration to antrea makes sense, I would be more keen on contributing to the project in the future.

@antoninbas
Copy link
Contributor

Thanks for reporting this @nitrotm. I can look into this before the next release (Antrea v1.1). Will assign this to me, but if someone wants to start working on this, please comment here and I can assign the issue to you.

@antoninbas antoninbas self-assigned this Apr 15, 2021
@antoninbas antoninbas added area/build-release Issues or PRs related to building and releasing priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release. labels Apr 15, 2021
@antoninbas antoninbas added this to the Antrea v1.1 release milestone Apr 15, 2021
antoninbas added a commit to antoninbas/antrea that referenced this issue May 18, 2021
antrea-cni can be installed (by the initContainer) on systems with
incompatible system libraries. To increase portability, we build
antrea-cni without cgo by setting CG_ENABLED to 0.

Same goes for release binaries (e.g. antctl). Note that when
cross-compiling, cgo is disabled by default, so there is no change there
(e.g. antctl binary for macOS). It's only for native Linux amd64 builds
that there is an actual change.

Fixes antrea-io#2095
@antoninbas antoninbas added the lifecycle/active Indicates that an issue or PR is actively being worked on by a contributor. label May 19, 2021
antoninbas added a commit to antoninbas/antrea that referenced this issue May 19, 2021
antrea-cni can be installed (by the initContainer) on systems with
incompatible system libraries. To increase portability, we build
antrea-cni without cgo by setting CG_ENABLED to 0.

Same goes for release binaries (e.g. antctl). Note that when
cross-compiling, cgo is disabled by default, so there is no change there
(e.g. antctl binary for macOS). It's only for native Linux amd64 builds
that there is an actual change.

Fixes antrea-io#2095
antoninbas added a commit to antoninbas/antrea that referenced this issue May 20, 2021
antrea-cni can be installed (by the initContainer) on systems with
incompatible system libraries. To increase portability, we build
antrea-cni without cgo by setting CG_ENABLED to 0.

Same goes for release binaries (e.g. antctl). Note that when
cross-compiling, cgo is disabled by default, so there is no change there
(e.g. antctl binary for macOS). It's only for native Linux amd64 builds
that there is an actual change.

Fixes antrea-io#2095

Signed-off-by: Antonin Bas <[email protected]>
antoninbas added a commit that referenced this issue May 20, 2021
antrea-cni can be installed (by the initContainer) on systems with
incompatible system libraries. To increase portability, we build
antrea-cni without cgo by setting CG_ENABLED to 0.

Same goes for release binaries (e.g. antctl). Note that when
cross-compiling, cgo is disabled by default, so there is no change there
(e.g. antctl binary for macOS). It's only for native Linux amd64 builds
that there is an actual change.

Fixes #2095

Signed-off-by: Antonin Bas <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/build-release Issues or PRs related to building and releasing kind/bug Categorizes issue or PR as related to a bug. lifecycle/active Indicates that an issue or PR is actively being worked on by a contributor. priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants