Skip to content

Make attested-node prune batch size configurable - #7100

Merged
MarcosDY merged 2 commits into
spiffe:mainfrom
terahertz5k:configurable-attested-node-pruning
Jul 2, 2026
Merged

MarcosDY merged 2 commits into
spiffe:mainfrom
terahertz5k:configurable-attested-node-pruning

Conversation

@terahertz5k

Copy link
Copy Markdown
Contributor

Pull Request check list

  • Commit conforms to CONTRIBUTING.md?
  • Proper tests/regressions included?
  • Documentation updated?

Affected functionality

Pruning of expired attested nodes (the background job enabled by prune_attested_nodes_expired_for), and the DataStore.PruneAttestedExpiredNodes interface.

Description of change

Adds a prune_attested_nodes_batch_size server 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_for is set.

Details:

  • prune_attested_nodes_batch_size HCL option parsed in cmd/spire-server/cli/run, defaulting to 1000 when unset or non-positive.
  • Threaded as a batchSize parameter through DataStore.PruneAttestedExpiredNodes (interface, sqlstore impl, metrics wrapper, fakes) down to the SQL LIMIT, with a defensive default in the datastore for non-positive values.
  • BatchSize added to node.PruneArgs and wired through the server config.
  • Docs row added to doc/spire_server.md.

No datastore schema change or migration: only an existing query's LIMIT is parameterized, so the CONTRIBUTING "SQL Plugin Changes" release-cycle rule does not apply.

Testing: new TestPruneAttestedExpiredNodesBatchSize verifies the limit is honored and that successive runs drain the backlog; new NewServerConfig cases cover parsing and defaulting; go build ./..., scoped go test, and golangci-lint all pass.

Which issue this PR fixes

fixes #7099

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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_size server configuration (default 1000) and wire it into node.Manager pruning.
  • Extend DataStore.PruneAttestedExpiredNodes to accept a batchSize argument and propagate it through wrappers/fakes.
  • Parameterize the SQLStore prune query LIMIT and 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.

Comment thread cmd/spire-server/cli/run/run.go Resolved
Comment thread cmd/spire-server/cli/run/run.go Resolved
Comment thread pkg/server/node/manager.go Resolved
…gerConfig, document in server_full.conf

Signed-off-by: Kevin Lui <[email protected]>
@MarcosDY MarcosDY added this to the 1.15.2 milestone Jul 2, 2026
@MarcosDY
MarcosDY added this pull request to the merge queue Jul 2, 2026
Merged via the queue into spiffe:main with commit 9f3095f Jul 2, 2026
56 checks passed
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.

Make the attested-node prune batch size configurable

3 participants