From 3f88e8ea6f40d14442486351192296f024d81f09 Mon Sep 17 00:00:00 2001 From: Matt Toohey Date: Thu, 11 Jul 2024 15:27:15 +1000 Subject: [PATCH] fix: include the IP of the leader in ASM follower sync error logs (#2049) It can be hard to tell in logs when an ASM follower can not sync with the leader what it thinks the leader is, which is important to know if it is following the current leader or an old one. --- common/configuration/asm.go | 2 +- common/configuration/asm_follower.go | 4 ++-- common/configuration/asm_leader.go | 2 +- common/configuration/asm_test.go | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/common/configuration/asm.go b/common/configuration/asm.go index e1b7eb741d..25d1ffd9e0 100644 --- a/common/configuration/asm.go +++ b/common/configuration/asm.go @@ -44,7 +44,7 @@ func newASMForTesting(ctx context.Context, secretsClient *secretsmanager.Client, } followerFactory := func(ctx context.Context, url *url.URL) (client asmClient, err error) { rpcClient := rpc.Dial(ftlv1connect.NewAdminServiceClient, url.String(), log.Error) - return newASMFollower(ctx, rpcClient, clock), nil + return newASMFollower(ctx, rpcClient, url.String(), clock), nil } return &ASM{ coordinator: leader.NewCoordinator[asmClient]( diff --git a/common/configuration/asm_follower.go b/common/configuration/asm_follower.go index b7155d6d87..1b22b8e168 100644 --- a/common/configuration/asm_follower.go +++ b/common/configuration/asm_follower.go @@ -27,10 +27,10 @@ type asmFollower struct { var _ asmClient = &asmFollower{} -func newASMFollower(ctx context.Context, rpcClient ftlv1connect.AdminServiceClient, clock clock.Clock) *asmFollower { +func newASMFollower(ctx context.Context, rpcClient ftlv1connect.AdminServiceClient, leaderName string, clock clock.Clock) *asmFollower { f := &asmFollower{ client: rpcClient, - cache: newSecretsCache("asm-follower"), + cache: newSecretsCache(fmt.Sprintf("asm/follower/%s", leaderName)), } go f.cache.sync(ctx, asmFollowerSyncInterval, func(ctx context.Context, secrets *xsync.MapOf[Ref, cachedSecret]) error { return f.sync(ctx, secrets) diff --git a/common/configuration/asm_leader.go b/common/configuration/asm_leader.go index 286560ce01..65705e9af8 100644 --- a/common/configuration/asm_leader.go +++ b/common/configuration/asm_leader.go @@ -31,7 +31,7 @@ var _ asmClient = &asmLeader{} func newASMLeader(ctx context.Context, client *secretsmanager.Client, clock clock.Clock) *asmLeader { l := &asmLeader{ client: client, - cache: newSecretsCache("asm-leader"), + cache: newSecretsCache("asm/leader"), } go l.cache.sync(ctx, asmLeaderSyncInterval, func(ctx context.Context, secrets *xsync.MapOf[Ref, cachedSecret]) error { return l.sync(ctx, secrets) diff --git a/common/configuration/asm_test.go b/common/configuration/asm_test.go index ed56328473..80d80cb76d 100644 --- a/common/configuration/asm_test.go +++ b/common/configuration/asm_test.go @@ -168,7 +168,7 @@ func TestFollowerSync(t *testing.T) { // fakeRPCClient connects the follower to the leader fakeRPCClient := &fakeAdminClient{asm: asm} followerClock := clock.NewMock() - follower := newASMFollower(ctx, fakeRPCClient, followerClock) + follower := newASMFollower(ctx, fakeRPCClient, "fake", followerClock) testClientSync(ctx, t, follower, follower.cache, sm, func(percentage float64) { // sync leader