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-133313 / 25.04 / Safely normalize host ports when retrieving from docker #15279

Merged
merged 1 commit into from
Dec 31, 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
13 changes: 9 additions & 4 deletions src/middlewared/middlewared/plugins/apps/ix_apps/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,13 +188,18 @@ def translate_resources_to_desired_workflow(app_resources: dict) -> dict:
if not host_config:
# This will happen for ports which are not exposed on the host side
continue
host_ports = []
for host_port in host_config:
try:
# We have seen that docker can report host port as an empty string or null
host_ports.append({'host_port': int(host_port['HostPort']), 'host_ip': host_port['HostIp']})
except (TypeError, ValueError):
continue

port_config = {
'container_port': int(container_port.split('/')[0]),
'protocol': container_port.split('/')[1],
'host_ports': [
{'host_port': int(host_port['HostPort']), 'host_ip': host_port['HostIp']}
for host_port in host_config
]
'host_ports': host_ports,
}
container_ports_config.append(port_config)

Expand Down
Loading