Skip to content

Commit 558c6b2

Browse files
authored
Merge pull request #2294 from ArangoGutierrez/rebase_2001
Rebase PR 2001: add configurable pagination to nfd-gc
2 parents 9126920 + a72f889 commit 558c6b2

File tree

4 files changed

+27
-1
lines changed

4 files changed

+27
-1
lines changed

cmd/nfd-gc/main.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@ func initFlags(flagset *flag.FlagSet) *nfdgarbagecollector.Args {
8585
"Kubeconfig to use")
8686
flagset.IntVar(&args.Port, "port", 8080,
8787
"Port which metrics and healthz endpoints are served on")
88+
flagset.Int64Var(&args.ListSize, "list-size", 200,
89+
"the pagination size used when listing node features")
8890

8991
klog.InitFlags(flagset)
9092

docs/reference/gc-commandline-reference.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,21 @@ Print usage and exit.
3131

3232
Print version and exit.
3333

34+
### -list-size
35+
36+
The pagination size to use when calling api-server to list nodefeatures.
37+
Pagination is useful for controlling the load on api-server/etcd as the
38+
nodefeature resources can be large.
39+
A value of 0 will disable pagination.
40+
41+
Default: 200
42+
43+
Example:
44+
45+
```bash
46+
nfd-gc -list-size=100
47+
```
48+
3449
### -gc-interval
3550

3651
The `-gc-interval` specifies the interval between periodic garbage collector runs.

docs/usage/nfd-gc.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,11 @@ default garbage collector interval is set to 1h which is the value when no
2727
In Helm deployments see
2828
[garbage collector parameters](../deployment/helm.md#garbage-collector-parameters)
2929
for altering the nfd-gc configuration.
30+
31+
## List Pagination & Scalability
32+
33+
When NFD GC starts up it lists nodefeatures from api-server.
34+
These resources can be large and in a large cluster this initial list call to
35+
sync the informer cache can be expensive and heavy on api-server/etcd.
36+
You can use the `list-size` argument to control pagination size
37+
to help control the load from this list.

pkg/nfd-gc/nfd-gc.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ type Args struct {
5252
GCPeriod time.Duration
5353
Kubeconfig string
5454
Port int
55+
ListSize int64
5556
}
5657

5758
type NfdGarbageCollector interface {
@@ -162,7 +163,7 @@ func (n *nfdGarbageCollector) garbageCollect() {
162163

163164
listAndHandle := func(gvr schema.GroupVersionResource, handler func(metav1.PartialObjectMetadata)) {
164165
opts := metav1.ListOptions{
165-
Limit: 200,
166+
Limit: n.args.ListSize,
166167
}
167168
for {
168169
rsp, err := n.client.Resource(gvr).List(context.TODO(), opts)

0 commit comments

Comments
 (0)