Repository navigation
Implemented periodic purging of expired agents - #6152
Merged
sorindumitru merged 2 commits intoJul 16, 2025
Merged
Conversation
ValFadeev
force-pushed
the
periodic-purge-expired-nodes-server
branch
from
June 24, 2025 23:16
4073973 to
9c11127
Compare
ValFadeev
marked this pull request as ready for review
June 24, 2025 23:45
ValFadeev
requested review from
MarcosDY,
amartinezfayo,
evan2645,
rturner3 and
sorindumitru
as code owners
June 24, 2025 23:45
MarcosDY
reviewed
Jul 4, 2025
| return telemetry.StartCall(m, telemetry.Datastore, telemetry.Node, telemetry.Delete) | ||
| } | ||
|
|
||
| func StartPruneAttestedExpiredNodes(m telemetry.Metrics) *telemetry.CallCounter { |
Contributor
There was a problem hiding this comment.
Suggested change
| func StartPruneAttestedExpiredNodes(m telemetry.Metrics) *telemetry.CallCounter { | |
| // StartPruneAttestedExpiredNodes return metric | |
| // for server's datastore, on pruning expired attested nodes. | |
| func StartPruneAttestedExpiredNodes(m telemetry.Metrics) *telemetry.CallCounter { |
| return &common.AttestedNode{}, ds.err | ||
| } | ||
|
|
||
| func (ds *fakeDataStore) PruneAttestedExpiredNodes(ctx context.Context, expiredBefore time.Time, includeNonReattestable bool) error { |
Contributor
There was a problem hiding this comment.
Suggested change
| func (ds *fakeDataStore) PruneAttestedExpiredNodes(ctx context.Context, expiredBefore time.Time, includeNonReattestable bool) error { | |
| func (ds *fakeDataStore) PruneAttestedExpiredNodes(context.Context, time.Time, bool) error { |
Comment on lines
+1781
to
+1779
| if !include { | ||
| return tx.Where("can_reattest = ?", true) | ||
| } else { | ||
| return tx | ||
| } |
Contributor
There was a problem hiding this comment.
Suggested change
| if !include { | |
| return tx.Where("can_reattest = ?", true) | |
| } else { | |
| return tx | |
| } | |
| if !include { | |
| return tx.Where("can_reattest = ?", true) | |
| } | |
| return tx |
| logger.WithFields(logrus.Fields{ | ||
| telemetry.SPIFFEID: node.SpiffeID, | ||
| telemetry.SVIDSerialNumber: node.SerialNumber, | ||
| telemetry.SerialNumber: "CURRENT", |
Contributor
Author
There was a problem hiding this comment.
I took pruning of registration entries as an example here
spire/pkg/server/datastore/sqlstore/sqlstore.go
Lines 4087 to 4091 in 9c11127
| telemetry.SPIFFEID: node.SpiffeID, | ||
| telemetry.SVIDSerialNumber: node.SerialNumber, | ||
| telemetry.SerialNumber: "CURRENT", | ||
| }).Info("Pruned an expired node") |
Contributor
There was a problem hiding this comment.
this is going to cause spam the first time, may we move to debug? or add a summary?
like logger.WithField("count", count).Info("Pruned expired agents")
| CanReattest: false, | ||
| CertNotAfter: s.clock.Now().Unix(), | ||
| } | ||
| attestedNodeNonReattestable, err := s.ds.CreateAttestedNode(context.Background(), nodeNonReattestable) |
Contributor
There was a problem hiding this comment.
Can you get the context from T and use it instead of context.Background() in all tests?
Suggested change
| attestedNodeNonReattestable, err := s.ds.CreateAttestedNode(context.Background(), nodeNonReattestable) | |
| ctx := s.T().Context() | |
| attestedNodeNonReattestable, err := s.ds.CreateAttestedNode(ctx, nodeNonReattestable) |
MarcosDY
approved these changes
Jul 16, 2025
Signed-off-by: Valentin Fadeev <[email protected]>
Signed-off-by: Valentin Fadeev <[email protected]>
sorindumitru
force-pushed
the
periodic-purge-expired-nodes-server
branch
from
July 16, 2025 18:33
b5ad72b to
7e13a29
Compare
2 of 3 tasks
This was referenced May 8, 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
Adds the capability to enable periodic pruning of attested agents with certificates expired for longer than a configurable duration of time.
Description of change
Introduces new configuration options
prune_attested_nodes_expired_forandprune_non_reattestable_nodes. Whenprune_attested_nodes_expired_foris set to a given duration value SPIRE server will start a periodic task deleting attested nodes and the corresponding selectors, where agent certificate had been expired for longer than the specified duration. Non-reattestable nodes are not pruned by default. In order to consider the latter for pruningprune_non_reattestable_nodesmust be set totrue. Banned nodes are not pruned by this task.In the interests of limiting the scope of the change, and to require explicit opt-in at this stage, the implementation of the recently introduced
agent purgesubcommand (#3982) is left unchanged.Which issue this PR fixes
Closes #5938