From eb002e78767383a1544259a01a513475e9308416 Mon Sep 17 00:00:00 2001 From: Forrest <30576607+fspmarshall@users.noreply.github.com> Date: Wed, 6 Nov 2024 07:13:09 -0800 Subject: [PATCH] upsert trusted cluster cleanup (#48491) --- 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 acbc46dc4f281..784d6aad010dc 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