Skip to content

Commit

Permalink
Remove the additional route map cidr default value (#134)
Browse files Browse the repository at this point in the history
  • Loading branch information
majst01 authored Nov 25, 2024
1 parent dcbe18b commit d8c102d
Show file tree
Hide file tree
Showing 12 changed files with 119 additions and 125 deletions.
1 change: 0 additions & 1 deletion cmd/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,4 @@ type Config struct {
GrpcClientCertFile string `required:"false" desc:"the gRPC client certificate file" envconfig:"grpc_client_cert_file"`
GrpcClientKeyFile string `required:"false" desc:"the gRPC client key file" envconfig:"grpc_client_key_file"`
PXEVlanID uint16 `required:"false" default:"4000" desc:"the id of the pxe vlan" envconfig:"pxe_vlan_id"`
AdditionalRouteMapCIDRs []string `required:"false" default:"10.240.0.0/12" desc:"additional route map entries, typically the pod/service CIDRs, one or more CIDR for ipv4 or ipv6, separated by comma" envconfig:"additional_route_map_cidrs"`
}
7 changes: 2 additions & 5 deletions cmd/internal/core/core.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ type Core struct {

metrics *metrics.Metrics

pxeVlanID uint16
additionalRouteMapCIDRs []string
pxeVlanID uint16
}

type Config struct {
Expand All @@ -60,8 +59,7 @@ type Config struct {

Metrics *metrics.Metrics

PXEVlanID uint16
AdditionalRouteMapCIDRs []string
PXEVlanID uint16
}

func New(c Config) *Core {
Expand All @@ -84,6 +82,5 @@ func New(c Config) *Core {
eventServiceClient: c.EventServiceClient,
metrics: c.Metrics,
pxeVlanID: c.PXEVlanID,
additionalRouteMapCIDRs: c.AdditionalRouteMapCIDRs,
}
}
15 changes: 7 additions & 8 deletions cmd/internal/core/reconfigure-switch.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,14 +124,13 @@ func (c *Core) buildSwitcherConfig(s *models.V1SwitchResponse) (*types.Conf, err
}

switcherConfig := &types.Conf{
Name: s.Name,
LogLevel: mapLogLevel(c.logLevel),
ASN: uint32(asn64), // nolint:gosec
Loopback: c.loopbackIP,
MetalCoreCIDR: c.cidr,
AdditionalBridgeVIDs: c.additionalBridgeVIDs,
PXEVlanID: c.pxeVlanID,
AdditionalRouteMapCIDRs: c.additionalRouteMapCIDRs,
Name: s.Name,
LogLevel: mapLogLevel(c.logLevel),
ASN: uint32(asn64), // nolint:gosec
Loopback: c.loopbackIP,
MetalCoreCIDR: c.cidr,
AdditionalBridgeVIDs: c.additionalBridgeVIDs,
PXEVlanID: c.pxeVlanID,
}

p := types.Ports{
Expand Down
31 changes: 17 additions & 14 deletions cmd/internal/core/reconfigure-switch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,14 @@ import (

func TestBuildSwitcherConfig(t *testing.T) {
c := &Core{
cidr: "10.255.255.2/24",
partitionID: "fra-equ01",
rackID: "rack01",
asn: "420000001",
loopbackIP: "10.0.0.1",
spineUplinks: []string{"swp31", "swp32"},
additionalBridgeVIDs: []string{"201-256", "301-356"},
nos: &cumulus.Cumulus{},
additionalRouteMapCIDRs: []string{"10.240.0.0/12"},
cidr: "10.255.255.2/24",
partitionID: "fra-equ01",
rackID: "rack01",
asn: "420000001",
loopbackIP: "10.0.0.1",
spineUplinks: []string{"swp31", "swp32"},
additionalBridgeVIDs: []string{"201-256", "301-356"},
nos: &cumulus.Cumulus{},
}

n1 := "swp1"
Expand All @@ -35,6 +34,11 @@ func TestBuildSwitcherConfig(t *testing.T) {
Name: &n2,
Mac: &m2,
Vrf: "vrf104001",
Filter: &models.V1BGPFilter{
Cidrs: []string{
"10.240.0.0/12", // pod ipv4 cidrs
},
},
}
n3 := "swp3"
m3 := "00:00:00:00:00:03"
Expand All @@ -54,11 +58,10 @@ func TestBuildSwitcherConfig(t *testing.T) {
require.NoError(t, err)
require.NotNil(t, actual)
expected := &types.Conf{
LogLevel: "warnings",
Loopback: "10.0.0.1",
MetalCoreCIDR: "10.255.255.2/24",
ASN: 420000001,
AdditionalRouteMapCIDRs: []string{"10.240.0.0/12"},
LogLevel: "warnings",
Loopback: "10.0.0.1",
MetalCoreCIDR: "10.255.255.2/24",
ASN: 420000001,
Ports: types.Ports{
DownPorts: map[string]bool{},
Underlay: []string{"swp31", "swp32"},
Expand Down
5 changes: 2 additions & 3 deletions cmd/internal/switcher/templates/test_data/dev/conf.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ loglevel: warnings
loopback: 10.0.0.10
asn: 4200000010
metalcorecidr: 10.255.255.2/24
additionalroutemapcidrs:
- "10.240.0.0/12"
- "fd00:10::/64"
ports:
eth0:
addresscidr: 192.168.101.12/24
Expand Down Expand Up @@ -40,6 +37,8 @@ ports:
- "100.127.131.0/24"
- "212.17.234.17/32"
- "2001:db8:3::1/128"
- "10.240.0.0/12" # pod and service ipv4 cidrs
- "fd00:10::/64" # pod and service ipv6 cidrs
additionalbridgevids:
- 201-256
- 301-356
Expand Down
4 changes: 2 additions & 2 deletions cmd/internal/switcher/templates/test_data/lab/conf.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ loglevel: debugging
loopback: 10.0.0.10
asn: 4200000010
metalcorecidr: 10.255.255.2/24
additionalroutemapcidrs:
- "10.240.0.0/12"
ports:
eth0:
addresscidr: 192.168.0.11
Expand All @@ -32,4 +30,6 @@ ports:
neighbors:
- swp1
- swp2
cidrs:
- "10.240.0.0/12" # pod and service ipv4 cidrs
pxevlanid: 966
2 changes: 0 additions & 2 deletions cmd/internal/switcher/templates/test_data/notenants/conf.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ loglevel: warnings
loopback: 10.0.0.10
asn: 4200000010
metalcorecidr: 10.255.255.2/24
additionalroutemapcidrs:
- "10.240.0.0/12"
ports:
eth0:
addresscidr: 192.168.0.11
Expand Down
2 changes: 0 additions & 2 deletions cmd/internal/switcher/types/conf.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ func (c *Conf) FillRouteMapsAndIPPrefixLists() error {
f.Assemble("fw-"+port, f.Vnis, f.Cidrs)
}
for vrf, t := range c.Ports.Vrfs {
t.Cidrs = append(t.Cidrs, c.AdditionalRouteMapCIDRs...)

var err error
t.Cidrs, err = compactCidrs(t.Cidrs)
if err != nil {
Expand Down
17 changes: 8 additions & 9 deletions cmd/internal/switcher/types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,14 @@ import (

// Conf holds the switch configuration
type Conf struct {
Name string
LogLevel string
Loopback string
ASN uint32
Ports Ports
MetalCoreCIDR string
AdditionalBridgeVIDs []string
PXEVlanID uint16
AdditionalRouteMapCIDRs []string
Name string
LogLevel string
Loopback string
ASN uint32
Ports Ports
MetalCoreCIDR string
AdditionalBridgeVIDs []string
PXEVlanID uint16
}

type Ports struct {
Expand Down
1 change: 0 additions & 1 deletion cmd/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ func Run() {
EventServiceClient: grpcClient.NewEventClient(),
Metrics: metrics,
PXEVlanID: cfg.PXEVlanID,
AdditionalRouteMapCIDRs: cfg.AdditionalRouteMapCIDRs,
})

err = c.RegisterSwitch()
Expand Down
54 changes: 27 additions & 27 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
module github.com/metal-stack/metal-core

go 1.23
go 1.23.0

require (
github.com/avast/retry-go/v4 v4.6.0
github.com/coreos/go-systemd/v22 v22.5.0
github.com/go-redis/redismock/v9 v9.2.0
github.com/google/go-cmp v0.6.0
github.com/kelseyhightower/envconfig v1.4.0
github.com/metal-stack/go-lldpd v0.4.7
github.com/metal-stack/metal-api v0.34.0
github.com/metal-stack/metal-go v0.34.0
github.com/metal-stack/go-lldpd v0.4.8
github.com/metal-stack/metal-api v0.39.4
github.com/metal-stack/metal-go v0.39.4
github.com/metal-stack/v v1.0.3
github.com/prometheus/client_golang v1.20.2
github.com/redis/go-redis/v9 v9.6.1
github.com/stretchr/testify v1.9.0
github.com/prometheus/client_golang v1.20.5
github.com/redis/go-redis/v9 v9.7.0
github.com/stretchr/testify v1.10.0
github.com/vishvananda/netlink v1.3.0
go4.org/netipx v0.0.0-20231129151722-fdeea329fbba
golang.org/x/text v0.18.0
google.golang.org/grpc v1.66.0
google.golang.org/protobuf v1.34.2
golang.org/x/text v0.20.0
google.golang.org/grpc v1.68.0
google.golang.org/protobuf v1.35.2
gopkg.in/yaml.v3 v3.0.1
)

Expand All @@ -46,41 +46,41 @@ require (
github.com/go-openapi/validate v0.24.0 // indirect
github.com/goccy/go-json v0.10.3 // indirect
github.com/godbus/dbus/v5 v5.1.1-0.20230522191255-76236955d466 // indirect
github.com/golang-jwt/jwt/v4 v4.5.0 // indirect
github.com/golang-jwt/jwt/v5 v5.2.1 // indirect
github.com/google/gopacket v1.1.19 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/gorilla/mux v1.8.1 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/klauspost/compress v1.17.9 // indirect
github.com/klauspost/compress v1.17.11 // indirect
github.com/lestrrat-go/blackmagic v1.0.2 // indirect
github.com/lestrrat-go/httpcc v1.0.1 // indirect
github.com/lestrrat-go/httprc v1.0.6 // indirect
github.com/lestrrat-go/iter v1.0.2 // indirect
github.com/lestrrat-go/jwx/v2 v2.1.1 // indirect
github.com/lestrrat-go/jwx/v2 v2.1.3 // indirect
github.com/lestrrat-go/option v1.0.1 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/mdlayher/ethernet v0.0.0-20220221185849-529eae5b6118 // indirect
github.com/mdlayher/lldp v0.0.0-20150915211757-afd9f83164c5 // indirect
github.com/metal-stack/metal-lib v0.18.1 // indirect
github.com/metal-stack/security v0.8.1 // indirect
github.com/metal-stack/metal-lib v0.19.0 // indirect
github.com/metal-stack/security v0.9.0 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/oklog/ulid v1.3.1 // indirect
github.com/opentracing/opentracing-go v1.2.0 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/prometheus/client_model v0.6.1 // indirect
github.com/prometheus/common v0.58.0 // indirect
github.com/prometheus/common v0.60.1 // indirect
github.com/prometheus/procfs v0.15.1 // indirect
github.com/segmentio/asm v1.2.0 // indirect
github.com/vishvananda/netns v0.0.4 // indirect
go.mongodb.org/mongo-driver v1.16.1 // indirect
go.opentelemetry.io/otel v1.29.0 // indirect
go.opentelemetry.io/otel/metric v1.29.0 // indirect
go.opentelemetry.io/otel/trace v1.29.0 // indirect
golang.org/x/crypto v0.26.0 // indirect
golang.org/x/net v0.28.0 // indirect
golang.org/x/oauth2 v0.23.0 // indirect
golang.org/x/sync v0.8.0 // indirect
golang.org/x/sys v0.25.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240903143218-8af14fe29dc1 // indirect
github.com/vishvananda/netns v0.0.5 // indirect
go.mongodb.org/mongo-driver v1.17.1 // indirect
go.opentelemetry.io/otel v1.32.0 // indirect
go.opentelemetry.io/otel/metric v1.32.0 // indirect
go.opentelemetry.io/otel/trace v1.32.0 // indirect
golang.org/x/crypto v0.29.0 // indirect
golang.org/x/net v0.31.0 // indirect
golang.org/x/oauth2 v0.24.0 // indirect
golang.org/x/sync v0.9.0 // indirect
golang.org/x/sys v0.27.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20241118233622-e639e219e697 // indirect
)
Loading

0 comments on commit d8c102d

Please sign in to comment.