Skip to content

Commit ac01d8b

Browse files
committed
pkg/multus: downcast empty CNI result to requested cniVersion
Closes #1497. Signed-off-by: SAY-5 <say.apm35@gmail.com>
1 parent bd3f2a5 commit ac01d8b

11 files changed

Lines changed: 98 additions & 50 deletions

File tree

.github/workflows/build.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ jobs:
1010
runs-on: ${{ matrix.os }}
1111
steps:
1212
- name: Install Go
13-
uses: actions/setup-go@40f1582b2485089dde7abd97c1529aa768e1baff # v5
13+
uses: actions/setup-go@v5
1414
with:
1515
go-version: ${{ matrix.go-version }}
1616

1717
- name: Checkout code
18-
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
18+
uses: actions/checkout@v4
1919

2020
- name: Build
2121
env:

.github/workflows/codeql.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,18 @@ jobs:
2424

2525
steps:
2626
- name: Checkout
27-
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
27+
uses: actions/checkout@v4
2828

2929
- name: Initialize CodeQL
30-
uses: github/codeql-action/init@b8d3b6e8af63cde30bdc382c0bc28114f4346c88 # v2
30+
uses: github/codeql-action/init@v2
3131
with:
3232
languages: ${{ matrix.language }}
3333
queries: +security-and-quality
3434

3535
- name: Autobuild
36-
uses: github/codeql-action/autobuild@b8d3b6e8af63cde30bdc382c0bc28114f4346c88 # v2
36+
uses: github/codeql-action/autobuild@v2
3737

3838
- name: Perform CodeQL Analysis
39-
uses: github/codeql-action/analyze@b8d3b6e8af63cde30bdc382c0bc28114f4346c88 # v2
39+
uses: github/codeql-action/analyze@v2
4040
with:
4141
category: "/language:${{ matrix.language }}"

.github/workflows/image-build.yml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@ jobs:
66
runs-on: ubuntu-latest
77
steps:
88
- name: Check out code into the Go module directory
9-
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
9+
uses: actions/checkout@v4
1010

1111
- name: Set up Docker Buildx
12-
uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3
12+
uses: docker/setup-buildx-action@v3
1313

1414
# note: disable sbom/provenance for now (gchr.io does not managed well yet)
1515
- name: Build container image
16-
uses: docker/build-push-action@10e90e3645eae34f1e60eeb005ba3a3d33f178e8 # v6
16+
uses: docker/build-push-action@v6
1717
with:
1818
context: .
1919
push: false
@@ -25,7 +25,7 @@ jobs:
2525

2626
# note: disable sbom/provenance for now (gchr.io does not managed well yet)
2727
- name: Build container debug image
28-
uses: docker/build-push-action@10e90e3645eae34f1e60eeb005ba3a3d33f178e8 # v6
28+
uses: docker/build-push-action@v6
2929
with:
3030
context: .
3131
push: false
@@ -40,13 +40,13 @@ jobs:
4040
runs-on: ubuntu-latest
4141
steps:
4242
- name: Check out code into the Go module directory
43-
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
43+
uses: actions/checkout@v4
4444

4545
- name: Set up Docker Buildx
46-
uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3
46+
uses: docker/setup-buildx-action@v3
4747

4848
- name: Build container image
49-
uses: docker/build-push-action@10e90e3645eae34f1e60eeb005ba3a3d33f178e8 # v6
49+
uses: docker/build-push-action@v6
5050
with:
5151
context: .
5252
push: false
@@ -57,7 +57,7 @@ jobs:
5757
provenance: false
5858

5959
- name: Run Trivy vulnerability scanner
60-
uses: aquasecurity/trivy-action@57a97c7e7821a5776cebc9bb87c984fa69cba8f1 # v0.35.0
60+
uses: aquasecurity/trivy-action@0.35.0
6161
with:
6262
image-ref: ghcr.io/${{ github.repository }}:latest-thick
6363
ignore-unfixed: true
@@ -67,7 +67,7 @@ jobs:
6767
output: 'trivy-results.sarif'
6868

