-
Notifications
You must be signed in to change notification settings - Fork 8
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
feat: cache asm secrets #1832
feat: cache asm secrets #1832
Conversation
Wasn't this going to be two separate PRs? |
Can you split it up please? |
b4bb735
to
1133952
Compare
I'll add some more tests to this PR too |
5630f53
to
70ad963
Compare
common/configuration/asm_follower.go
Outdated
} | ||
entries := []Entry{} | ||
for _, s := range resp.Msg.Secrets { | ||
components := strings.Split(s.RefPath, ".") |
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've seen this pattern a few times, maybe a fn (rp *) ToRef (Ref, 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.
I'll make a helper func for this 👍
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.
ParseRef
already exists 🤦♂️
added integration test for syncing secrets |
815b466
to
9b0726e
Compare
common/configuration/asm_leader.go
Outdated
go func() { | ||
l.watchForUpdates(ctx, clock) | ||
}() |
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.
go func() { | |
l.watchForUpdates(ctx, clock) | |
}() | |
go l.watchForUpdates(ctx, clock) |
common/configuration/asm_leader.go
Outdated
|
||
err := l.sync(ctx) | ||
if err == nil { | ||
backOff = syncInitialBackoff |
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.
We should log this error, even if at debug.
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.
This case is for when there is no error and is resetting the backoff. The error is logged below
common/configuration/asm_leader.go
Outdated
|
||
// sync retrieves all secrets from ASM and updates the cache | ||
func (l *asmLeader) sync(ctx context.Context) error { | ||
previous := map[Ref]asmSecretValue{} |
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 don't see a cache for the followers?
common/configuration/asm_leader.go
Outdated
client *secretsmanager.Client | ||
|
||
// indicates if the initial sync with ASM has finished | ||
loaded atomic.Value[bool] |
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.
It would be more idiomatic to use a channel here, closing it once the value is available. This makes it simpler to do timeouts too.
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.
Oh nice
4253681
to
a58886d
Compare
Updated:
|
3c767ad
to
2374dae
Compare
# Conflicts: # cmd/ftl-controller/main.go
4f6c5c2
to
775ae73
Compare
closes #1782
ASM changes:
ASM
usesleader
package to coordinate between leader and followerssecretsCache
Other changes: