-
Notifications
You must be signed in to change notification settings - Fork 556
fix: fetch federated trust bundles concurrently #6491
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
SPIRE agent periodically syncs entries, federated bundles and SVIDs from the SPIRE server. This happens every 5 seconds with a backoff. There is a 30 second timeout for this process. If there are many federations for the entries allowed for the agent, this timeout can be exceeded. This change adds a concurrent fetch for federated bundles to reduce the chance of hitting the timeout. Fixes: spiffe#6490
4142365 to
a11fc24
Compare
sorindumitru
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @markgoddard for providing a fix to this issue. This is looking good. I think we have some tests for fetching the federated bundles, but could you add one with more bundles than the number of workers to make sure that keeps working?
| } | ||
|
|
||
| // fetchBundle fetches a single federated bundle from SPIRE server. | ||
| func (c *client) fetchBundle(ctx context.Context, bundleClient bundlev1.BundleClient, trustDomain string) (*types.Bundle, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we include federated in the names of these functions since they can only deal with federated bundles.
| func (c *client) fetchBundle(ctx context.Context, bundleClient bundlev1.BundleClient, trustDomain string) (*types.Bundle, error) { | |
| func (c *client) fetchFederatedBundle(ctx context.Context, bundleClient bundlev1.BundleClient, trustDomain string) (*types.Bundle, error) { |
| // fetchBundlesConcurrently fetches federated bundles concurrently. | ||
| // This is done to improve sync times when there are many federations. This should ensure that the | ||
| // sync does not exceed rpcTimeout. | ||
| func (c *client) fetchBundlesConcurrently(ctx context.Context, bundleClient bundlev1.BundleClient, trustDomains []string, bundles []*types.Bundle) ([]*types.Bundle, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| func (c *client) fetchBundlesConcurrently(ctx context.Context, bundleClient bundlev1.BundleClient, trustDomains []string, bundles []*types.Bundle) ([]*types.Bundle, error) { | |
| func (c *client) fetchFederatedBundlesConcurrently(ctx context.Context, bundleClient bundlev1.BundleClient, trustDomains []string, bundles []*types.Bundle) ([]*types.Bundle, error) { |
| wg.Add(1) | ||
| go func() { | ||
| defer wg.Done() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you can now do something like this to avoid the Add() and defer:
| wg.Add(1) | |
| go func() { | |
| defer wg.Done() | |
| wg.Go(func() { |
SPIRE agent periodically syncs entries, federated bundles and SVIDs from
the SPIRE server. This happens every 5 seconds with a backoff. There is
a 30 second timeout for this process. If there are many federations for
the entries allowed for the agent, this timeout can be exceeded.
This change adds a concurrent fetch for federated bundles to reduce the
chance of hitting the timeout.
Fixes: #6490