6969
- name: Upload Trivy scan results to GitHub Security tab
70-
uses: github/codeql-action/upload-sarif@ebcb5b36ded6beda4ceefea6a8bc4cc885255bb3 # v3
70+
uses: github/codeql-action/upload-sarif@v3
7171
if: always()
7272
with:
7373
sarif_file: 'trivy-results.sarif'
@@ -77,10 +77,10 @@ jobs:
7777
runs-on: ubuntu-latest
7878
steps:
7979
- name: Check out code into the Go module directory
80-
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
80+
uses: actions/checkout@v4
8181

8282
- name: Set up Docker Buildx
83-
uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3
83+
uses: docker/setup-buildx-action@v3
8484

8585
- name: Download OKD Builder Dockerfile
8686
run: curl https://raw.githubusercontent.com/okd-project/images/main/builder/Dockerfile -o images/okd-builder.Dockerfile

.github/workflows/image-push-master.yml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,22 @@ jobs:
1111
runs-on: ubuntu-latest
1212
steps:
1313
- name: Check out code into the Go module directory
14-
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
14+
uses: actions/checkout@v4
1515

1616
- name: Set up Docker Buildx
17-
uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3
17+
uses: docker/setup-buildx-action@v3
1818

1919
- name: Login to GitHub Container Registry
2020
if: ${{ github.repository_owner == env.image-push-owner }}
21-
uses: docker/login-action@c94ce9fb468520275223c153574b00df6fe4bcc9 # v3
21+
uses: docker/login-action@v3
2222
with:
2323
registry: ghcr.io
2424
username: ${{ github.repository_owner }}
2525
password: ${{ secrets.GITHUB_TOKEN }}
2626

2727
- name: Push container image for thick plugin
2828
if: ${{ github.repository_owner == env.image-push-owner }}
29-
uses: docker/build-push-action@ca052bb54ab0790a636c9b5f226502c73d547a25 # v5
29+
uses: docker/build-push-action@v5
3030
with:
3131
context: .
3232
push: true
@@ -43,22 +43,22 @@ jobs:
4343
runs-on: ubuntu-latest
4444
steps:
4545
- name: Check out code into the Go module directory
46-
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
46+
uses: actions/checkout@v4
4747

4848
- name: Set up Docker Buildx
49-
uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3
49+
uses: docker/setup-buildx-action@v3
5050

5151
- name: Login to GitHub Container Registry
5252
if: ${{ github.repository_owner == env.image-push-owner }}
53-
uses: docker/login-action@c94ce9fb468520275223c153574b00df6fe4bcc9 # v3
53+
uses: docker/login-action@v3
5454
with:
5555
registry: ghcr.io
5656
username: ${{ github.repository_owner }}
5757
password: ${{ secrets.GITHUB_TOKEN }}
5858

5959
- name: Push thin container image
6060
if: ${{ github.repository_owner == env.image-push-owner }}
61-
uses: docker/build-push-action@ca052bb54ab0790a636c9b5f226502c73d547a25 # v5
61+
uses: docker/build-push-action@v5
6262
with:
6363
context: .
6464
push: true
@@ -72,7 +72,7 @@ jobs:
7272

7373
- name: Push thin container debug image
7474
if: ${{ github.repository_owner == env.image-push-owner }}
75-
uses: docker/build-push-action@ca052bb54ab0790a636c9b5f226502c73d547a25 # v5
75+
uses: docker/build-push-action@v5
7676
with:
7777
context: .
7878
push: true

.github/workflows/image-push-release.yml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,30 +11,30 @@ jobs:
1111
runs-on: ubuntu-latest
1212
steps:
1313
- name: Check out code into the Go module directory
14-
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
14+
uses: actions/checkout@v4
1515

1616
- name: Set up Docker Buildx
17-
uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3
17+
uses: docker/setup-buildx-action@v3
1818

