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

Update golang to go1.22.3 #2924

Merged
merged 1 commit into from
May 23, 2024
Merged
Show file tree
Hide file tree
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
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},
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's funny. I realized that the test fix I had to do was the same as described in this blogpost - https://go.dev/blog/loopvar-preview

{"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
Loading