Skip to content

Commit

Permalink
Patch upstream issue where multus delegates to itself
Browse files Browse the repository at this point in the history
and breaks pod networking by try multiple times to create the same interface.

Issue fixed: rancher/rke2#4568
  • Loading branch information
thomasferrandiz committed Aug 9, 2023
1 parent 83069ac commit b9547ee
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,14 @@ ARG ARCH
ARG TAG
ENV GOARCH ${ARCH}
ENV GOOS "linux"
# patch to solve https://github.com/rancher/rke2/issues/4568
# to be removed once upstream merges the fix
COPY self_delegation_bug.patch /tmp
RUN git clone --depth=1 https://github.com/k8snetworkplumbingwg/multus-cni && \
cd multus-cni && \
git fetch --all --tags --prune && \
git checkout tags/${TAG} -b ${TAG} && \
git apply /tmp/self_delegation_bug.patch && \
./hack/build-go.sh

# Create the multus image
Expand Down
36 changes: 36 additions & 0 deletions self_delegation_bug.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
diff --git a/cmd/thin_entrypoint/main.go b/cmd/thin_entrypoint/main.go
index ac721518..3f0e835f 100644
--- a/cmd/thin_entrypoint/main.go
+++ b/cmd/thin_entrypoint/main.go
@@ -23,7 +23,9 @@ import (
"fmt"
"io"
"os"
+ "path"
"path/filepath"
+ "regexp"
"strings"
"text/template"
"time"
@@ -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("multus")
+ 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)

0 comments on commit b9547ee

Please sign in to comment.