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 Go to 1.17 #2609

Merged
merged 1 commit into from Aug 24, 2021
Merged

Update Go to 1.17 #2609

merged 1 commit into from Aug 24, 2021

Conversation

antoninbas
Copy link
Contributor

@antoninbas antoninbas commented Aug 17, 2021

Go 1.17 has just been released, which means that Go 1.15 will not be
actively maintained any more.

One notable change in Go 1.17 is that "pruned module graphs" are used:
https://golang.org/doc/go1.17#go-command. In Go 1.17, for the go command
to correctly resolve transitive imports using the pruned module graph,
the go.mod file for each module needs to include more detail about the
transitive dependencies relevant to that module. This leads to a second
require directive for modules that provide a transitively-imported
package. In previous versions, the go.mod file typically only included
explicit requirements for directly-imported packages.

The following command was used to update the go.mod (as suggested):
go-1.17 mod tidy -go=1.16 && go-1.17 mod tidy -go=1.17

I checked that the project could still be built using older Go versions:
GO=go-1.15 make bin
GO=go-1.16 make bin
GO=go-1.17 make bin

Another notable change is in the implementation of ParseIP and ParseCIDR
from the net package. These functions now reject IPv4 addresses which
contain decimal components with leading zeros. K8s is taking some extra
steps as they upgrade to Go 1.17 to ensure backwards-compatibility of
API resources which include IP fields and for which the contents of the
field are validated using the net stdlib functions. They are defining
their own versions of these functions, using code from the old version
of the standard library. In our case, we have decided not to follow in
K8s steps and we are sticking to the Go 1.17 standard library. Our
analysis has concluded that there is no reason to preserve past behavior
for network policies which use such IPv4 addresses. Note that these
policies will still be "valid" resources that users can delete /
update. But the Agent will reject the internal version of the policies
distributed by the Controller.

As part of this change, I also tried to have the current Go version be
defined in a "central" location to facilitate future updates.
Unfortunately this doesn't apply to Github actions yet, for which the Go
version is still hardcoded in multiple places.

Fixes #2606

Signed-off-by: Antonin Bas abas@vmware.com

@codecov-commenter
Copy link

codecov-commenter commented Aug 17, 2021

Codecov Report

Merging #2609 (2f10111) into main (f21f45e) will increase coverage by 0.03%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #2609      +/-   ##
==========================================
+ Coverage   60.75%   60.78%   +0.03%     
==========================================
  Files         285      285              
  Lines       23045    23045              
