Skip to content

Commit

Permalink
Update Go to 1.17 (antrea-io#2609)
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
antoninbas authored Aug 24, 2021
1 parent 9e112d4 commit 7f448b0
Show file tree
Hide file tree
Showing 33 changed files with 301 additions and 95 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
bin/antctl-darwin
bin/antctl-linux
bin/antctl-windows.exe
test/e2e/infra
2 changes: 1 addition & 1 deletion .github/workflows/clair.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
with:
go-version: 1.15
go-version: 1.17
- name: Scan Antrea Docker image for vulnerabilities
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID_SES }}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ jobs:
if: ${{ github.actor == 'dependabot[bot]' && contains(github.event.pull_request.labels.*.name, 'dependencies') && contains(github.event.pull_request.labels.*.name, 'go') }}
runs-on: [ubuntu-latest]
steps:
- name: Set up Go 1.15
- name: Set up Go 1.17
uses: actions/setup-go@v2
with:
go-version: 1.15
go-version: 1.17
- uses: actions/checkout@v2
with:
# Check out the pull request HEAD
Expand Down
24 changes: 12 additions & 12 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ jobs:
os: [ubuntu-latest, windows-2019]
runs-on: ${{ matrix.os }}
steps:
- name: Set up Go 1.15
- name: Set up Go 1.17
uses: actions/setup-go@v2
with:
go-version: 1.15
go-version: 1.17
- name: Check-out code
uses: actions/checkout@v2
- uses: actions/cache@v2
Expand Down Expand Up @@ -57,10 +57,10 @@ jobs:
platform: [ubuntu-latest, macos-latest]
runs-on: ${{ matrix.platform }}
steps:
- name: Set up Go 1.15
- name: Set up Go 1.17
uses: actions/setup-go@v2
with:
go-version: 1.15
go-version: 1.17
- name: Check-out code
uses: actions/checkout@v2
- uses: actions/cache@v2
Expand All @@ -87,10 +87,10 @@ jobs:
name: Build Antrea and antctl binaries
runs-on: [ubuntu-latest]
steps:
- name: Set up Go 1.15
- name: Set up Go 1.17
uses: actions/setup-go@v2
with:
go-version: 1.15
go-version: 1.17
- name: Check-out code
uses: actions/checkout@v2
- uses: actions/cache@v2
Expand Down Expand Up @@ -120,10 +120,10 @@ jobs:
name: Build Antrea Windows binaries
runs-on: [ubuntu-latest]
steps:
- name: Set up Go 1.15
- name: Set up Go 1.17
uses: actions/setup-go@v2
with:
go-version: 1.15
go-version: 1.17
- name: Check-out code
uses: actions/checkout@v2
- uses: actions/cache@v2
Expand All @@ -147,10 +147,10 @@ jobs:
name: Check tidy, code generation and manifest
runs-on: [ubuntu-latest]
steps:
- name: Set up Go 1.15
- name: Set up Go 1.17
uses: actions/setup-go@v2
with:
go-version: 1.15
go-version: 1.17
- name: Check-out code
uses: actions/checkout@v2
# tidy check need to be run before code generation which will regenerate codes.
Expand All @@ -165,10 +165,10 @@ jobs:
name: Verify docs and spelling
runs-on: [ubuntu-latest]
steps:
- name: Set up Go 1.15
- name: Set up Go 1.17
uses: actions/setup-go@v2
with:
go-version: 1.15
go-version: 1.17
- name: Check-out code
uses: actions/checkout@v2
- name: Run verify scripts
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/golicense.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ jobs:
if: ${{ needs.check-changes.outputs.has_changes == 'yes' || github.event_name != 'pull_request' }}
runs-on: [ubuntu-latest]
steps:
- name: Set up Go 1.15
- name: Set up Go 1.17
uses: actions/setup-go@v2
with:
go-version: 1.15
go-version: 1.17
- uses: actions/checkout@v2
- name: Cache licensing information for dependencies
uses: actions/cache@v2
Expand Down
14 changes: 7 additions & 7 deletions .github/workflows/kind.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
with:
go-version: 1.15
go-version: 1.17
- name: Download Antrea image from previous job
uses: actions/download-artifact@v1
with:
Expand Down Expand Up @@ -141,7 +141,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
with:
go-version: 1.15
go-version: 1.17
- name: Download Antrea image from previous job
uses: actions/download-artifact@v1
with:
Expand Down Expand Up @@ -204,7 +204,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
with:
go-version: 1.15
go-version: 1.17
- name: Download Antrea image from previous job
uses: actions/download-artifact@v1
with:
Expand Down Expand Up @@ -267,7 +267,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
with:
go-version: 1.15
go-version: 1.17
- name: Download Antrea image from previous job
uses: actions/download-artifact@v1
with:
Expand Down Expand Up @@ -333,7 +333,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
with:
go-version: 1.15
go-version: 1.17
- name: Download Antrea image from previous job
uses: actions/download-artifact@v1
with:
Expand Down Expand Up @@ -396,7 +396,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
with:
go-version: 1.15
go-version: 1.17
- name: Download Antrea image from previous job
uses: actions/download-artifact@v1
with:
Expand Down Expand Up @@ -431,7 +431,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
with:
go-version: 1.15
go-version: 1.17
- name: Download Antrea image from previous job
uses: actions/download-artifact@v1
with:
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/kind_upgrade.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
with:
go-version: 1.15
go-version: 1.17
- name: Download Antrea image from previous job
uses: actions/download-artifact@v1
with:
Expand Down Expand Up @@ -101,7 +101,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
with:
go-version: 1.15
go-version: 1.17
- name: Download Antrea image from previous job
uses: actions/download-artifact@v1
with:
Expand Down Expand Up @@ -141,7 +141,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
with:
go-version: 1.15
go-version: 1.17
- name: Download Antrea image from previous job
uses: actions/download-artifact@v1
with:
Expand Down Expand Up @@ -181,7 +181,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
with:
go-version: 1.15
go-version: 1.17
- name: Download Antrea image from previous job
uses: actions/download-artifact@v1
with:
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ the `$GOPATH`.

