Repository navigation
Make attested-node prune batch size configurable - #7100
Merged
MarcosDY merged 2 commits intoJul 2, 2026
Merged
Conversation
Signed-off-by: Kevin Lui <[email protected]>
terahertz5k
requested review from
MarcosDY,
amartinezfayo,
evan2645,
rturner3 and
sorindumitru
as code owners
June 30, 2026 21:50
Contributor
There was a problem hiding this comment.
Pull request overview
This PR makes the SPIRE Server’s expired attested-node pruning throughput configurable by introducing a prune_attested_nodes_batch_size setting, threading it through the server config, node manager, datastore interface, and SQL implementation while preserving the previous default behavior (1000).
Changes:
- Add
prune_attested_nodes_batch_sizeserver configuration (default 1000) and wire it intonode.Managerpruning. - Extend
DataStore.PruneAttestedExpiredNodesto accept abatchSizeargument and propagate it through wrappers/fakes. - Parameterize the SQLStore prune query
LIMITand add test coverage to verify batch-size behavior.
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| test/fakes/fakedatastore/fakedatastore.go | Update fake datastore method signature to include batchSize. |
| pkg/server/server.go | Pass configured prune BatchSize into the node manager. |
| pkg/server/node/manager.go | Add BatchSize to prune configuration and pass it to datastore prune call. |
| pkg/server/datastore/sqlstore/sqlstore.go | Add default batch constant and apply configurable LIMIT(batchSize) for pruning. |
| pkg/server/datastore/sqlstore/sqlstore_test.go | Update existing prune tests and add batch-size specific pruning test. |
| pkg/server/datastore/datastore.go | Update DataStore interface method signature to include batchSize. |
| pkg/server/config.go | Add PruneAttestedNodesBatchSize to server runtime config. |
| pkg/common/telemetry/server/datastore/wrapper.go | Thread batchSize through metrics wrapper. |
| pkg/common/telemetry/server/datastore/wrapper_test.go | Update wrapper test fake to match new datastore signature. |
| doc/spire_server.md | Document prune_attested_nodes_batch_size config option and default. |
| cmd/spire-server/cli/run/run.go | Parse and default prune_attested_nodes_batch_size from HCL config. |
| cmd/spire-server/cli/run/run_test.go | Add config parsing/defaulting tests for the new option. |
…gerConfig, document in server_full.conf Signed-off-by: Kevin Lui <[email protected]>
MarcosDY
approved these changes
Jul 2, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull Request check list
Affected functionality
Pruning of expired attested nodes (the background job enabled by
prune_attested_nodes_expired_for), and theDataStore.PruneAttestedExpiredNodesinterface.Description of change
Adds a
prune_attested_nodes_batch_sizeserver config option controlling how many expired attested nodes are pruned per cycle. The limit was previously hardcoded to 1000 (pkg/server/datastore/sqlstore/sqlstore.go). Because each prune run deletes at most 1000 nodes, a single server prunes at most ~1000 expired nodes/hour. Additional replicas do not reliably increase this since they prune the same shared datastore and concurrent runs conflict (see #6310). In our environment we see 5000+ expirations per hour, so ~1000 per hour per SPIRE server is not enough and the backlog never clears.The new option defaults to 1000, so existing behavior is unchanged. It only applies when
prune_attested_nodes_expired_foris set.Details:
prune_attested_nodes_batch_sizeHCL option parsed incmd/spire-server/cli/run, defaulting to 1000 when unset or non-positive.batchSizeparameter throughDataStore.PruneAttestedExpiredNodes(interface, sqlstore impl, metrics wrapper, fakes) down to the SQLLIMIT, with a defensive default in the datastore for non-positive values.BatchSizeadded tonode.PruneArgsand wired through the server config.doc/spire_server.md.No datastore schema change or migration: only an existing query's
LIMITis parameterized, so the CONTRIBUTING "SQL Plugin Changes" release-cycle rule does not apply.Testing: new
TestPruneAttestedExpiredNodesBatchSizeverifies the limit is honored and that successive runs drain the backlog; newNewServerConfigcases cover parsing and defaulting;go build ./..., scopedgo test, andgolangci-lintall pass.Which issue this PR fixes
fixes #7099