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

Remove the additional route map cidr default value #134

Merged
merged 4 commits into from
Nov 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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