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

fingerprint: check if the CNI bridge plugin is available #11038

Closed
wants to merge 4 commits into from

Conversation

notnoop
Copy link
Contributor

@notnoop notnoop commented Aug 11, 2021

A client should declare the "bridge" network fingerprint only if the
bridge CNI plugin is available.

Currently, Linux clients with the bridge kernel module enabled (pretty
much all Linux boxes with Docker installed) declare "bridge" network,
but allocs requiring it will fail with failed to find plugin "bridge" in path [/opt/cni/bin] error.

Related to #11034

A client should declare the "bridge" network fingerprint only if the
bridge CNI plugin is available.

Currently, Linux clients with the bridge kernel module enabled (pretty
much all Linux boxes with Docker installed) declare "bridge" network,
but allocs requiring it will fail with `failed to find plugin "bridge"
in path [/opt/cni/bin]` error.
if err := f.detect(bridgeKernelModuleName); err != nil {
f.logger.Warn("failed to detect bridge kernel module, bridge network mode disabled", "error", err)
if err := f.detect(req); err != nil {
f.logger.Warn("failed to dtect bridge network setup, bridge network mode disabled", "error", err)
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
f.logger.Warn("failed to dtect bridge network setup, bridge network mode disabled", "error", err)
f.logger.Warn("failed to detect bridge network setup, bridge network mode disabled", "error", err)


func (f *BridgeFingerprint) detectCNIBinaries(cniPath string) error {
if cniPath == "" {
return fmt.Errorf("cni is not configured")
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
return fmt.Errorf("cni is not configured")
return fmt.Errorf("cni_path is not configured")

Comment on lines +74 to +83
path := filepath.Join(cniPath, plugin)
fi, err := os.Stat(path)
if err != nil {
return fmt.Errorf("failed to find the %v CNI plugin in %v: %v", plugin, path, err)
}

if !fi.Mode().IsRegular() {
return fmt.Errorf("the %v CNI plugin is not a regular file: %v", plugin, path)

}
Copy link
Member

Choose a reason for hiding this comment

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

cni_path can contain multiple : delimited paths, so this needs to use filepath.SplitList and loop over the paths.

@hashicorp-cla
Copy link

CLA assistant check

Thank you for your submission! We require that all contributors sign our Contributor License Agreement ("CLA") before we can accept the contribution. Read and sign the agreement

Learn more about why HashiCorp requires a CLA and what the CLA includes


Mahmood Ali seems not to be a GitHub user.
You need a GitHub account to be able to sign the CLA. If you already have a GitHub account, please add the email address used for this commit to your account.

Have you signed the CLA already but the status is still pending? Recheck it.

@lgfa29
Copy link
Contributor

lgfa29 commented Apr 19, 2023

Closing this one as it was implemented in #15452.

@lgfa29 lgfa29 closed this Apr 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants