Skip to content

Comments

Configure local REST client QPS/Burst from global config#2051

Open
tpantelis wants to merge 1 commit intosubmariner-io:develfrom
tpantelis:rest_qps
Open

Configure local REST client QPS/Burst from global config#2051
tpantelis wants to merge 1 commit intosubmariner-io:develfrom
tpantelis:rest_qps

Conversation

@tpantelis
Copy link
Contributor

@tpantelis tpantelis commented Feb 19, 2026

Initialize global config before creating REST clients to allow QPS and Burst settings to be applied. This enables cluster-specific tuning of Kubernetes API request rates.

Summary by CodeRabbit

  • Chores

    • Updated module dependencies for controller-runtime and related packages.
  • Refactor

    • Reorganized agent initialization to improve configuration loading and management.

Initialize global config before creating REST clients to allow QPS
and Burst settings to be applied. This enables cluster-specific
tuning of Kubernetes API request rates.

Signed-off-by: Tom Pantelis <tompantelis@gmail.com>
@submariner-bot
Copy link
Contributor

🤖 Created branch: z_pr2051/tpantelis/rest_qps
🚀 Full E2E won't run until the "ready-to-test" label is applied. I will add it automatically once the PR has 2 approvals, or you can add it manually.

@coderabbitai
Copy link

coderabbitai bot commented Feb 19, 2026

Walkthrough

Updated module dependencies in go.mod and refactored pkg/agent/main.go to retrieve a global ConfigMap during initialization. The global ConfigMap is used to configure QPS and Burst settings before creating the dynamic Kubernetes client. API signatures for global.Init and configmap.WatchAndSignalOnChange were updated accordingly.

Changes

Cohort / File(s) Summary
Dependency Updates
go.mod
Updated three module dependencies: submariner-io/admiral, sigs.k8s.io/controller-runtime, and sigs.k8s.io/structured-merge-diff/v6 to newer patch/pre-release versions.
Initialization Flow Refactoring
pkg/agent/main.go
Restructured initialization sequence to retrieve global ConfigMap before creating dynamic Kubernetes client. Updated global.Init to accept two ConfigMaps (global and service), updated configmap.WatchAndSignalOnChange to accept global ConfigMap parameter, and added QPS/Burst configuration retrieval from global ConfigMap.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested labels

ready-to-test

Suggested reviewers

  • dfarrell07
  • aswinsuryan
  • vthapar
  • skitt
  • sridhargaddam

Important

Pre-merge checks failed

Please resolve all errors before merging. Addressing warnings is optional.

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Actionable Comments Resolved ❓ Inconclusive Unable to verify all actionable comments have been resolved due to ambiguity in what constitutes actionable comments in this context. Clarify whether actionable comments refer to code-level TODO/FIXME markers, test skip markers, or GitHub PR review comments requiring resolution.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly and concisely describes the main change: configuring local REST client QPS/Burst settings from global configuration, which aligns with the primary objective of initializing global config before creating REST clients.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (3)
go.mod (1)

11-11: LGTM — admiral pseudo-version correctly carries the new API signatures.

The pseudo-version (v0.24.0-m0.0.20260218133429-4ba4e2683354) is the expected cross-repo development pattern for the Submariner devel branch when coordinating API changes ahead of a milestone tag. The commit timestamp (2026-02-18) aligns with the day before this PR was opened, and the AI summary confirms this version introduces the updated global.Init / configmap.WatchAndSignalOnChange signatures that the rest of this PR consumes.