To develop locally, you can follow these steps:

1. [Install Go 1.15](https://golang.org/doc/install)
1. [Install Go 1.17](https://golang.org/doc/install)
2. Checkout your feature branch and `cd` into it.
3. To build all Go files and install them under `bin`, run `make bin`
4. To run all Go unit tests, run `make test-unit`
Expand Down
38 changes: 21 additions & 17 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ GOPATH ?= $$($(GO) env GOPATH)
DOCKER_CACHE := $(CURDIR)/.cache
ANTCTL_BINARY_NAME ?= antctl
OVS_VERSION := $(shell head -n 1 build/images/deps/ovs-version)
GO_VERSION := $(shell head -n 1 build/images/deps/go-version)

DOCKER_BUILD_ARGS = --build-arg OVS_VERSION=$(OVS_VERSION)
DOCKER_BUILD_ARGS += --build-arg GO_VERSION=$(GO_VERSION)

.PHONY: all
all: build
Expand Down Expand Up @@ -128,7 +132,7 @@ DOCKER_ENV := \
-v $(DOCKER_CACHE)/gopath:/tmp/gopath \
-v $(DOCKER_CACHE)/gocache:/tmp/gocache \
-v $(CURDIR):/usr/src/antrea.io/antrea \
golang:1.15
golang:1.17

.PHONY: docker-bin
docker-bin: $(DOCKER_CACHE)
Expand All @@ -148,9 +152,9 @@ docker-test-unit: $(DOCKER_CACHE)
docker-test-integration: .coverage
@echo "===> Building Antrea Integration Test Docker image <==="
ifneq ($(NO_PULL),)
docker build -t antrea/test -f build/images/test/Dockerfile --build-arg OVS_VERSION=$(OVS_VERSION) .
docker build -t antrea/test -f build/images/test/Dockerfile $(DOCKER_BUILD_ARGS) .
else
docker build --pull -t antrea/test -f build/images/test/Dockerfile --build-arg OVS_VERSION=$(OVS_VERSION) .
docker build --pull -t antrea/test -f build/images/test/Dockerfile $(DOCKER_BUILD_ARGS) .
endif
@docker run --privileged --rm \
-e "GOCACHE=/tmp/gocache" \
Expand Down Expand Up @@ -273,9 +277,9 @@ codegen:
ubuntu:
@echo "===> Building antrea/antrea-ubuntu Docker image <==="
ifneq ($(NO_PULL),)
docker build -t antrea/antrea-ubuntu:$(DOCKER_IMG_VERSION) -f build/images/Dockerfile.ubuntu --build-arg OVS_VERSION=$(OVS_VERSION) .
docker build -t antrea/antrea-ubuntu:$(DOCKER_IMG_VERSION) -f build/images/Dockerfile.ubuntu $(DOCKER_BUILD_ARGS) .
else
docker build --pull -t antrea/antrea-ubuntu:$(DOCKER_IMG_VERSION) -f build/images/Dockerfile.ubuntu --build-arg OVS_VERSION=$(OVS_VERSION) .
docker build --pull -t antrea/antrea-ubuntu:$(DOCKER_IMG_VERSION) -f build/images/Dockerfile.ubuntu $(DOCKER_BUILD_ARGS) .
endif
docker tag antrea/antrea-ubuntu:$(DOCKER_IMG_VERSION) antrea/antrea-ubuntu
docker tag antrea/antrea-ubuntu:$(DOCKER_IMG_VERSION) projects.registry.vmware.com/antrea/antrea-ubuntu
Expand All @@ -286,9 +290,9 @@ endif
build-ubuntu:
@echo "===> Building Antrea bins and antrea/antrea-ubuntu Docker image <==="
ifneq ($(NO_PULL),)
docker build -t antrea/antrea-ubuntu:$(DOCKER_IMG_VERSION) -f build/images/Dockerfile.build.ubuntu --build-arg OVS_VERSION=$(OVS_VERSION) .
docker build -t antrea/antrea-ubuntu:$(DOCKER_IMG_VERSION) -f build/images/Dockerfile.build.ubuntu $(DOCKER_BUILD_ARGS) .
else
docker build --pull -t antrea/antrea-ubuntu:$(DOCKER_IMG_VERSION) -f build/images/Dockerfile.build.ubuntu --build-arg OVS_VERSION=$(OVS_VERSION) .
docker build --pull -t antrea/antrea-ubuntu:$(DOCKER_IMG_VERSION) -f build/images/Dockerfile.build.ubuntu $(DOCKER_BUILD_ARGS) .
endif
docker tag antrea/antrea-ubuntu:$(DOCKER_IMG_VERSION) antrea/antrea-ubuntu
docker tag antrea/antrea-ubuntu:$(DOCKER_IMG_VERSION) projects.registry.vmware.com/antrea/antrea-ubuntu
Expand All @@ -298,9 +302,9 @@ endif
build-windows:
@echo "===> Building Antrea bins and antrea/antrea-windows Docker image <==="
ifneq ($(NO_PULL),)
docker build -t antrea/antrea-windows:$(DOCKER_IMG_VERSION) -f build/images/Dockerfile.build.windows .
docker build -t antrea/antrea-windows:$(DOCKER_IMG_VERSION) -f build/images/Dockerfile.build.windows $(DOCKER_BUILD_ARGS) .
else
docker build --pull -t antrea/antrea-windows:$(DOCKER_IMG_VERSION) -f build/images/Dockerfile.build.windows .
docker build --pull -t antrea/antrea-windows:$(DOCKER_IMG_VERSION) -f build/images/Dockerfile.build.windows $(DOCKER_BUILD_ARGS) .
endif
docker tag antrea/antrea-windows:$(DOCKER_IMG_VERSION) antrea/antrea-windows
docker tag antrea/antrea-windows:$(DOCKER_IMG_VERSION) projects.registry.vmware.com/antrea/antrea-windows
Expand All @@ -310,16 +314,16 @@ endif
build-ubuntu-coverage:
@echo "===> Building Antrea bins and antrea/antrea-ubuntu-coverage Docker image <==="
ifneq ($(NO_PULL),)
docker build -t antrea/antrea-ubuntu-coverage:$(DOCKER_IMG_VERSION) -f build/images/Dockerfile.build.coverage --build-arg OVS_VERSION=$(OVS_VERSION) .
docker build -t antrea/antrea-ubuntu-coverage:$(DOCKER_IMG_VERSION) -f build/images/Dockerfile.build.coverage $(DOCKER_BUILD_ARGS) .
else
docker build --pull -t antrea/antrea-ubuntu-coverage:$(DOCKER_IMG_VERSION) -f build/images/Dockerfile.build.coverage --build-arg OVS_VERSION=$(OVS_VERSION) .
docker build --pull -t antrea/antrea-ubuntu-coverage:$(DOCKER_IMG_VERSION) -f build/images/Dockerfile.build.coverage $(DOCKER_BUILD_ARGS) .
endif
docker tag antrea/antrea-ubuntu-coverage:$(DOCKER_IMG_VERSION) antrea/antrea-ubuntu-coverage

.PHONY: build-scale-simulator
build-scale-simulator:
@echo "===> Building simulator bin and antrea-ubuntu-simulator image"
docker build -t antrea/antrea-ubuntu-simulator:$(DOCKER_IMG_VERSION) -f build/images/Dockerfile.simulator.build.ubuntu .
docker build -t antrea/antrea-ubuntu-simulator:$(DOCKER_IMG_VERSION) -f build/images/Dockerfile.simulator.build.ubuntu $(DOCKER_BUILD_ARGS) .
docker tag antrea/antrea-ubuntu-simulator:$(DOCKER_IMG_VERSION) antrea/antrea-ubuntu-simulator

.PHONY: manifest
Expand Down Expand Up @@ -348,7 +352,7 @@ manifest-coverage:
.PHONY: octant-antrea-ubuntu
octant-antrea-ubuntu:
@echo "===> Building antrea/octant-antrea-ubuntu Docker image <==="
docker build --pull -t antrea/octant-antrea-ubuntu:$(DOCKER_IMG_VERSION) -f build/images/Dockerfile.octant.ubuntu .
docker build --pull -t antrea/octant-antrea-ubuntu:$(DOCKER_IMG_VERSION) -f build/images/Dockerfile.octant.ubuntu $(DOCKER_BUILD_ARGS) .
docker tag antrea/octant-antrea-ubuntu:$(DOCKER_IMG_VERSION) antrea/octant-antrea-ubuntu
docker tag antrea/octant-antrea-ubuntu:$(DOCKER_IMG_VERSION) projects.registry.vmware.com/antrea/octant-antrea-ubuntu
docker tag antrea/octant-antrea-ubuntu:$(DOCKER_IMG_VERSION) projects.registry.vmware.com/antrea/octant-antrea-ubuntu:$(DOCKER_IMG_VERSION)
Expand All @@ -357,9 +361,9 @@ octant-antrea-ubuntu:
flow-aggregator-image:
@echo "===> Building antrea/flow-aggregator Docker image <==="
ifneq ($(NO_PULL),)
docker build -t antrea/flow-aggregator:$(DOCKER_IMG_VERSION) -f build/images/flow-aggregator/Dockerfile .
docker build -t antrea/flow-aggregator:$(DOCKER_IMG_VERSION) -f build/images/flow-aggregator/Dockerfile $(DOCKER_BUILD_ARGS) .
else
docker build --pull -t antrea/flow-aggregator:$(DOCKER_IMG_VERSION) -f build/images/flow-aggregator/Dockerfile .
docker build --pull -t antrea/flow-aggregator:$(DOCKER_IMG_VERSION) -f build/images/flow-aggregator/Dockerfile $(DOCKER_BUILD_ARGS) .
endif
docker tag antrea/flow-aggregator:$(DOCKER_IMG_VERSION) antrea/flow-aggregator
docker tag antrea/flow-aggregator:$(DOCKER_IMG_VERSION) projects.registry.vmware.com/antrea/flow-aggregator
Expand All @@ -369,9 +373,9 @@ endif
flow-aggregator-ubuntu-coverage:
@echo "===> Building antrea/flow-aggregator-coverage Docker image <==="
ifneq ($(NO_PULL),)
docker build -t antrea/flow-aggregator-coverage:$(DOCKER_IMG_VERSION) -f build/images/flow-aggregator/Dockerfile.coverage .
docker build -t antrea/flow-aggregator-coverage:$(DOCKER_IMG_VERSION) -f build/images/flow-aggregator/Dockerfile.coverage $(DOCKER_BUILD_ARGS) .
else
docker build --pull -t antrea/flow-aggregator-coverage:$(DOCKER_IMG_VERSION) -f build/images/flow-aggregator/Dockerfile.coverage .
docker build --pull -t antrea/flow-aggregator-coverage:$(DOCKER_IMG_VERSION) -f build/images/flow-aggregator/Dockerfile.coverage $(DOCKER_BUILD_ARGS) .
endif
docker tag antrea/flow-aggregator-coverage:$(DOCKER_IMG_VERSION) antrea/flow-aggregator-coverage

Expand Down
3 changes: 2 additions & 1 deletion build/images/Dockerfile.build.coverage
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
ARG GO_VERSION
ARG OVS_VERSION
FROM golang:1.15 as antrea-build
FROM golang:${GO_VERSION} as antrea-build

WORKDIR /antrea

Expand Down
3 changes: 2 additions & 1 deletion build/images/Dockerfile.build.ubuntu
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
ARG GO_VERSION
ARG OVS_VERSION
FROM golang:1.15 as antrea-build
FROM golang:${GO_VERSION} as antrea-build

WORKDIR /antrea

Expand Down
3 changes: 2 additions & 1 deletion build/images/Dockerfile.build.windows
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
ARG GO_VERSION
FROM mcr.microsoft.com/powershell:lts-nanoserver-1809 as cni-binaries-windows
SHELL ["pwsh", "-NoLogo", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]

Expand All @@ -10,7 +11,7 @@ RUN curl.exe -LO https://github.com/containernetworking/plugins/releases/downloa
rm cni-plugins-windows-amd64-v0.8.1.tgz


FROM golang:1.15 as antrea-build-windows
FROM golang:${GO_VERSION} as antrea-build-windows

WORKDIR /

Expand Down
3 changes: 2 additions & 1 deletion build/images/Dockerfile.octant.ubuntu
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
FROM golang:1.15 as antrea-build
ARG GO_VERSION
FROM golang:${GO_VERSION} as antrea-build

COPY . /antrea

Expand Down
3 changes: 2 additions & 1 deletion build/images/Dockerfile.simulator.build.ubuntu
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
FROM golang:1.15 as antrea-build
ARG GO_VERSION
FROM golang:${GO_VERSION} as antrea-build

WORKDIR /antrea

Expand Down
Loading

0 comments on commit 7f448b0

Please sign in to comment.