Skip to content

Commit

Permalink
Merge branch 'main' into dependabot/go_modules/github.com/onsi/gomega…
Browse files Browse the repository at this point in the history
…-1.32.0
  • Loading branch information
mcbenjemaa authored Apr 3, 2024
2 parents b8b9039 + f57cdbf commit 29360a4
Show file tree
Hide file tree
Showing 6 changed files with 105 additions and 45 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ jobs:
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.event.pull_request.head.ref }}

- uses: webiny/[email protected]
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
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Build the manager binary
FROM golang:1.20 AS builder
FROM golang:1.21 AS builder
ARG TARGETOS
ARG TARGETARCH

Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion docs/Development.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions pkg/cloudinit/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand All @@ -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 }}
Expand Down
130 changes: 92 additions & 38 deletions pkg/cloudinit/network_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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) {
Expand Down Expand Up @@ -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{
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 29360a4

Please sign in to comment.