Just a reminder: this pseudo-version — along with the indirect sigs.k8s.io/structured-merge-diff/v6 v6.3.2-0.20260122202528-d9cc6641c482 on line 76 — should be replaced with proper tagged releases before any milestone/release cut.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@go.mod` at line 11, The go.mod entry for github.com/submariner-io/admiral
uses the expected pseudo-version v0.24.0-m0.0.20260218133429-4ba4e2683354 which
matches the new API signatures (global.Init and
configmap.WatchAndSignalOnChange) referenced elsewhere; no functional change is
required now, but ensure you replace this pseudo-version (and the indirect
sigs.k8s.io/structured-merge-diff/v6 pseudo-version) with proper tagged releases
before the milestone/release cut.
pkg/agent/main.go (2)

115-116: k8sClient (used by the configmap watcher) is not re-created after QPS/Burst are applied.

kubernetes.NewForConfig captures a snapshot of cfg at line 115 — modifications to cfg.QPS/cfg.Burst at lines 128-129 have no effect on it. The configmap watcher at line 126 therefore operates with the original (pre-global-config) rate-limit settings. For a simple watch this is likely inconsequential, but it's inconsistent with the stated goal of applying global QPS/Burst to all REST clients. If full coverage is desired, recreate k8sClient after the QPS/Burst assignment (which would also require moving both configmap.Get calls below it, or caching their results).

Also applies to: 126-126

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@pkg/agent/main.go` around lines 115 - 116, k8sClient is created with
kubernetes.NewForConfig(cfg) before you mutate cfg.QPS/cfg.Burst, so the client
keeps the old rate limits; recreate the client after setting cfg.QPS and
cfg.Burst (i.e., call kubernetes.NewForConfig(cfg) again and assign to
k8sClient) and then perform the configmap watcher and any configmap.Get calls
(or alternatively cache the earlier Get results and reuse them) so the watcher
uses the updated rate-limited REST client.

128-129: Unconditional zero-write may silently discard kubeconfig-specified QPS/Burst values.

When QPS is zero, the created RESTClient falls back to DefaultQPS: 5 and when Burst is zero it falls back to DefaultBurst: 10 — so this won't disable rate limiting. However, if clientcmd.BuildConfigFromFlags already populated cfg.QPS/cfg.Burst from a kubeconfig that explicitly sets them, these lines unconditionally replace those values with 0 when the global config is absent. A guard preserves the intent of "only apply when explicitly configured":

♻️ Proposed fix — guard on non-zero before overriding
-	cfg.QPS = float32(global.Get(global.K8sClientQPS, 0))
-	cfg.Burst = global.Get(global.K8sClientBurst, 0)
+	if qps := global.Get(global.K8sClientQPS, 0); qps > 0 {
+		cfg.QPS = float32(qps)
+	}
+	if burst := global.Get(global.K8sClientBurst, 0); burst > 0 {
+		cfg.Burst = burst
+	}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@pkg/agent/main.go` around lines 128 - 129, The code unconditionally sets
cfg.QPS and cfg.Burst to values returned by global.Get, which can overwrite
kubeconfig-provided non-zero values with zero; change the logic in main.go to
only assign cfg.QPS = float32(global.Get(global.K8sClientQPS, 0)) and cfg.Burst
= global.Get(global.K8sClientBurst, 0) when the retrieved value is non-zero
(i.e., check the returned value from global.Get before writing into
cfg.QPS/cfg.Burst) so existing kubeconfig settings are preserved; update the
assignment sites that reference cfg.QPS and cfg.Burst accordingly.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@go.mod`:
- Line 11: The go.mod entry for github.com/submariner-io/admiral uses the
expected pseudo-version v0.24.0-m0.0.20260218133429-4ba4e2683354 which matches
the new API signatures (global.Init and configmap.WatchAndSignalOnChange)
referenced elsewhere; no functional change is required now, but ensure you
replace this pseudo-version (and the indirect
sigs.k8s.io/structured-merge-diff/v6 pseudo-version) with proper tagged releases
before the milestone/release cut.

In `@pkg/agent/main.go`:
- Around line 115-116: k8sClient is created with kubernetes.NewForConfig(cfg)
before you mutate cfg.QPS/cfg.Burst, so the client keeps the old rate limits;
recreate the client after setting cfg.QPS and cfg.Burst (i.e., call
kubernetes.NewForConfig(cfg) again and assign to k8sClient) and then perform the
configmap watcher and any configmap.Get calls (or alternatively cache the
earlier Get results and reuse them) so the watcher uses the updated rate-limited
REST client.
- Around line 128-129: The code unconditionally sets cfg.QPS and cfg.Burst to
values returned by global.Get, which can overwrite kubeconfig-provided non-zero
values with zero; change the logic in main.go to only assign cfg.QPS =
float32(global.Get(global.K8sClientQPS, 0)) and cfg.Burst =
global.Get(global.K8sClientBurst, 0) when the retrieved value is non-zero (i.e.,
check the returned value from global.Get before writing into cfg.QPS/cfg.Burst)
so existing kubeconfig settings are preserved; update the assignment sites that
reference cfg.QPS and cfg.Burst accordingly.

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.

2 participants