Skip to content

Commit

Permalink
Saving work off so I can switch machines.
Browse files Browse the repository at this point in the history
Signed-off-by: Edwin Buck <edwbuck@gmail.com>
  • Loading branch information
edwbuck committed Sep 25, 2024
1 parent bf6ad3c commit f81942f
Show file tree
Hide file tree
Showing 4 changed files with 620 additions and 39 deletions.
4 changes: 4 additions & 0 deletions pkg/server/datastore/sqlstore/sqlstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,8 @@ func (ds *Plugin) UpdateAttestedNode(ctx context.Context, n *common.AttestedNode
if err != nil {
return err
}
// TODO: this is at the wrong level of the software stack.
// It should be created in the caller of the datastore interface.
return createAttestedNodeEvent(tx, &datastore.AttestedNodeEvent{
SpiffeID: n.SpiffeId,
})
Expand All @@ -369,6 +371,8 @@ func (ds *Plugin) DeleteAttestedNode(ctx context.Context, spiffeID string) (atte
if err != nil {
return err
}
// TODO: this is at the wrong level of the software stack.
// It should be created in the caller of the datastore interface.
return createAttestedNodeEvent(tx, &datastore.AttestedNodeEvent{
SpiffeID: spiffeID,
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func (a *attestedNodes) captureChangedNodes(ctx context.Context) error {

func (a *attestedNodes) searchBeforeFirstEvent(ctx context.Context) error {
// First event detected, and startup was less than a transaction timout away.
if !a.firstEventTime.IsZero() && a.clk.Now().Sub(a.firstEventTime) > a.sqlTransactionTimeout {
if !a.firstEventTime.IsZero() && a.clk.Now().Sub(a.firstEventTime) <= a.sqlTransactionTimeout {
resp, err := a.ds.ListAttestedNodesEvents(ctx, &datastore.ListAttestedNodesEventsRequest{
LessThanEventID: a.firstEvent,
})
Expand Down Expand Up @@ -230,6 +230,7 @@ func (a *attestedNodes) updateCachedNodes(ctx context.Context) error {

agentExpiresAt := time.Unix(node.CertNotAfter, 0)
a.cache.UpdateAgent(node.SpiffeId, agentExpiresAt, api.ProtoFromSelectors(node.Selectors))
delete(a.fetchNodes, node.SpiffeId)

}
a.emitCacheMetrics()
Expand Down
Loading

0 comments on commit f81942f

Please sign in to comment.