Prevent manual peering of control plane nodes to hop node (#13966)

This commit is contained in:
Lila Yasin 2023-05-25 15:44:43 -04:00 committed by Seth Foster
parent 6834568c5d
commit 9cad45feac

View File

@ -5489,6 +5489,13 @@ class InstanceSerializer(BaseSerializer):
if peers_from_control_nodes and node_type not in (Instance.Types.EXECUTION, Instance.Types.HOP):
raise serializers.ValidationError("peers_from_control_nodes can only be enabled for execution or hop nodes.")
if node_type in (Instance.Types.CONTROL):
if self.instance and 'peers' in attrs and set(self.instance.peers.all()) != set(attrs['peers']):
raise serializers.ValidationError(
"Setting peers manually for control nodes is not allowed. Enable peers_from_control_nodes on the hop and execution nodes instead."
)
return super().validate(attrs)
def validate_node_type(self, value):