Skip to content

fix: make rpc_timeout and max_bundle_workers configurable on the agent#7093

Open
salimeid wants to merge 2 commits into
spiffe:mainfrom
salimeid:user/se/agent-concurrency-config
Open

fix: make rpc_timeout and max_bundle_workers configurable on the agent#7093
salimeid wants to merge 2 commits into
spiffe:mainfrom
salimeid:user/se/agent-concurrency-config

Conversation

@salimeid

Copy link
Copy Markdown

Both values were package-level constants with no way to tune them at runtime. Expose them as experimental HCL options following the same pattern as jwt_svid_cache_hit_timeout.

Affected functionality
Fetching of federated trust bundles.

Description of change
Makes spire-agent gRPC Timeout and federated bundle fetch's concurrency configurable.

Which issue this PR fixes
Fixes: #6490

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This pull request makes SPIRE Agent’s gRPC timeout and federated bundle fetch concurrency configurable via experimental HCL settings, addressing bundle sync failures when many federations cause update cycles to exceed the fixed RPC timeout.

Changes:

  • Exposes agent RPC timeout as an experimental rpc_timeout option and applies it to agent client calls.
  • Exposes federated bundle fetch concurrency as an experimental max_bundle_workers option.
  • Adds CLI config parsing/validation and unit tests for the new experimental options.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

File Description
pkg/agent/client/client.go Introduces exported, configurable RPC timeout and bundle worker count; updates client call sites and worker spawning to use the configurable values.
cmd/spire-agent/cli/run/run.go Adds experimental HCL fields, parses/validates them, and applies them to the agent client configuration with warnings.
cmd/spire-agent/cli/run/run_test.go Adds test coverage for parsing/validation and warning logs for the new experimental settings.

Comment on lines +61 to +63
func SetRPCTimeout(d time.Duration) {
RPCTimeout = d
}

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Leaving this comment unresolved, reviewers can decide of which approach to take here

Comment thread pkg/agent/client/client.go
Comment thread cmd/spire-agent/cli/run/run_test.go Outdated
Comment thread cmd/spire-agent/cli/run/run_test.go Outdated
salimeid and others added 2 commits June 30, 2026 09:13
Both values were package-level constants with no way to tune them
at runtime. Expose them as experimental HCL options following the
same pattern as jwt_svid_cache_hit_timeout.

Signed-off-by: Salim Eid <seid@genetec.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Salim Eid <4256703+salimeid@users.noreply.github.com>
@salimeid salimeid force-pushed the user/se/agent-concurrency-config branch from a7691da to bd9a463 Compare June 30, 2026 13:13
const (
rpcTimeout = 30 * time.Second

// maxBundleWorkers is the maximum number of worker goroutines to use when fetching bundles.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We should keep this comment.

Comment on lines +32 to 33
rpcTimeout = 30 * time.Second
maxBundleWorkers = 10

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Could you rename these to defaultX to differentiate them from the other ones

Comment on lines +39 to +40
RPCTimeout = rpcTimeout
MaxBundleWorkers = maxBundleWorkers

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

These do not need to be exported, maybe after renaming the consts, these can become rpcTimeout and maxBundleWorkers.

@github-actions github-actions Bot assigned salimeid and unassigned sorindumitru Jul 15, 2026
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.

SPIRE agent can exceed the RPC timeout when synchronising bundles with many federations

3 participants