From cbbf915537dd947386b6d2c8746963cfc02dfbaa Mon Sep 17 00:00:00 2001 From: Forrest <30576607+fspmarshall@users.noreply.github.com> Date: Tue, 5 Nov 2024 14:15:50 -0800 Subject: [PATCH] upsert trusted cluster cleanup (#48176) --- lib/auth/trustedcluster.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/auth/trustedcluster.go b/lib/auth/trustedcluster.go index acbc46dc4f2..784d6aad010 100644 --- a/lib/auth/trustedcluster.go +++ b/lib/auth/trustedcluster.go @@ -54,13 +54,15 @@ func (a *Server) UpsertTrustedCluster(ctx context.Context, tc types.TrustedClust // It is recommended to omit trusted cluster name because the trusted cluster name // is updated to the roots cluster name during the handshake with the root cluster. var existingCluster types.TrustedCluster - var cas []types.CertAuthority if tc.GetName() != "" { - var err error - existingCluster, err = a.GetTrustedCluster(ctx, tc.GetName()) + ec, err := a.GetTrustedCluster(ctx, tc.GetName()) if err != nil && !trace.IsNotFound(err) { return nil, trace.Wrap(err) } + + if err == nil { + existingCluster = ec + } } // if there is no existing cluster, switch to the create case