Skip to content

Commit

Permalink
Prevent manual peering of control plane nodes to hop node (#13966)
Browse files Browse the repository at this point in the history
  • Loading branch information
djyasin authored May 25, 2023
1 parent 91efa83 commit e2c08d0
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions awx/api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -5490,6 +5490,13 @@ def get_field_from_model_or_attrs(fd):

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):
Expand Down

0 comments on commit e2c08d0

Please sign in to comment.