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

Add metrics for iptables operations #323

Merged
merged 7 commits into from
Aug 5, 2022
Merged

Add metrics for iptables operations #323

merged 7 commits into from
Aug 5, 2022

Conversation

dajudge
Copy link
Contributor

@dajudge dajudge commented Jul 25, 2022

To have better visibility of the iptables operations performed by kilo it would be nice to have prom metrics for them.

This PR introduces such metrics for all iptables operations by wrapping a proxy around the iptables client.

@dajudge dajudge marked this pull request as ready for review July 25, 2022 15:22
Copy link
Collaborator

@leonnicolas leonnicolas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks, looks good to me. I am just not sure about some small things

pkg/iptables/iptables.go Outdated Show resolved Hide resolved
pkg/iptables/iptables.go Outdated Show resolved Hide resolved
pkg/iptables/metrics.go Outdated Show resolved Hide resolved
pkg/iptables/metrics.go Show resolved Hide resolved
Co-authored-by: leonnicolas <60091705+leonnicolas@users.noreply.github.com>
"operation",
"table",
})
registerer.MustRegister(counterWithChain, counterWithoutChain)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if we do the registerer == nil check here, we don't have to do it in the caller twice (for ipv4 and ipv6)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@clive-jevons WDYT? I don't feel it's the cleanest piece of code ever to hand in a nil value for registerer here, but I have no strong feelings against it either...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great idea - done 😁

Alex Stockinger and others added 4 commits July 26, 2022 12:07
@dajudge dajudge requested a review from leonnicolas July 26, 2022 13:19
leonnicolas
leonnicolas previously approved these changes Jul 27, 2022
Copy link
Collaborator

@leonnicolas leonnicolas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice 🌮

@dajudge dajudge mentioned this pull request Jul 28, 2022
@leonnicolas leonnicolas requested a review from squat July 28, 2022 14:23
@@ -245,7 +245,7 @@ func runRoot(_ *cobra.Command, _ []string) error {
if port < 1 || port > 1<<16-1 {
return fmt.Errorf("invalid port: port mus be in range [%d:%d], but got %d", 1, 1<<16-1, port)
}
m, err := mesh.New(b, enc, gr, hostname, port, s, local, cni, cniPath, iface, cleanUpIface, createIface, mtu, resyncPeriod, prioritisePrivateAddr, iptablesForwardRule, log.With(logger, "component", "kilo"))
m, err := mesh.New(b, enc, gr, hostname, port, s, local, cni, cniPath, iface, cleanUpIface, createIface, mtu, resyncPeriod, prioritisePrivateAddr, iptablesForwardRule, log.With(logger, "component", "kilo"), registry)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the mesh accepts a registerer in its constructor, I think it's pretty awkward to still require calling "RegisterMetrics" a couple of lines below. We should do this automatically now during creation of the mesh.

squat
squat previously approved these changes Aug 5, 2022
Copy link
Owner

@squat squat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Love it. Just one comment about the registration of the Mesh metrics. I'd like to do this cleanup together, but we can also do a follow up.

@dajudge
Copy link
Contributor Author

dajudge commented Aug 5, 2022

Love it. Just one comment about the registration of the Mesh metrics. I'd like to do this cleanup together, but we can also do a follow up.

I'll add it over the weekend! 👍

@squat
Copy link
Owner

squat commented Aug 5, 2022

Thanks @dajudge and great work here

@dajudge dajudge dismissed stale reviews from squat and leonnicolas via db6587f August 5, 2022 19:11
@dajudge
Copy link
Contributor Author

dajudge commented Aug 5, 2022

I'm a bit puzzled why those e2e tests would fail... 🤔

@squat
Copy link
Owner

squat commented Aug 5, 2022

Retried the e2e tests and it passed; I think the failure was just a flake

@squat
Copy link
Owner

squat commented Aug 5, 2022

Netlify also passed but the status isn't syncing. Merging 🚀🚀

@squat squat merged commit 1921c6a into squat:main Aug 5, 2022
@dajudge dajudge deleted the iptables-metrics branch August 6, 2022 04:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants