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

Add SKIP_CNI_BINARIES env var to support skipping installing specified cni bins #3454

Merged
merged 1 commit into from
Mar 21, 2022

Conversation

jainpulkit22
Copy link
Contributor

@jainpulkit22 jainpulkit22 commented Mar 16, 2022

Fixes #3422.

This PR adds a new feature by introducing skip_cni_binaries variable, to allow users to skip
installing some of the CNI plugin binaries which they think are not
required for certain reasons.

Signed-off-by: Pulkit Jain [email protected]

@codecov-commenter
Copy link

codecov-commenter commented Mar 16, 2022

Codecov Report

Merging #3454 (68ccf8a) into main (ed0ad19) will decrease coverage by 10.31%.
The diff coverage is n/a.

Impacted file tree graph

@@             Coverage Diff             @@
##             main    #3454       +/-   ##
===========================================
- Coverage   65.28%   54.97%   -10.32%     
===========================================
  Files         268      374      +106     
  Lines       26900    41447    +14547     
===========================================
+ Hits        17563    22784     +5221     
- Misses       7432    16263     +8831     
- Partials     1905     2400      +495     
Flag Coverage Δ
integration-tests 35.82% <ø> (?)
kind-e2e-tests 55.76% <ø> (+0.04%) ⬆️
unit-tests 42.44% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
pkg/agent/apiserver/apiserver.go 69.56% <0.00%> (-10.15%) ⬇️
pkg/agent/nodeportlocal/k8s/annotations.go 93.54% <0.00%> (-6.46%) ⬇️
pkg/ovs/ovsctl/appctl.go 42.39% <0.00%> (-2.18%) ⬇️
pkg/agent/openflow/pipeline.go 79.80% <0.00%> (-0.07%) ⬇️
...ea/pkg/agent/ipassigner/local_ip_detector_linux.go 0.00% <0.00%> (ø)
...g/agent/cniserver/interface_configuration_linux.go 24.87% <0.00%> (ø)
antrea/pkg/apis/controlplane/v1beta2/register.go 91.66% <0.00%> (ø)
.../agent/flowexporter/connections/conntrack_linux.go 2.41% <0.00%> (ø)
antrea/pkg/agent/config/node_config.go 50.00% <0.00%> (ø)
antrea/pkg/agent/openflow/network_policy.go 49.86% <0.00%> (ø)
... and 106 more

@jainpulkit22 jainpulkit22 force-pushed the add-cni-plugin-install-policy branch 2 times, most recently from 68ccf8a to 3a0ef43 Compare March 16, 2022 13:05
@jainpulkit22 jainpulkit22 changed the title Added feature CNI_PLUGIN_INSTALL_POLICY Add CNI_PLUGIN_INSTALL_POLICY for custom /opt/cni/bin plugin bundles Mar 16, 2022
@jainpulkit22 jainpulkit22 marked this pull request as ready for review March 16, 2022 13:09
env:
- name: SKIP_CNI_BINARIES
value: ""

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please remove this line

for args in $flags; do
binaries+=($args)
done
IFS=$oldDelimeter
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The above can be written in one line:

IFS=',' read -r -a binaries <<< "$SKIP_CNI_BINARIES"

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think by specifying IFS before the command, it only affects that line. Maybe you can test to verify it.

# Install the loopback plugin.
# It is required by kubelet on Linux when using docker as the container runtime.
# We replace the binary files even they are already present on the Node to make
# sure expected versions are used.
install -m 755 /opt/cni/bin/loopback /host/opt/cni/bin/loopback
if [[ ! " ${binaries[*]}" =~ "loopback" ]]; then
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although it works for current case, it's not very precise. For example, if there is one cni called loopback2, it would be matched by mistake. This would be more precise:

if [[ ! " ${binaries[*]} " =~ " loopback " ]]; then

@@ -3296,6 +3296,9 @@ spec:
initContainers:
- command:
- install_cni_chaining
env:
- name: SKIP_CNI_BINARIES
Copy link
Contributor

@luolanzone luolanzone Mar 18, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you provide a sample about how to set this variable? I didn't see you mention it anywhere.
I remember kustomize will remove all comments from yaml @tnqn any suggestion about where to put the sample information?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can I add the comment in the antrea.yml file

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be used by distros and end users won't care about it. So perhaps adding comment to the base yaml is enough, I think it's fine to not have it in the generated yaml.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BTW, could you update the PR title to be more accurate?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes sure would do that

@jainpulkit22 jainpulkit22 changed the title Add CNI_PLUGIN_INSTALL_POLICY for custom /opt/cni/bin plugin bundles Add SKIP_CNI_BINARIES feature for custom /opt/cni/bin plugin bundles Mar 18, 2022
for args in $flags; do
binaries+=($args)
done
IFS=$oldDelimeter
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think by specifying IFS before the command, it only affects that line. Maybe you can test to verify it.

@@ -48,6 +48,11 @@ spec:
add:
# SYS_MODULE is required to load the OVS kernel module.
- SYS_MODULE
env:
# SKIP_CNI_BINARIES takes in values as a comma separated list of
# binaries that need to be skipped.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# binaries that need to be skipped.
# binaries that need to be skipped for installation, e.g. "portmap, bandwdith".

@tnqn
Copy link
Member

tnqn commented Mar 18, 2022

This title may be more proper: Add SKIP_CNI_BINARIES env var to support skipping installing specified cni bins

@jainpulkit22 jainpulkit22 changed the title Add SKIP_CNI_BINARIES feature for custom /opt/cni/bin plugin bundles Add SKIP_CNI_BINARIES env var to support skipping installing specified cni bins Mar 18, 2022
tnqn
tnqn previously approved these changes Mar 18, 2022
Copy link
Member

@tnqn tnqn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks

@tnqn
Copy link
Member

tnqn commented Mar 18, 2022

/test-all

@@ -48,6 +48,11 @@ spec:
add:
# SYS_MODULE is required to load the OVS kernel module.
- SYS_MODULE
env:
# SKIP_CNI_BINARIES takes in values as a comma separated list of
# binaries that need to be skipped for installation, e.g. "portmap, bandwdith".
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# binaries that need to be skipped for installation, e.g. "portmap, bandwdith".
# binaries that need to be skipped for installation, e.g. "portmap, bandwidth".

This caused spelling check failure

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

my bad, I din't gave a relook to it. I will make the change

…d cni bins

This commit adds a skip_cni_binaries variable, to allow users to skip
installing some of the CNI plugin binaries which they think are not
required for certain reasons.

Signed-off-by: Pulkit Jain <[email protected]>
Copy link
Member

@tnqn tnqn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@tnqn
Copy link
Member

tnqn commented Mar 18, 2022

/test-all

build/images/scripts/install_cni Show resolved Hide resolved
@@ -2,25 +2,38 @@

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if in the future we should consider replacing this bash script with a small Go binary for maintainability and unit testing?

@tnqn tnqn added this to the Antrea v1.6 release milestone Mar 21, 2022
@tnqn tnqn added the action/release-note Indicates a PR that should be included in release notes. label Mar 21, 2022
@tnqn tnqn merged commit e274ab1 into antrea-io:main Mar 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
action/release-note Indicates a PR that should be included in release notes.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

(renamed) Feature: Add CNI_PLUGIN_INSTALL_POLICY for custom /opt/cni/bin plugin bundles
5 participants