==========================================
+ Hits        14000    14009       +9     
+ Misses       7575     7570       -5     
+ Partials     1470     1466       -4     
Flag Coverage Δ
kind-e2e-tests 47.89% <ø> (+0.12%) ⬆️
unit-tests 41.69% <ø> (-0.03%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
pkg/apiserver/storage/ram/watch.go 90.38% <0.00%> (-3.85%) ⬇️
pkg/controller/grouping/controller.go 67.24% <0.00%> (-1.73%) ⬇️
pkg/monitor/controller.go 27.61% <0.00%> (-1.50%) ⬇️
pkg/agent/proxy/proxier.go 64.42% <0.00%> (+0.32%) ⬆️
pkg/agent/memberlist/cluster.go 72.81% <0.00%> (+0.48%) ⬆️
pkg/agent/util/net_linux.go 37.00% <0.00%> (+3.00%) ⬆️
pkg/controller/networkpolicy/status_controller.go 77.12% <0.00%> (+5.88%) ⬆️
pkg/version/version.go 46.15% <0.00%> (+7.69%) ⬆️

tnqn
tnqn previously approved these changes Aug 18, 2021
Copy link
Member

@tnqn tnqn left a comment

Choose a reason for hiding this comment

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

LGTM

@antoninbas
Copy link
Contributor Author

/test-all

Go 1.17 has just been released, which means that Go 1.15 will not be
actively maintained any more.

One notable change in Go 1.17 is that "pruned module graphs" are used:
https://golang.org/doc/go1.17#go-command. In Go 1.17, for the go command
to correctly resolve transitive imports using the pruned module graph,
the go.mod file for each module needs to include more detail about the
transitive dependencies relevant to that module. This leads to a second
require directive for modules that provide a transitively-imported
package. In previous versions, the go.mod file typically only included
explicit requirements for directly-imported packages.

The following command was used to update the go.mod (as suggested):
go-1.17 mod tidy -go=1.16 && go-1.17 mod tidy -go=1.17

I checked that the project could still be built using older Go versions:
GO=go-1.15 make bin
GO=go-1.16 make bin
GO=go-1.17 make bin

Another notable change is in the implementation of ParseIP and ParseCIDR
from the net package. These functions now reject IPv4 addresses which
contain decimal components with leading zeros. K8s is taking some extra
steps as they upgrade to Go 1.17 to ensure backwards-compatibility of
API resources which include IP fields and for which the contents of the
field are validated using the net stdlib functions. They are defining
their own versions of these functions, using code from the old version
of the standard library. In our case, we have decided not to follow in
K8s steps and we are sticking to the Go 1.17 standard library. Our
analysis has concluded that there is no reason to preserve past behavior
for network policies which use such IPv4 addresses. Note that these
policies will still be "valid" resources that users can delete /
update. But the Agent will reject the internal version of the policies
distributed by the Controller.

As part of this change, I also tried to have the current Go version be
defined in a "central" location to facilitate future updates.
Unfortunately this doesn't apply to Github actions yet, for which the Go
version is still hardcoded in multiple places.

Fixes antrea-io#2606

Signed-off-by: Antonin Bas <abas@vmware.com>
@antoninbas
Copy link
Contributor Author

@tnqn I rebased and need a new approval

@antoninbas antoninbas added this to the Antrea v1.3 release milestone Aug 23, 2021
@antoninbas
Copy link
Contributor Author

/test-all

@antoninbas antoninbas merged commit 7f448b0 into antrea-io:main Aug 24, 2021
@antoninbas antoninbas deleted the update-go-to-1.17 branch August 24, 2021 02:25
abdallahyas added a commit to abdallahyas/antrea that referenced this pull request Aug 24, 2021
Following antrea-io#2609 `docker build`
for the ubuntu image now requires the `GO_VERSION` to be passed, which
broke the Mellanox CI. This patch changes the Mellanox CI so that it would
use `make build-ubuntu` instead of using the `docker build` command so that
all changes to Makefile would not break CI.
abdallahyas added a commit to abdallahyas/antrea that referenced this pull request Aug 25, 2021
Following antrea-io#2609 `docker build`
for the ubuntu image now requires the `GO_VERSION` to be passed, which
broke the Mellanox CI. This patch changes the Mellanox CI so that it would
use `make build-ubuntu` instead of using the `docker build` command so that
all changes to Makefile would not break CI.
abdallahyas added a commit to abdallahyas/antrea that referenced this pull request Aug 30, 2021
Following antrea-io#2609 `docker build`
for the ubuntu image now requires the `GO_VERSION` to be passed, which
broke the Mellanox CI. This patch changes the Mellanox CI so that it would
use `make build-ubuntu` instead of using the `docker build` command so that
all changes to Makefile would not break CI.

Signed-off-by: abdallahyas <abdallahyas@mellanox.com>
antoninbas pushed a commit that referenced this pull request Aug 30, 2021
Following #2609 `docker build`
for the ubuntu image now requires the `GO_VERSION` to be passed, which
broke the Mellanox CI. This patch changes the Mellanox CI so that it would
use `make build-ubuntu` instead of using the `docker build` command so that
all changes to Makefile would not break CI.

Signed-off-by: abdallahyas <abdallahyas@mellanox.com>
antoninbas pushed a commit to antoninbas/antrea that referenced this pull request Aug 30, 2021
Following antrea-io#2609 `docker build`
for the ubuntu image now requires the `GO_VERSION` to be passed, which
broke the Mellanox CI. This patch changes the Mellanox CI so that it would
use `make build-ubuntu` instead of using the `docker build` command so that
all changes to Makefile would not break CI.

Signed-off-by: abdallahyas <abdallahyas@mellanox.com>
antoninbas added a commit that referenced this pull request Aug 30, 2021
Following #2609 `docker build`
for the ubuntu image now requires the `GO_VERSION` to be passed, which
broke the Mellanox CI. This patch changes the Mellanox CI so that it would
use `make build-ubuntu` instead of using the `docker build` command so that
all changes to Makefile would not break CI.

Signed-off-by: abdallahyas <abdallahyas@mellanox.com>

Co-authored-by: abdallahyas <abdallahyas@mellanox.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Update Go version to 1.17
3 participants