-
Notifications
You must be signed in to change notification settings - Fork 244
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 NRT garbage collector #1024
Add NRT garbage collector #1024
Conversation
✅ Deploy Preview for kubernetes-sigs-nfd ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
Welcome @PiotrProkop! |
Hi @PiotrProkop. Thanks for your PR. I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
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.
Thanks for implementing this!
very initial pass, only shallow review.
Some open questions for discussion, I don't have strong opinions here yet
- should this be (yet another) separate tiny component or do we want to merge this on nfd-master?
- I concur the GC should be enabled only if a flag is given - note: if we move the GC to its own tiny server we get this for free
- and probably the resync loop interval as well should be tunable using an option
- we may want to add, perhaps in the future, a check if a NRT is orphaned, meaning there is no daemon (as in daemonset) for a given node. So even if we node is still here, we may want to delete that NRT (this may be governed by another option)
Another option would be running GC only e.g. at NFD master startup & exit.
|
Designwise I have no objections, but in practical terms AFAIU nfd-master is supposed to stay running for very long periods, possibly forever (bar bugs/upgrades), and in this case the actual GC will happen very seldomly. |
Or, we can add this option to nfd-topology-updater, and add manifests to reuse this binary as GC. It can work like this:
benefits:
@PiotrProkop @marquiz WDYT? |
60296f0
to
bf96421
Compare
I have implemented this as part of |
I'm also in favor of moving this to
One more option would have been doing GC only when notified, but to my amazement, k8s still does not have an API for that, despite 6 years of discussions: |
Ok, I'll move
I think we should also expose the informer's |
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.
Thanks @PiotrProkop for PR number 2^10 😄 I left some code comments. Thanks also @fromanirh and @eero-t for the reviews
/ok-to-test
About @fromanirh's suggestionm
Or, we can add this option to nfd-topology-updater, and add manifests to reuse this binary as GC. It can work like this:
- we add code to handle GC, but instead of calling it into nfd-master, we call into nfd-topology-updater
- by default, the GC code is disabled
- nfd-topology-updater becomes EITHER updater (= like today) or does GC
- we add new manifests to run nfd-topology-updater as GC agent
benefits:
- all the NRT handling logic is neatly included into nfd-topology-updater, no spillover on nfd-master
- very clear when GC is enabled: only if you run nfd-topology-updater --gc-enabled --gc-period 5m
- very clear separation of concerns
- no new images (but this is also true for nfd-master integration)
I kinda like this idea 👍 For the reasons (benefits) you mentioned. I think the nrt-gc could live in nfd-master but your suggestion would make it cleaner and also simpler/more understandable to deploy e.g. if one wants to deploy only topology-updater, without the nfd labeler at all.
Then there's the question whether it should be a separate tiny binary (as @fromanirh suggested in some other comment above) or bolt this into the current topology-updater binary under some separate cmdline flag. I don't have strong opinion about that but maybe a separate super simple binary would be cleaner. Any though? We need separate deployment files (deployment yamls, rbac rules etc) anyway in either case.
bf96421
to
08346ac
Compare
7d99e4a
to
59d50c1
Compare
@marquiz Thanks for the review! For now I have move this GC to
|
59d50c1
to
9a7dc43
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.
/lgtm
Thanks! Only minor nits, please consider them only if you resubmit for other reasons. Once @marquiz is happy we can merge.
cmd/nfd-topology-gc/main_test.go
Outdated
Convey("When parsing command line arguments", t, func() { | ||
flags := flag.NewFlagSet(ProgramName, flag.ExitOnError) | ||
|
||
Convey("When valid -gc-inteval is specified", func() { |
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.
(only if you resubmit): typo "inteval"
cmd/nfd-topology-gc/main_test.go
Outdated
args := parseArgs(flags, | ||
"-gc-interval=30s") | ||
|
||
Convey("args.sources is set to appropriate values", func() { |
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.
(only if you resubmit) either generalize the text or replace "sources" with "GCPeriod"
pkg/nfd-topology-gc/nfd-nrt-gc.go
Outdated
n.factory.Start(n.stopChan) | ||
n.factory.WaitForCacheSync(n.stopChan) | ||
|
||
klog.Infof("Running initial GC") |
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.
(only if you resubmit) drop "initial", so it reads "Running GC"
LGTM label has been added. Git tree hash: a6249fa59f772901471a95774e535d7700e0f786
|
We still need the docs 😅 And one more thing I started to ponder about the Helm deployment. It would be nice for the Helm to also deploy topology-gc by default (if topology-updater is enabled). Probably the nicest/easiest way to do this would be to simply deploy topology-gc only if topology-updater is enabled, too. That is, deploy if |
b9005b3
to
daf8440
Compare
daf8440
to
2b5f428
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.
Thanks for the update @PiotrProkop. I had a few more comments but after those I think we should get this merged
deployment/helm/node-feature-discovery/templates/clusterrole.yaml
Outdated
Show resolved
Hide resolved
deployment/helm/node-feature-discovery/templates/clusterrolebinding.yaml
Outdated
Show resolved
Hide resolved
deployment/helm/node-feature-discovery/templates/serviceaccount.yaml
Outdated
Show resolved
Hide resolved
deployment/helm/node-feature-discovery/templates/topology-gc.yaml
Outdated
Show resolved
Hide resolved
NodeResourceTopology(aka NRT) custom resource is used to enable NUMA aware Scheduling in Kubernetes. As of now node-feature-discovery daemons are used to advertise those resources but there is no service responsible for removing obsolete objects(without corresponding Kubernetes node). This patch adds new daemon called nfd-topology-gc which removes old NRTs. Signed-off-by: PiotrProkop <[email protected]>
Signed-off-by: PiotrProkop <[email protected]>
2b5f428
to
3143faf
Compare
From #1024 (comment)
A side note, talking about CRDs, how do you guys normally deploy the NRT CRD? Now this CRD is not properly/normally managed by the NFD Helm chart. It is not deployed by default (only created when |
@marquiz To be honest I don't use helm to deploy NFD and CRDs but kustomize 😄 but I agree that |
I fully agree deploying the CRD is a separate topic. For the record:
|
K, that's fine. Just started to think about that 😊 And yes, we should document clearly what is the expected method of getting the CRD deployed
Yeah, I agree. But let's take these separately, not belonging into this PR |
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.
Thanks @PiotrProkop for working on this. I think this PR is ready to get in
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: marquiz, PiotrProkop The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
agreed, thanks @PiotrProkop ! |
/lgtm |
LGTM label has been added. Git tree hash: c5fe413bc2d1beb1826a3d46ceefc38ced76e349
|
Fixes: #928
I am still missing RBAC configuration. Also I am wondering whether this garbage collector should only be started when some flag is set to
true
. Let me know what you think.