Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NAS-130193 / 24.10 / Correctly reference used ports key when validating app ports #14066

Merged
merged 1 commit into from
Jul 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading