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

feat: persist k8s client QPS/Burst values #263

Merged
merged 5 commits into from
Jan 8, 2024

Conversation

thapabishwa
Copy link
Contributor

@thapabishwa thapabishwa commented Dec 9, 2023

This PR intents to allow end users to use custom QPS/Burst value with trivy-kubernetes library with wrapper functions

Output after QPS/Burst value set to 100/100 (after this PR)

Current namespace: default
Scanning cluster
Scan took 79.106125ms

Output with no overrides(before this PR)

Current namespace: default
Scanning cluster
Scan took 2.043902375s

@chen-keinan This PR fixes the issues we discussed in #262

@thapabishwa-plerionaut
Copy link
Contributor

This PR addresses issue introduced by kubernetes/cli-runtime#23

Copy link
Contributor

@chen-keinan chen-keinan left a comment

Choose a reason for hiding this comment

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

lgtm I have added one comment

Comment on lines 22 to 52
func WithQPS(qps float32) k8s.ClusterOption {
return func(o *genericclioptions.ConfigFlags) {
o.WrapConfigFn = combineConfigFns(o.WrapConfigFn, func(c *rest.Config) *rest.Config {
c.QPS = qps
return c
})
}
}

func WithBurst(burst int) k8s.ClusterOption {
return func(o *genericclioptions.ConfigFlags) {
o.WrapConfigFn = combineConfigFns(o.WrapConfigFn, func(c *rest.Config) *rest.Config {
c.Burst = burst
return c
})
}
}

// Helper function to combine multiple config functions
func combineConfigFns(existing, newFn func(*rest.Config) *rest.Config) func(*rest.Config) *rest.Config {
if existing == nil {
return newFn
}
return func(c *rest.Config) *rest.Config {
if modified := existing(c); modified != nil {
return newFn(modified)
}
return newFn(c)
}
}

Copy link
Contributor

Choose a reason for hiding this comment

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

should these option function should be in k8s.go file?

Copy link
Contributor

@thapabishwa-plerionaut thapabishwa-plerionaut Jan 8, 2024

Choose a reason for hiding this comment

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

Yeah. I have moved them over to k8s.go file.

@chen-keinan
Copy link
Contributor

lgtm 🚀

@chen-keinan chen-keinan merged commit a47c86a into aquasecurity:main Jan 8, 2024
3 checks passed
@thapabishwa thapabishwa deleted the QPS-Burst-Fix branch January 10, 2024 13:39
@thapabishwa thapabishwa changed the title feat: allow adjustment of QPS/Burst values feat: persist k8s client QPS/Burst values Mar 26, 2024
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.

3 participants