From cd732299be33df6b8a650d00ec01ec33cb2a3a72 Mon Sep 17 00:00:00 2001 From: Mohamed Chiheb Ben Jemaa Date: Wed, 3 Apr 2024 00:21:49 +0200 Subject: [PATCH 1/9] Clean kind clusters after e2e --- .github/workflows/e2e.yml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index 6f5f6004..bfdb4d9f 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -11,6 +11,7 @@ jobs: e2e: runs-on: [capmox,e2e,dcd-playground] environment: e2e + continue-on-error: true # to make sure post runs env: PROXMOX_URL: ${{ secrets.PROXMOX_URL }} PROXMOX_TOKEN: ${{ secrets.PROXMOX_TOKEN }} @@ -33,3 +34,11 @@ jobs: - name: Run e2e tests run: "make test-e2e" + + post: + runs-on: [capmox,e2e,dcd-playground] + environment: e2e + steps: + - name: cleanup kind clusters + run: | + kind get clusters | xargs kind delete cluster --name \ No newline at end of file From 4c5d8809139b36262b8702123b94a3fbd1870026 Mon Sep 17 00:00:00 2001 From: Mohamed Chiheb Ben Jemaa Date: Wed, 3 Apr 2024 01:00:29 +0200 Subject: [PATCH 2/9] Update e2e.yml --- .github/workflows/e2e.yml | 9 --------- 1 file changed, 9 deletions(-) diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index bfdb4d9f..6f5f6004 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -11,7 +11,6 @@ jobs: e2e: runs-on: [capmox,e2e,dcd-playground] environment: e2e - continue-on-error: true # to make sure post runs env: PROXMOX_URL: ${{ secrets.PROXMOX_URL }} PROXMOX_TOKEN: ${{ secrets.PROXMOX_TOKEN }} @@ -34,11 +33,3 @@ jobs: - name: Run e2e tests run: "make test-e2e" - - post: - runs-on: [capmox,e2e,dcd-playground] - environment: e2e - steps: - - name: cleanup kind clusters - run: | - kind get clusters | xargs kind delete cluster --name \ No newline at end of file From fac5f9c7cd1ae0fea54db7f7c5acf97d1b95aaaa Mon Sep 17 00:00:00 2001 From: "Felix Wischke (65278)" Date: Sun, 31 Mar 2024 22:46:35 +0200 Subject: [PATCH 3/9] cloudinit: fix multiple vrf device templating --- pkg/cloudinit/network.go | 8 +-- pkg/cloudinit/network_test.go | 130 ++++++++++++++++++++++++---------- 2 files changed, 96 insertions(+), 42 deletions(-) diff --git a/pkg/cloudinit/network.go b/pkg/cloudinit/network.go index 27e941d9..0f72cb22 100644 --- a/pkg/cloudinit/network.go +++ b/pkg/cloudinit/network.go @@ -41,17 +41,17 @@ const ( {{- end }} {{- if and $element.IPV6Address (not $element.DHCP6)}} - '{{ $element.IPV6Address }}' - {{- end }} + {{- end }} {{- if or (and $element.Gateway (not $element.DHCP4)) (and $element.Gateway6 (not $element.DHCP6)) }} routes: {{- if and $element.Gateway (not $element.DHCP4) }} - to: 0.0.0.0/0 via: {{ $element.Gateway }} - {{- end }} + {{- end }} {{- if and $element.Gateway6 (not $element.DHCP6) }} - to: '::/0' via: '{{ $element.Gateway6 }}' - {{- end }} + {{- end }} {{- end }} {{- end }} {{- if $element.DNSServers }} @@ -68,7 +68,7 @@ const ( {{- if eq $element.Type "vrf" }} {{- if eq $vrf 0 }} vrfs: - {{- $vrf := 1 }} + {{- $vrf = 1 }} {{- end }} {{$element.Name}}: table: {{ $element.Table }} diff --git a/pkg/cloudinit/network_test.go b/pkg/cloudinit/network_test.go index 8a54bffa..f6eb9d11 100644 --- a/pkg/cloudinit/network_test.go +++ b/pkg/cloudinit/network_test.go @@ -237,17 +237,7 @@ const ( - eth0 - eth1` - expectedValidNetworkConfigValidFIBRule = `network: - version: 2 - renderer: networkd - ethernets: - vrfs: - vrf-blue: - table: 500 - routing-policy: - - { "from": "10.10.0.0/16", }` - - expectedValidNetworkNotGateway = `network: + expectedValidNetworkConfigMultipleNicsMultipleVRF = `network: version: 2 renderer: networkd ethernets: @@ -272,10 +262,39 @@ const ( dhcp6: false addresses: - 196.168.100.124/24 + routes: + - to: 0.0.0.0/0 + via: 196.168.100.254 nameservers: addresses: - '8.8.8.8' - - '8.8.4.4'` + - '8.8.4.4' + vrfs: + vrf-blue: + table: 500 + routes: + - { "to": "default", "via": "192.168.178.1", "metric": 100, "table": 100, } + - { "to": "10.10.10.0/24", "via": "192.168.178.254", "metric": 100, } + routing-policy: + - { "to": "0.0.0.0/0", "from": "192.168.178.1/24", "priority": 999, "table": 100, } + interfaces: + - eth0 + vrf-red: + table: 501 + routing-policy: + - { "to": "0.0.0.0/0", "from": "192.168.100.0/24", "priority": 999, "table": 101, } + interfaces: + - eth1` + + expectedValidNetworkConfigValidFIBRule = `network: + version: 2 + renderer: networkd + ethernets: + vrfs: + vrf-blue: + table: 500 + routing-policy: + - { "from": "10.10.0.0/16", }` ) func TestNetworkConfig_Render(t *testing.T) { @@ -625,6 +644,67 @@ func TestNetworkConfig_Render(t *testing.T) { err: nil, }, }, + "ValidNetworkConfigMultipleNicsMultipleVRF": { + reason: "valid config multiple nics enslaved to multiple VRFs", + args: args{ + nics: []NetworkConfigData{ + { + Type: "ethernet", + Name: "eth0", + MacAddress: "92:60:a0:5b:22:c2", + IPAddress: "10.10.10.12/24", + Gateway: "10.10.10.1", + DNSServers: []string{"8.8.8.8", "8.8.4.4"}, + }, + { + Type: "ethernet", + Name: "eth1", + MacAddress: "b4:87:18:bf:a3:60", + IPAddress: "196.168.100.124/24", + Gateway: "196.168.100.254", + DNSServers: []string{"8.8.8.8", "8.8.4.4"}, + }, + { + Type: "vrf", + Name: "vrf-blue", + Table: 500, + Interfaces: []string{"eth0"}, + Routes: []RoutingData{{ + To: "default", + Via: "192.168.178.1", + Metric: 100, + Table: 100, + }, { + To: "10.10.10.0/24", + Via: "192.168.178.254", + Metric: 100, + }}, + FIBRules: []FIBRuleData{{ + To: "0.0.0.0/0", + From: "192.168.178.1/24", + Priority: 999, + Table: 100, + }}, + }, + { + Type: "vrf", + Name: "vrf-red", + Table: 501, + Interfaces: []string{"eth1"}, + FIBRules: []FIBRuleData{{ + To: "0.0.0.0/0", + From: "192.168.100.0/24", + Priority: 999, + Table: 101, + }}, + }, + }, + }, + want: want{ + network: expectedValidNetworkConfigMultipleNicsMultipleVRF, + err: nil, + }, + }, "ValidNetworkConfigValidFIBRule": { reason: "valid config valid routing policy", args: args{ @@ -664,32 +744,6 @@ func TestNetworkConfig_Render(t *testing.T) { err: ErrMalformedRoute, }, }, - "AdditionalNicNoGateway": { - reason: "missing route is okay", - args: args{ - nics: []NetworkConfigData{ - { - Type: "ethernet", - Name: "eth0", - MacAddress: "92:60:a0:5b:22:c2", - IPAddress: "10.10.10.12/24", - Gateway: "10.10.10.1", - DNSServers: []string{"8.8.8.8", "8.8.4.4"}, - }, - { - Type: "ethernet", - Name: "eth1", - MacAddress: "b4:87:18:bf:a3:60", - IPAddress: "196.168.100.124/24", - DNSServers: []string{"8.8.8.8", "8.8.4.4"}, - }, - }, - }, - want: want{ - network: expectedValidNetworkNotGateway, - err: nil, - }, - }, } for n, tc := range cases { From 99c3d1d2308e3cae550694649f2072750c62f1c1 Mon Sep 17 00:00:00 2001 From: Mohamed Chiheb Ben Jemaa Date: Wed, 3 Apr 2024 11:35:49 +0200 Subject: [PATCH 4/9] Add post run to cleanup kind clusters from e2e runner (#164) * Update e2e.yml * Update e2e.yml --- .github/workflows/e2e.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index 6f5f6004..a1cf68df 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -27,6 +27,13 @@ jobs: repository: ${{ github.event.pull_request.head.repo.full_name }} ref: ${{ github.event.pull_request.head.ref }} + - uses: webiny/action-post-run@3.1.0 + name: Cleanup kind clusters + id: post-run + with: + run: | + kind get clusters | xargs -I% kind delete cluster --name % + - uses: actions/setup-go@v5 with: go-version-file: go.mod From 0fa73f200a93a912fbadc1e45e9edc625e616edc Mon Sep 17 00:00:00 2001 From: Mohamed Chiheb Ben Jemaa Date: Wed, 3 Apr 2024 12:49:46 +0200 Subject: [PATCH 5/9] Update e2e.yml --- .github/workflows/e2e.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index a1cf68df..bfbe1f28 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -31,8 +31,7 @@ jobs: name: Cleanup kind clusters id: post-run with: - run: | - kind get clusters | xargs -I% kind delete cluster --name % + run: "kind get clusters | xargs -I% kind delete cluster --name %" - uses: actions/setup-go@v5 with: From 6f6303b0c014d930ab0cbd8045867c88462b9bc2 Mon Sep 17 00:00:00 2001 From: "Felix Wischke (65278)" Date: Sun, 31 Mar 2024 23:04:33 +0200 Subject: [PATCH 6/9] Makefile: fix setup-envtest to latest version supporting 1.21 --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 255b4a0d..b3e1ca64 100644 --- a/Makefile +++ b/Makefile @@ -203,7 +203,7 @@ $(CONTROLLER_GEN): $(LOCALBIN) .PHONY: envtest envtest: $(ENVTEST) ## Download envtest-setup locally if necessary. $(ENVTEST): $(LOCALBIN) - test -s $(LOCALBIN)/setup-envtest || GOBIN=$(LOCALBIN) go install sigs.k8s.io/controller-runtime/tools/setup-envtest@latest + test -s $(LOCALBIN)/setup-envtest || GOBIN=$(LOCALBIN) go install sigs.k8s.io/controller-runtime/tools/setup-envtest@v0.0.0-20240208111015-5923139bc5bd ##@ Test From 89e12917350bb87f76f4ed59c43daf0f89037c9b Mon Sep 17 00:00:00 2001 From: "Felix Wischke (65278)" Date: Sun, 31 Mar 2024 23:14:22 +0200 Subject: [PATCH 7/9] docs: update to golang 1.21 --- docs/Development.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/Development.md b/docs/Development.md index f3915436..30a82ab9 100644 --- a/docs/Development.md +++ b/docs/Development.md @@ -33,7 +33,7 @@ The following dependencies are required to setup a development environment: - git - make -- Go v1.20 (newer versions break testing) +- Go v1.21 (newer versions break testing) - Kubebuilder (only required for making new controllers) - Docker (required for Kind) - Tilt From 361d8954667afbd552e1e9824d3a181a5ab4a7e8 Mon Sep 17 00:00:00 2001 From: "Felix Wischke (65278)" Date: Sun, 31 Mar 2024 23:14:32 +0200 Subject: [PATCH 8/9] Dockerfile: update to golang 1.21 --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 05ca5698..ff107dfd 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ # Build the manager binary -FROM golang:1.20 AS builder +FROM golang:1.21 AS builder ARG TARGETOS ARG TARGETARCH From f57cdbf5eb12faa7ecd7c7d9034b41280d292a9c Mon Sep 17 00:00:00 2001 From: Vic Kerr Date: Wed, 3 Apr 2024 12:22:04 +0000 Subject: [PATCH 9/9] e2e: fix cleanup (?) 0fa73f200a93a912fbadc1e45e9edc625e616edc did not fix it --- .github/workflows/e2e.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index bfbe1f28..9c48dc06 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -31,7 +31,7 @@ jobs: name: Cleanup kind clusters id: post-run with: - run: "kind get clusters | xargs -I% kind delete cluster --name %" + run: "kind get clusters | xargs -I % kind delete cluster --name %" - uses: actions/setup-go@v5 with: