diff --git a/agent/rpc/peering/service.go b/agent/rpc/peering/service.go index 86a8b11dc..a30eae21b 100644 --- a/agent/rpc/peering/service.go +++ b/agent/rpc/peering/service.go @@ -346,8 +346,7 @@ func (s *Server) Establish( return nil, err } - // we don't want to default req.Partition unlike because partitions are empty in OSS - if err := s.validatePeeringInPartition(tok.PeerID, req.Partition); err != nil { + if err := s.validatePeeringInPartition(tok.PeerID, entMeta.PartitionOrDefault()); err != nil { return nil, err } @@ -409,8 +408,15 @@ func (s *Server) validatePeeringInPartition(remotePeerID, partition string) erro return fmt.Errorf("cannot read peering by ID: %w", err) } - if peering != nil && peering.Partition == partition { - return fmt.Errorf("cannot create a peering within the same partition (ENT) or cluster (OSS)") + if peering != nil { + stateStorePart := peering.Partition + if stateStorePart == "" { + stateStorePart = "default" + } + + if stateStorePart == partition { + return fmt.Errorf("cannot create a peering within the same partition (ENT) or cluster (OSS)") + } } return nil