Skip to content

Commit

Permalink
Correctly reference used ports key when validating app ports (#14066)
Browse files Browse the repository at this point in the history
  • Loading branch information
sonicaj authored Jul 23, 2024
1 parent bbfdd38 commit cbcd4f0
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/middlewared/middlewared/plugins/apps/schema_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,12 @@ def validate_acl_entries(self, verrors, value, question, schema_name, app_data):
verrors.add(schema_name, f'{value["path"]}: path does not exist')

async def validate_port_available_on_node(self, verrors, value, question, schema_name, app_data):
if app_data and value in [p['port'] for p in app_data['used_ports']]:
# TODO: This still leaves a case where user has multiple ports in a single app and mixes
# them to the same value however in this case we will still get an error raised by docker.
return
for port_entry in (app_data['active_workloads']['used_ports'] if app_data else []):
for host_port in port_entry['host_ports']:
if value == host_port['host_port']:
# TODO: This still leaves a case where user has multiple ports in a single app and mixes
# them to the same value however in this case we will still get an error raised by docker.
return

if value in await self.middleware.call('app.used_ports') or value in await self.middleware.call(
'port.ports_mapping', 'app'
Expand Down

0 comments on commit cbcd4f0

Please sign in to comment.