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

OCPBUGS-37991: Downstream sync to address multiple interface returns in network-status annotation #245

Merged
merged 40 commits into from
Aug 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
d625d48
Change Validation of interface name
adrianchiris Mar 14, 2024
40378ca
add support for Dynamic Resource Allocation
moshe010 Jun 29, 2023
202533c
support for Dynamic Resource Allocation doc update
moshe010 Nov 6, 2023
2c796b5
Add DRA Integration E2E test
vasrem Mar 18, 2024
5a407e1
Bump golang.org/x/net from 0.17.0 to 0.23.0
dependabot[bot] Apr 19, 2024
633985d
thin plugin: Handle --multus-master-cni-file-name flag
ordovicia Apr 25, 2024
8918802
Merge pull request #1266 from k8snetworkplumbingwg/dependabot/go_modu…
s1061123 May 1, 2024
541a803
Fix defaultnetworkfile in unit test
s1061123 May 1, 2024
4457289
Merge pull request #1272 from s1061123/fix-readiness
s1061123 May 1, 2024
5fe1249
Fix CNI cache update function to prevent nil access
s1061123 May 8, 2024
c6a371b
Merge pull request #1274 from s1061123/fix/gateway-nil
dougbtv May 9, 2024
5a2597b
Merge pull request #1270 from ordovicia/thin-master-cni-file-flag
s1061123 May 9, 2024
c9d411c
Add warning in docs that DRA is alpha and in preview
vasrem May 13, 2024
181f56f
Thick plugin should not wait for API readiness on CNI DEL
dougbtv May 14, 2024
75c0245
Merge pull request #1279 from dougbtv/skip-api-ready-on-cni-del
s1061123 May 15, 2024
bb47b55
arm64: build image for arm v8
ader1990 May 17, 2024
d9f1c7c
Merge pull request #1243 from adrianchiris/allow_undersocre_in_ifname
dougbtv May 23, 2024
9f5c023
Merge pull request #1078 from moshe010/dra
dougbtv May 23, 2024
d23856b
Not exposed APIReadyCheckFunc to outside of package
s1061123 May 24, 2024
4757be1
Merge pull request #1286 from s1061123/fix-type-scope-comment
dougbtv Jun 6, 2024
aff99fc
Merge pull request #1284 from ader1990/patch-1
dougbtv Jun 6, 2024
572e4e0
Build multiarch thick images
sfackler Jun 12, 2024
849a3cd
Add mountPropagation to host-var-lib-kubelet
adrianchiris Jun 18, 2024
41013e7
Merge pull request #1300 from adrianchiris/fix-mount-prop-var-lib-kub…
dougbtv Jun 20, 2024
cd81346
Add a note about multi-arch support
sfackler Jun 25, 2024
9b4a0ce
Update how-to-use.md
alrokayan Jun 30, 2024
8587734
Merge pull request #1305 from alrokayan/patch-1
dougbtv Jul 18, 2024
334fdce
Add signals package
adrianchiris Jun 17, 2024
004f1e6
delete multus conf file generated by thin_entrypoint
adrianchiris Jun 17, 2024
04fb819
Update DRA integration info and e2e test
vasrem Jul 24, 2024
bc6c8d5
Updates to use CreateNetworkStauses from net-attach-def client for mu…
dougbtv Jul 25, 2024
f54693f
Merge pull request #1313 from vasrem/chore/update-dra-e2e
dougbtv Jul 25, 2024
6ade0ce
update how-to-use doc
adrianchiris Jul 18, 2024
fd9736b
Merge pull request #1297 from sfackler/thick-arm
dougbtv Aug 1, 2024
b11ea82
Merge pull request #1299 from adrianchiris/cleanup-multus-conf
dougbtv Aug 1, 2024
ca21ef6
create multus kubeconfig for incase of non auto flag.
abasitt Jun 22, 2024
b901901
Merge pull request #1317 from adrianchiris/pr-1302-update
dougbtv Aug 1, 2024
a28d1e4
[bump] Bumps net-attach-def client lib to v1.7.1
dougbtv Aug 1, 2024
3c33f6f
Merge pull request #1314 from dougbtv/client-lib-multiple-if-cni-result
dougbtv Aug 5, 2024
a9fc584
Merge branch 'master' into downstream-sync-aug24
dougbtv Aug 5, 2024
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
11 changes: 7 additions & 4 deletions .github/workflows/image-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ jobs:
push: false
tags: ghcr.io/${{ github.repository }}:latest
file: images/Dockerfile.debug
platforms: linux/amd64,linux/arm64,linux/arm/v7,linux/ppc64le,linux/s390x
platforms: linux/amd64,linux/arm64,linux/arm/v7,linux/arm/v8,linux/ppc64le,linux/s390x
sbom: false
provenance: false

