upsert trusted cluster cleanup (#48176)

This commit is contained in:
Forrest
2024-11-05 22:15:50 +00:00
committed by GitHub
parent e6fc6a55ce
commit cbbf915537
+5 -3
View File
@@ -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