Skip to content

Commit

Permalink
Update golang to go1.22.3
Browse files Browse the repository at this point in the history
  • Loading branch information
orsenthil committed May 23, 2024
1 parent 7eb07e9 commit b0454e8
Show file tree
Hide file tree
Showing 9 changed files with 53 additions and 42 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/integration-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: "1.21"
go-version: "1.22"
- name: Set up tools
run: |
# Install ginkgo version from go.mod
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/nightly-cron-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: "1.21"
go-version: "1.22"
- name: Set up tools
run: |
# Install ginkgo version from go.mod
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/pr-automated-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: "1.21"
go-version: "1.22"
- name: Set up tools
run: |
go install golang.org/x/lint/golint@latest
Expand Down Expand Up @@ -50,7 +50,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: "1.21"
go-version: "1.22"
- name: Build CNI images
run: make multi-arch-cni-build
- name: Build CNI Init images
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pr-manual-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: "1.21"
go-version: "1.22"
- name: Set up tools
run: |
# Install ginkgo version from go.mod
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: "1.21"
go-version: "1.22"
- name: Generate CNI YAML
run: make generate-cni-yaml
- name: Create eks-charts PR
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/weekly-cron-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: "1.21"
go-version: "1.22"
- name: Set up tools
run: |
# Install ginkgo version from go.mod
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/aws/amazon-vpc-cni-k8s

go 1.21
go 1.22.3