build-amd64-thick:
name: Image build/amd64 thick plugin
build-thick:
name: Image thick plugin
runs-on: ubuntu-latest
steps:
- name: Check out code into the Go module directory
Expand All @@ -50,8 +50,11 @@ jobs:
with:
context: .
push: false
tags: ghcr.io/${{ github.repository }}:latest-amd64-thick
tags: ghcr.io/${{ github.repository }}:latest-thick
file: images/Dockerfile.thick
platforms: linux/amd64,linux/arm64,linux/arm/v7,linux/arm/v8,linux/ppc64le,linux/s390x
sbom: false
provenance: false

build-origin:
name: Image build/origin
Expand Down
14 changes: 8 additions & 6 deletions .github/workflows/image-push-master.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
name: Image push for master
on:
on:
push:
branches:
- master
env:
image-push-owner: 'k8snetworkplumbingwg'
jobs:
push-thick-amd64:
name: Image push thick image/amd64
push-thick:
name: Image push thick image
runs-on: ubuntu-latest
steps:
- name: Check out code into the Go module directory
Expand All @@ -34,7 +34,9 @@ jobs:
ghcr.io/${{ github.repository }}:latest-thick
ghcr.io/${{ github.repository }}:snapshot-thick
file: images/Dockerfile.thick
platforms: linux/amd64
platforms: linux/amd64,linux/arm64,linux/arm/v7,linux/arm/v8,linux/ppc64le,linux/s390x
sbom: false
provenance: false

push-thin:
name: Image push thin image
Expand Down Expand Up @@ -64,7 +66,7 @@ jobs:
ghcr.io/${{ github.repository }}:latest
ghcr.io/${{ github.repository }}:snapshot
file: images/Dockerfile
platforms: linux/amd64,linux/arm64,linux/arm/v7,linux/ppc64le,linux/s390x
platforms: linux/amd64,linux/arm64,linux/arm/v7,linux/arm/v8,linux/ppc64le,linux/s390x
sbom: false
provenance: false

Expand All @@ -78,7 +80,7 @@ jobs:
ghcr.io/${{ github.repository }}:latest-debug
ghcr.io/${{ github.repository }}:snapshot-debug
file: images/Dockerfile.debug
platforms: linux/amd64,linux/arm64,linux/arm/v7,linux/ppc64le,linux/s390x
platforms: linux/amd64,linux/arm64,linux/arm/v7,linux/arm/v8,linux/ppc64le,linux/s390x
sbom: false
provenance: false

Expand Down
14 changes: 8 additions & 6 deletions .github/workflows/image-push-release.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
name: Image push release
on:
on:
push:
tags:
- v*
env:
image-push-owner: 'k8snetworkplumbingwg'
jobs:
push-thick-amd64:
name: Image push thick image/amd64
push-thick:
name: Image push thick image
runs-on: ubuntu-latest
steps:
- name: Check out code into the Go module directory
Expand Down Expand Up @@ -42,7 +42,9 @@ jobs:
ghcr.io/${{ github.repository }}:stable-thick
${{ steps.docker_meta.outputs.tags }}-thick
file: images/Dockerfile.thick
platforms: linux/amd64
platforms: linux/amd64,linux/arm64,linux/arm/v7,linux/arm/v8,linux/ppc64le,linux/s390x
sbom: false
provenance: false

push-thin:
name: Image push thin image/amd64
Expand Down Expand Up @@ -80,7 +82,7 @@ jobs:
ghcr.io/${{ github.repository }}:stable
${{ steps.docker_meta.outputs.tags }}
file: images/Dockerfile
platforms: linux/amd64,linux/arm64,linux/arm/v7,linux/ppc64le,linux/s390x
platforms: linux/amd64,linux/arm64,linux/arm/v7,linux/arm/v8,linux/ppc64le,linux/s390x
sbom: false
provenance: false

