-
Notifications
You must be signed in to change notification settings - Fork 12
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
Tie up the API with the FRR configuration mechanism #4
Conversation
internal/metrics/metrics.go
Outdated
} | ||
|
||
var ( | ||
Namespace = "metallb" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: frr-k8s?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
internal/metrics/metrics.go
Outdated
SessionUp = metric{ | ||
Name: "session_up", | ||
Help: "BGP session state (1 is up, 0 is down)", | ||
} | ||
|
||
UpdatesSent = metric{ | ||
Name: "updates_total", | ||
Help: "Number of BGP UPDATE messages sent", | ||
} | ||
|
||
Prefixes = metric{ | ||
Name: "announced_prefixes_total", | ||
Help: "Number of prefixes currently being advertised on the BGP session", | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should this be closer to the exporter or we're treating this package as the one containing all of the different metrics? if it's an option I think it makes more sense to separate the metrics the exporter is in charge of vs. the ones that actually relate to the "frr-k8s" controller (which we don't have any at this point?).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
makes sense, I copied from metallb but here we don't have the legacy bgp, so these can be moved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
internal/ipfamily/ipfamily.go
Outdated
if ip.To4() != nil { | ||
return IPv4, nil | ||
} | ||
return IPv6, nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can call ForAddress here.
internal/ipfamily/ipfamily.go
Outdated
type Family string | ||
|
||
func (f Family) String() string { | ||
return string(f) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can use type alias here instead (type Family = string)
and remove the String() func.
|
||
var ( | ||
sessionUpDesc = prometheus.NewDesc( | ||
prometheus.BuildFQName(Namespace, Subsystem, SessionUp.Name), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are we missing here the Namespace const definition and SessiopUp?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah I moved the file but forgot to commit it. Let me fix
internal/metrics/metrics.go
Outdated
var ( | ||
Namespace = "frr-k8s" | ||
Subsystem = "bgp" | ||
|
||
SessionUp = metric{ | ||
Name: "session_up", | ||
Help: "BGP session state (1 is up, 0 is down)", | ||
} | ||
|
||
UpdatesSent = metric{ | ||
Name: "updates_total", | ||
Help: "Number of BGP UPDATE messages sent", | ||
} | ||
|
||
Prefixes = metric{ | ||
Name: "announced_prefixes_total", | ||
Help: "Number of prefixes currently being advertised on the BGP session", | ||
} | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we still use those variables
6007f37
to
5f0394c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
found some nits in function comments, error logs, etc.
all the rest looks good
delete(expected, d) | ||
} | ||
if len(expected) > 0 { | ||
logger.Log("daemons not running. got: ", res, "missing: ", res) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in this log, we want to have the expected
map's keys after the "missing"
empty := frrk8sv1beta1.FRRConfiguration{} | ||
config, err := apiToFRR(empty) | ||
if err != nil { | ||
level.Error(r.Logger).Log("controller", "FRRConfigurationReconciler", "failed to translate the empty config", req.NamespacedName.String()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this log and the ones below are not printing the error
internal/frr/frr.go
Outdated
|
||
lastReloadStatus := strings.Fields(string(bytes)) | ||
if len(lastReloadStatus) != 2 { | ||
level.Error(l).Log("op", "reload-validate", "error", err, "cause", "Fields", "bytes", string(bytes)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we need to re-write this one. err is nil here. it's more of an invalid format error.
internal/frr/parse.go
Outdated
// parseRoute takes the result of a show bgp neighbor | ||
// and parses the informations related to all the neighbours. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a copy-paste from the function above
internal/ipfamily/ipfamily.go
Outdated
return ForAddresses(ipsStrings...) | ||
} | ||
|
||
// ForCIDR returns the address family from a given CIDR. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// ForCIDR returns the address family from a given CIDR. | |
// ForCIDRString returns the address family from a given CIDR string. |
internal/ipfamily/ipfamily_test.go
Outdated
family: IPv6, | ||
}, | ||
{ | ||
desc: "ipv4 and ipv6 addresse", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
desc: "ipv4 and ipv6 addresse", | |
desc: "ipv4 and ipv6 addresses", |
internal/ipfamily/ipfamily_test.go
Outdated
family: IPv6, | ||
}, | ||
{ | ||
desc: "ipv4 and ipv6 addresse", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
desc: "ipv4 and ipv6 addresse", | |
desc: "ipv4 and ipv6 addresses", |
)) | ||
|
||
}) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
extra newline
Routers: []*frr.RouterConfig{}, | ||
}, | ||
)) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
extra newline
Adding various utility packages stolen form metallb Signed-off-by: Federico Paolinelli <[email protected]>
The FRR module is implemented the same way (copied) as MetalLB. The only difference is the starting point, which is the frr-k8s api. We have a translation layer that takes the FRR-K8s config, then translates it, and then generate the FRR configuration and calls the reloader script. Signed-off-by: Federico Paolinelli <[email protected]>
Signed-off-by: Federico Paolinelli <[email protected]>
Signed-off-by: Federico Paolinelli <[email protected]>
Here we add the same containers we had in MetalLB and we change the dockerfile accordingly. Signed-off-by: Federico Paolinelli <[email protected]>
Add a dev-env like script that configures both the external container and the frr-k8s configuration. Signed-off-by: Federico Paolinelli <[email protected]>
Signed-off-by: Federico Paolinelli <[email protected]>
This will make easier to test the controller by injecting a mock frr handler. Signed-off-by: Federico Paolinelli <[email protected]>
This is meant to test only the controller behaviour, to see if it reacts correctly to the events. Testing of the conversion of the api should not depend on the api server. Signed-off-by: Federico Paolinelli <[email protected]>
Here we unit test the conversion function. Signed-off-by: Federico Paolinelli <[email protected]>
The flag was not implemented, here we cover with a test and support it. Signed-off-by: Federico Paolinelli <[email protected]>
@liornoy I think I fixed all the suggestions |
/lgtm |
Here we recycle a good amount of what was done in MetalLB, wiring up the frr-k8s configuration with the intermediate one required to render the configuration.
We also add a basic command to spin up an external FRR and configure it.