require (
github.com/apparentlymart/go-cidr v1.1.0
Expand Down
77 changes: 44 additions & 33 deletions pkg/ipamd/ipamd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1397,8 +1397,6 @@ func datastoreWith3PodsFromPrefix() *datastore.DataStore {
}

func TestIPAMContext_filterUnmanagedENIs(t *testing.T) {
ctrl := gomock.NewController(t)

eni1, eni2, eni3 := getDummyENIMetadata()
allENIs := []awsutils.ENIMetadata{eni1, eni2, eni3}
primaryENIonly := []awsutils.ENIMetadata{eni1}
Expand All @@ -1417,26 +1415,29 @@ func TestIPAMContext_filterUnmanagedENIs(t *testing.T) {
eni2.ENIID: {"hi": "tag", eniNodeTagKey: "i-abcdabcdabcd"},
eni3.ENIID: {"hi": "tag", eniNodeTagKey: instanceID}}

mockAWSUtils := mock_awsutils.NewMockAPIs(ctrl)
mockAWSUtils.EXPECT().GetPrimaryENI().Times(5).Return(eni1.ENIID)
mockAWSUtils.EXPECT().GetInstanceID().Times(3).Return(instanceID)

tests := []struct {
name string
tagMap map[string]awsutils.TagMap
enis []awsutils.ENIMetadata
want []awsutils.ENIMetadata
unmanagedenis []string
name string
tagMap map[string]awsutils.TagMap
enis []awsutils.ENIMetadata
want []awsutils.ENIMetadata
unmanagedenis []string
expectedGetPrimaryENICalls int
expectedGetInstanceIDCalls int
}{
{"No tags at all", nil, allENIs, allENIs, nil},
{"Primary ENI unmanaged", Test1TagMap, allENIs, allENIs, nil},
{"Secondary/Tertiary ENI unmanaged", Test2TagMap, allENIs, primaryENIonly, []string{eni2.ENIID, eni3.ENIID}},
{"Secondary ENI unmanaged", Test3TagMap, allENIs, filteredENIonly, []string{eni2.ENIID}},
{"Secondary ENI unmanaged and Tertiary ENI CNI created", Test4TagMap, allENIs, filteredENIonly, []string{eni2.ENIID}},
{"Secondary ENI not CNI created and Tertiary ENI CNI created", Test5TagMap, allENIs, filteredENIonly, nil},
{"No tags at all", nil, allENIs, allENIs, nil, 0, 0},
{"Primary ENI unmanaged", Test1TagMap, allENIs, allENIs, nil, 1, 0},
{"Secondary/Tertiary ENI unmanaged", Test2TagMap, allENIs, primaryENIonly, []string{eni2.ENIID, eni3.ENIID}, 2, 0},
{"Secondary ENI unmanaged", Test3TagMap, allENIs, filteredENIonly, []string{eni2.ENIID}, 1, 0},
{"Secondary ENI unmanaged and Tertiary ENI CNI created", Test4TagMap, allENIs, filteredENIonly, []string{eni2.ENIID}, 1, 1},
{"Secondary ENI not CNI created and Tertiary ENI CNI created", Test5TagMap, allENIs, filteredENIonly, nil, 0, 2},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
ctrl := gomock.NewController(t)
defer ctrl.Finish()

mockAWSUtils := mock_awsutils.NewMockAPIs(ctrl)

c := &IPAMContext{
awsClient: mockAWSUtils,
enableManageUntaggedMode: true}
Expand All @@ -1447,6 +1448,10 @@ func TestIPAMContext_filterUnmanagedENIs(t *testing.T) {
sort.Strings(args)
assert.Equal(t, tt.unmanagedenis, args)
}).AnyTimes()

mockAWSUtils.EXPECT().GetPrimaryENI().Times(tt.expectedGetPrimaryENICalls).Return(eni1.ENIID)
mockAWSUtils.EXPECT().GetInstanceID().Times(tt.expectedGetInstanceIDCalls).Return(instanceID)

c.setUnmanagedENIs(tt.tagMap)

mockAWSUtils.EXPECT().IsUnmanagedENI(gomock.Any()).DoAndReturn(
Expand Down Expand Up @@ -1479,7 +1484,6 @@ func TestIPAMContext_filterUnmanagedENIs(t *testing.T) {
}

func TestIPAMContext_filterUnmanagedENIs_disableManageUntaggedMode(t *testing.T) {
ctrl := gomock.NewController(t)

eni1, eni2, eni3 := getDummyENIMetadata()
allENIs := []awsutils.ENIMetadata{eni1, eni2, eni3}
Expand All @@ -1499,30 +1503,37 @@ func TestIPAMContext_filterUnmanagedENIs_disableManageUntaggedMode(t *testing.T)
eni2.ENIID: {"hi": "tag", eniNodeTagKey: "i-abcdabcdabcd"},
eni3.ENIID: {"hi": "tag", eniNodeTagKey: instanceID}}

mockAWSUtils := mock_awsutils.NewMockAPIs(ctrl)
mockAWSUtils.EXPECT().GetPrimaryENI().Times(6).Return(eni1.ENIID)
mockAWSUtils.EXPECT().GetInstanceID().Times(3).Return(instanceID)

tests := []struct {
name string
tagMap map[string]awsutils.TagMap
enis []awsutils.ENIMetadata
want []awsutils.ENIMetadata
unmanagedenis []string
name string
tagMap map[string]awsutils.TagMap
enis []awsutils.ENIMetadata
want []awsutils.ENIMetadata
unmanagedenis []string
expectedGetPrimaryENICalls int
expectedGetInstanceIDCalls int
}{
{"No tags at all", nil, allENIs, allENIs, []string{eni2.ENIID, eni3.ENIID}},
{"Primary ENI unmanaged", Test1TagMap, allENIs, allENIs, nil},
{"Secondary/Tertiary ENI unmanaged", Test2TagMap, allENIs, primaryENIonly, []string{eni2.ENIID, eni3.ENIID}},
{"Secondary ENI unmanaged", Test3TagMap, allENIs, filteredENIonly, []string{eni2.ENIID}},
{"Secondary ENI unmanaged and Tertiary ENI CNI created", Test4TagMap, allENIs, filteredENIonly, []string{eni2.ENIID}},
{"Secondary ENI not CNI created and Tertiary ENI CNI created", Test5TagMap, allENIs, filteredENIonly, []string{eni2.ENIID}},
{"No tags at all", nil, allENIs, allENIs, []string{eni2.ENIID, eni3.ENIID}, 0, 0},
{"Primary ENI unmanaged", Test1TagMap, allENIs, allENIs, nil, 1, 0},
{"Secondary/Tertiary ENI unmanaged", Test2TagMap, allENIs, primaryENIonly, []string{eni2.ENIID, eni3.ENIID}, 2, 0},
{"Secondary ENI unmanaged", Test3TagMap, allENIs, filteredENIonly, []string{eni2.ENIID}, 1, 0},
{"Secondary ENI unmanaged and Tertiary ENI CNI created", Test4TagMap, allENIs, filteredENIonly, []string{eni2.ENIID}, 1, 1},
{"Secondary ENI not CNI created and Tertiary ENI CNI created", Test5TagMap, allENIs, filteredENIonly, []string{eni2.ENIID}, 1, 2},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
ctrl := gomock.NewController(t)

defer ctrl.Finish()

mockAWSUtils := mock_awsutils.NewMockAPIs(ctrl)

c := &IPAMContext{
awsClient: mockAWSUtils,
enableManageUntaggedMode: false}

mockAWSUtils.EXPECT().GetPrimaryENI().Times(tt.expectedGetPrimaryENICalls).Return(eni1.ENIID)
mockAWSUtils.EXPECT().GetInstanceID().Times(tt.expectedGetInstanceIDCalls).Return(instanceID)

mockAWSUtils.
EXPECT().
SetUnmanagedENIs(gomock.Any()).
Expand Down
2 changes: 1 addition & 1 deletion test/agent/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/aws/amazon-vpc-cni-k8s/test/agent

go 1.21
go 1.22.3

require (
github.com/coreos/go-iptables v0.7.0
Expand Down

0 comments on commit b0454e8

Please sign in to comment.