Expand All @@ -94,7 +96,7 @@ jobs:
ghcr.io/${{ github.repository }}:stable-debug
${{ steps.docker_meta.outputs.tags }}-debug
file: images/Dockerfile.debug
platforms: linux/amd64,linux/arm64,linux/arm/v7,linux/ppc64le,linux/s390x
platforms: linux/amd64,linux/arm64,linux/arm/v7,linux/arm/v8,linux/ppc64le,linux/s390x
sbom: false
provenance: false

Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/kind-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ jobs:
working-directory: ./e2e
run: ./test-default-route1.sh

- name: Test DRA integration
working-directory: ./e2e
run: ./test-dra-integration.sh

- name: Export kind logs
if: always()
run: |
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
bin/
e2e/bin/
e2e/yamls/
e2e/repos/

# GOPATH created by the build script
gopath/
Expand Down
125 changes: 86 additions & 39 deletions cmd/thin_entrypoint/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import (
"github.com/spf13/pflag"

"gopkg.in/k8snetworkplumbingwg/multus-cni.v4/pkg/cmdutils"
"gopkg.in/k8snetworkplumbingwg/multus-cni.v4/pkg/signals"
)

// Options stores command line options
Expand All @@ -57,6 +58,7 @@ type Options struct {
AdditionalBinDir string
ForceCNIVersion bool
SkipTLSVerify bool
SkipMultusConfWatch bool
}