1919
- name: Login to GitHub Container Registry
2020
if: ${{ github.repository_owner == env.image-push-owner }}
21-
uses: docker/login-action@c94ce9fb468520275223c153574b00df6fe4bcc9 # v3
21+
uses: docker/login-action@v3
2222
with:
2323
registry: ghcr.io
2424
username: ${{ github.repository_owner }}
2525
password: ${{ secrets.GITHUB_TOKEN }}
2626

2727
- name: Docker meta
2828
id: docker_meta
29-
uses: docker/metadata-action@c299e40c65443455700f0fdfc63efafe5b349051 # v5
29+
uses: docker/metadata-action@v5
3030
with:
3131
images: ghcr.io/${{ github.repository }}
3232
flavor: |
3333
latest=false
3434
3535
- name: Push container image for thick plugin
3636
if: ${{ github.repository_owner == env.image-push-owner }}
37-
uses: docker/build-push-action@ca052bb54ab0790a636c9b5f226502c73d547a25 # v5
37+
uses: docker/build-push-action@v5
3838
with:
3939
context: .
4040
push: true
@@ -51,30 +51,30 @@ jobs:
5151
runs-on: ubuntu-latest
5252
steps:
5353
- name: Check out code into the Go module directory
54-
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
54+
uses: actions/checkout@v4
5555

5656
- name: Set up Docker Buildx
57-
uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3
57+
uses: docker/setup-buildx-action@v3
5858

5959
- name: Login to GitHub Container Registry
6060
if: ${{ github.repository_owner == env.image-push-owner }}
61-
uses: docker/login-action@c94ce9fb468520275223c153574b00df6fe4bcc9 # v3
61+
uses: docker/login-action@v3
6262
with:
6363
registry: ghcr.io
6464
username: ${{ github.repository_owner }}
6565
password: ${{ secrets.GITHUB_TOKEN }}
6666

6767
- name: Docker meta
6868
id: docker_meta
69-
uses: docker/metadata-action@c299e40c65443455700f0fdfc63efafe5b349051 # v5
69+
uses: docker/metadata-action@v5
7070
with:
7171
images: ghcr.io/${{ github.repository }}
7272
flavor: |
7373
latest=false
7474
7575
- name: Push thin container image
7676
if: ${{ github.repository_owner == env.image-push-owner }}
77-
uses: docker/build-push-action@ca052bb54ab0790a636c9b5f226502c73d547a25 # v5
77+
uses: docker/build-push-action@v5
7878
with:
7979
context: .
8080
push: true
@@ -88,7 +88,7 @@ jobs:
8888

8989
- name: Push thin container debug image
9090
if: ${{ github.repository_owner == env.image-push-owner }}
91-
uses: docker/build-push-action@ca052bb54ab0790a636c9b5f226502c73d547a25 # v5
91+
uses: docker/build-push-action@v5
9292
with:
9393
context: .
9494
push: true

.github/workflows/kind-e2e.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,13 @@ jobs:
3333
github.event_name == 'pull_request' ) || (github.event_name == 'push' && github.event.commits != '[]' )
3434
steps:
3535
- name: Check out code into the Go module directory
36-
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
36+
uses: actions/checkout@v4
3737

3838
- name: Set up Docker Buildx
39-
uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3
39+
uses: docker/setup-buildx-action@v3
4040

4141
- name: Setup python
42-
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5
42+
uses: actions/setup-python@v5
4343
with:
4444
python-version: 3.x
4545

@@ -49,7 +49,7 @@ jobs:
4949
echo $(j2 --version)
5050
5151
- name: Build latest-amd64
52-
uses: docker/build-push-action@ca052bb54ab0790a636c9b5f226502c73d547a25 # v5
52+
uses: docker/build-push-action@v5
5353
with:
5454
context: .
5555
load: true
@@ -108,7 +108,7 @@ jobs:
108108
109109
- name: Upload kind logs
110110
if: always()
111-
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
111+
uses: actions/upload-artifact@v4
112112
with:
113113
name: kind-logs-${{ env.JOB_NAME }}-${{ github.run_id }}
114114
path: /tmp/kind/logs

.github/workflows/release.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,17 @@ jobs:
88
runs-on: ubuntu-latest
99
steps:
1010
- name: Checkout
11-
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
11+
uses: actions/checkout@v4
1212
with:
1313
fetch-depth: 0
1414

