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

fix multus config file generation to avoid self-delegation #1137

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion cmd/thin_entrypoint/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ import (
"fmt"
"io"
"os"
"path"
"path/filepath"
"regexp"
"strings"
"text/template"
"time"
Expand Down Expand Up @@ -294,7 +296,20 @@ func (o *Options) createMultusConfig() (string, error) {
return "", fmt.Errorf("cannot find master CNI config in %q: %v", o.MultusAutoconfigDir, err)
}

masterConfigPath := files[0]
var masterConfigPath string
// skip existing multus configuration file to avoid creating a situation
// where multus delegates to itself and breaks pod networking
multusRegexp, err := regexp.Compile("00-multus.conf{,list}")
if err != nil {
return "", fmt.Errorf("regexp compilation failed: %v", err)
}
for _, filename := range files {
if !multusRegexp.MatchString(path.Base(filename)) {
masterConfigPath = filename
break
}
}

masterConfigBytes, err := os.ReadFile(masterConfigPath)
if err != nil {
return "", fmt.Errorf("cannot read master CNI config file %q: %v", masterConfigPath, err)
Expand Down