const (
Expand Down Expand Up @@ -84,7 +86,8 @@ func (o *Options) addFlags() {
fs.StringVar(&o.MultusLogLevel, "multus-log-level", "", "multus log level")
fs.StringVar(&o.MultusLogFile, "multus-log-file", "", "multus log file")
fs.BoolVar(&o.OverrideNetworkName, "override-network-name", false, "override network name from master cni file (used only with --multus-conf-file=auto)")
fs.BoolVar(&o.CleanupConfigOnExit, "cleanup-config-on-exit", false, "cleanup config file on exit (used only with --multus-conf-file=auto)")
fs.BoolVar(&o.CleanupConfigOnExit, "cleanup-config-on-exit", false, "cleanup config file on exit")
fs.BoolVar(&o.SkipMultusConfWatch, "skip-config-watch", false, "dont watch for config (master cni and kubeconfig) changes (used only with --multus-conf-file=auto)")
fs.BoolVar(&o.RenameConfFile, "rename-conf-file", false, "rename master config file to invalidate (used only with --multus-conf-file=auto)")
fs.StringVar(&o.ReadinessIndicatorFile, "readiness-indicator-file", "", "readiness indicator file (used only with --multus-conf-file=auto)")
fs.StringVar(&o.AdditionalBinDir, "additional-bin-dir", "", "adds binDir option to configuration (used only with --multus-conf-file=auto)")
Expand Down Expand Up @@ -310,22 +313,32 @@ const multusConfTemplate = `{
}
`

func (o *Options) createMultusConfig(prevMasterConfigFileHash []byte) (string, []byte, error) {
// find master file from MultusAutoconfigDir
func (o *Options) getMasterConfigPath() (string, error) {
// Master config file is specified
if o.MultusMasterCNIFileName != "" {
return filepath.Join(o.MultusAutoconfigDir, o.MultusMasterCNIFileName), nil
}

// Pick the alphabetically first config file from MultusAutoconfigDir
files, err := libcni.ConfFiles(o.MultusAutoconfigDir, []string{".conf", ".conflist"})
if err != nil {
return "", nil, fmt.Errorf("cannot find master CNI config in %q: %v", o.MultusAutoconfigDir, err)
return "", fmt.Errorf("cannot find master CNI config in %q: %v", o.MultusAutoconfigDir, err)
}

masterConfigPath := ""
for _, filename := range files {
if !strings.HasPrefix(filepath.Base(filename), "00-multus.conf") {
masterConfigPath = filename
break
return filename, nil
}
}
if masterConfigPath == "" {
return "", nil, fmt.Errorf("cannot find valid master CNI config in %q", o.MultusAutoconfigDir)

// No config file found
return "", fmt.Errorf("cannot find valid master CNI config in %q", o.MultusAutoconfigDir)
}

func (o *Options) createMultusConfig(prevMasterConfigFileHash []byte) (string, []byte, error) {
masterConfigPath, err := o.getMasterConfigPath()
if err != nil {
return "", nil, err
}

masterConfigBytes, masterConfigFileHash, err := getFileAndHash(masterConfigPath)
Expand Down Expand Up @@ -572,6 +585,11 @@ func main() {
var masterConfigFilePath string
// copy user specified multus conf to CNI conf directory
if opt.MultusConfFile != "auto" {
caHash, saTokenHash, err = opt.createKubeConfig(nil, nil)
if err != nil {
fmt.Fprintf(os.Stderr, "failed to create multus kubeconfig: %v\n", err)
return
}
confFileName := filepath.Base(opt.MultusConfFile)
tempConfFileName := fmt.Sprintf("%s.temp", confFileName)
if err = cmdutils.CopyFileAtomic(opt.MultusConfFile, opt.CNIConfDir, tempConfFileName, confFileName); err != nil {
Expand All @@ -594,43 +612,72 @@ func main() {
fmt.Printf("multus config file is created.\n")
}

if opt.CleanupConfigOnExit && opt.MultusConfFile == "auto" {
fmt.Printf("Entering watch loop...\n")
for {
// Check kubeconfig and update if different (i.e. service account updated)
caHash, saTokenHash, err = opt.createKubeConfig(caHash, saTokenHash)
if err != nil {
fmt.Fprintf(os.Stderr, "failed to update multus kubeconfig: %v\n", err)
return
}
ctx := signals.SetupSignalHandler()

// TODO: should we watch master CNI config (by fsnotify? https://github.com/fsnotify/fsnotify)
_, err = os.Stat(masterConfigFilePath)
if opt.CleanupConfigOnExit {
defer cleanupMultusConf(&opt)
}

// if masterConfigFilePath is no longer exists
if os.IsNotExist(err) {
fmt.Printf("Master plugin @ %q has been deleted. Allowing 45 seconds for its restoration...\n", masterConfigFilePath)
time.Sleep(10 * time.Second)
watchChanges := opt.CleanupConfigOnExit && opt.MultusConfFile == "auto" && !opt.SkipMultusConfWatch
if watchChanges {
fmt.Printf("Entering watch loop...\n")
masterConfigExists := true

outer:
for range time.Tick(1 * time.Second) {
select {
case <-ctx.Done():
// signal received break from loop
break outer
default:
// Check kubeconfig and update if different (i.e. service account updated)
caHash, saTokenHash, err = opt.createKubeConfig(caHash, saTokenHash)
if err != nil {
fmt.Fprintf(os.Stderr, "failed to update multus kubeconfig: %v\n", err)
return
}

for range time.Tick(1 * time.Second) {
_, err = os.Stat(masterConfigFilePath)
if !os.IsNotExist(err) {
fmt.Printf("Master plugin @ %q was restored. Regenerating given configuration.\n", masterConfigFilePath)
break
// TODO: should we watch master CNI config (by fsnotify? https://github.com/fsnotify/fsnotify)
_, err = os.Stat(masterConfigFilePath)

// if masterConfigFilePath is no longer exists
if os.IsNotExist(err) {
if masterConfigExists {
fmt.Printf("Master plugin @ %q has been deleted. waiting for its restoration...\n", masterConfigFilePath)
}
masterConfigExists = false
continue
}

if !masterConfigExists {
fmt.Printf("Master plugin @ %q was restored. Regenerating given configuration.\n", masterConfigFilePath)
masterConfigExists = true
}

masterConfigFilePath, masterConfigHash, err = opt.createMultusConfig(masterConfigHash)
if err != nil {
fmt.Fprintf(os.Stderr, "failed to create multus config: %v\n", err)
return
}
}
masterConfigFilePath, masterConfigHash, err = opt.createMultusConfig(masterConfigHash)
if err != nil {
fmt.Fprintf(os.Stderr, "failed to create multus config: %v\n", err)
return
}
time.Sleep(1 * time.Second)
}
} else {
// sleep infinitely
for {
time.Sleep(time.Duration(1<<63 - 1))
}
// wait until signal received
<-ctx.Done()
}
}

func cleanupMultusConf(opt *Options) {
// try remove multus conf
if opt.MultusConfFile == "auto" {
multusConfFilePath := fmt.Sprintf("%s/00-multus.conf", opt.CNIConfDir)
_ = os.Remove(multusConfFilePath)

multusConfFilePath = fmt.Sprintf("%s/00-multus.conflist", opt.CNIConfDir)
_ = os.Remove(multusConfFilePath)
} else {
confFileName := filepath.Base(opt.MultusConfFile)
_ = os.Remove(filepath.Join(opt.CNIConfDir, confFileName))
}

}
Loading