1515
- name: Set up Go
16-
uses: actions/setup-go@40f1582b2485089dde7abd97c1529aa768e1baff # v5
16+
uses: actions/setup-go@v5
1717
with:
1818
go-version: 1.25.x
1919

2020
- name: Run GoReleaser
21-
uses: goreleaser/goreleaser-action@5742e2a039330cbb23ebf35f046f814d4c6ff811 # v5
21+
uses: goreleaser/goreleaser-action@v5
2222
with:
2323
version: latest
2424
args: release --rm-dist

.github/workflows/stale-issues-prs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ jobs:
77
stale:
88
runs-on: ubuntu-latest
99
steps:
10-
- uses: actions/stale@5bef64f19d7facfb25b37b414482c7164d639639 # v9
10+
- uses: actions/stale@v9
1111
with:
1212
stale-issue-message: 'This issue is stale because it has been open 90 days with no activity. Remove stale label or comment or this will be closed in 7 days.'
1313
stale-pr-message: 'This pull request is stale because it has been open 90 days with no activity. Remove stale label or comment or this will be closed in 7 days.'

.github/workflows/test.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ jobs:
99
runs-on: ${{ matrix.os }}
1010
steps:
1111
- name: Install Go
12-
uses: actions/setup-go@40f1582b2485089dde7abd97c1529aa768e1baff # v5
12+
uses: actions/setup-go@v5
1313
with:
1414
go-version: ${{ matrix.go-version }}
1515

1616
- name: Checkout code
17-
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
17+
uses: actions/checkout@v4
1818

1919
- name: Run Revive Action by pulling pre-built image
2020
uses: docker://morphy/revive-action:v2
@@ -32,7 +32,7 @@ jobs:
3232
run: sudo -E env "PATH=$PATH" ./hack/test-go.sh
3333

3434
- name: Send coverage
35-
uses: shogo82148/actions-goveralls@25f5320d970fb565100cf1993ada29be1bb196a1 # v1
35+
uses: shogo82148/actions-goveralls@v1
3636
with:
3737
path-to-profile: coverage.out
3838
flag-name: Go-${{ matrix.go }}
@@ -43,6 +43,6 @@ jobs:
4343
needs: test
4444
runs-on: ubuntu-latest
4545
steps:
46-
- uses: shogo82148/actions-goveralls@25f5320d970fb565100cf1993ada29be1bb196a1 # v1
46+
- uses: shogo82148/actions-goveralls@v1
4747
with:
4848
parallel-finished: true

pkg/multus/multus.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -768,6 +768,19 @@ func CmdAdd(args *skel.CmdArgs, exec invoke.Exec, kubeClient *k8s.ClientInfo) (c
768768
if stderrors.Is(err, errPodNotFound) {
769769
emptyResult := emptyCNIResult(args, n.CNIVersion)
770770
logging.Verbosef("CmdAdd: Warning: pod [%s/%s] not found, exiting with empty CNI result: %v", k8sArgs.K8S_POD_NAMESPACE, k8sArgs.K8S_POD_NAME, emptyResult)
771+
// emptyCNIResult already returns a *cni100.Result, so 1.x
772+
// configs don't need conversion. For older cniVersions
773+
// (0.3.x / 0.4.0) we must downcast so skel's response
774+
// conversion path calls the right convertFrom*/To* converter;
775+
// otherwise convertFrom04x's type assertion to *types040.Result
776+
// panics (#1497).
777+
if n.CNIVersion != "" && !strings.HasPrefix(n.CNIVersion, "1.") {
778+
versioned, convErr := emptyResult.GetAsVersion(n.CNIVersion)
779+
if convErr != nil {
780+
return nil, cmdErr(k8sArgs, "failed to downcast empty CNI result to cniVersion %q: %v", n.CNIVersion, convErr)
781+
}
782+
return versioned, nil
783+
}
771784
return emptyResult, nil
772785
}
773786
return nil, err

0 commit comments

Comments
 (0)