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 configurable pagination to nfd-gc #2001

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
2 changes: 2 additions & 0 deletions cmd/nfd-gc/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ func initFlags(flagset *flag.FlagSet) *nfdgarbagecollector.Args {
"Kubeconfig to use")
flagset.IntVar(&args.MetricsPort, "metrics", 8081,
"Port on which to expose metrics.")
flagset.Int64Var(&args.ListSize, "list-size", 200,
"the pagination size used when listing node features")

klog.InitFlags(flagset)

Expand Down
14 changes: 14 additions & 0 deletions docs/reference/gc-commandline-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,20 @@ Print usage and exit.

Print version and exit.

### -list-size

The pagination size to use when calling api-server to list nodefeatures.
Pagination is useful for controlling the load on api-server/etcd as the nodefeature resources can be large.
A value of 0 will disable pagination.

Default: 200

Example:

```bash
nfd-gc -list-size=100
```

### -gc-interval

The `-gc-interval` specifies the interval between periodic garbage collector runs.
Expand Down
7 changes: 7 additions & 0 deletions docs/usage/nfd-gc.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,10 @@ default garbage collector interval is set to 1h which is the value when no
In Helm deployments see
[garbage collector parameters](../deployment/helm.md#garbage-collector-parameters)
for altering the nfd-gc configuration.

## List Pagination & Scalability

When NFD GC runs up it lists nodefeatures from api-server.
These resources can be large and in a large cluster this initial list call to sync the informer cache can be
expensive and heavy on api-server/etcd. You can use the `list-size` argument to control pagination size
to help control the load from this list.
3 changes: 2 additions & 1 deletion pkg/nfd-gc/nfd-gc.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ type Args struct {
GCPeriod time.Duration
Kubeconfig string
MetricsPort int
ListSize int64
}

type NfdGarbageCollector interface {
Expand Down Expand Up @@ -155,7 +156,7 @@ func (n *nfdGarbageCollector) garbageCollect() {

listAndHandle := func(gvr schema.GroupVersionResource, handler func(metav1.PartialObjectMetadata)) {
opts := metav1.ListOptions{
Limit: 200,
Limit: n.args.ListSize,
}
for {
rsp, err := n.client.Resource(gvr).List(context.TODO(), opts)
Expand Down