Skip to content

Conversation

@beena352
Copy link

Summary of the Pull Request

Update WSLAContainer::Inspect to return WSLA-schema JSON instead of raw Docker inspect JSON, preserve WSLA host-side port mappings when Docker reports empty bindings, and report host-side mount paths from WSLA state.

PR Checklist

  • Closes: Link to issue #xxx
  • [x ] Communication: I've discussed this with core contributors already. If work hasn't been agreed, this work might be rejected
  • Tests: Added/updated if needed and all pass
  • Localization: All end user facing strings can be localized
  • Dev docs: Added/updated if needed
  • Documentation updated: If checked, please file a pull request on our docs repo and link it here: #xxx

Detailed Description of the Pull Request / Additional comments

Inspect now returns WSLA-schema JSON instead of Docker’s raw inspect output. Docker inspect data is mapped through the WSLA runtime schema before being serialized. Port bindings are added without overwriting existing WSLA host-side mappings, and mounts use WSLA host paths. This only affects the inspect output and does not change container runtime behavior.

Validation Steps Performed

@kvega005 kvega005 self-assigned this Jan 30, 2026
wslaInspect.Id = dockerInspect.Id;
wslaInspect.Name = dockerInspect.Name;

// Remove leading '/' from Docker container names.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is already an ExtractContainerName function in this file. Perhaps you could alter it to fit this purpose, so we don't duplicate that logic.

Copy link
Collaborator

@OneBlue OneBlue left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This approach LGTM, added a few minor comments

}
}

wsl::windows::service::wsla::WSLAContainerImpl::WslaInspectContainer wsl::windows::service::wsla::WSLAContainerImpl::BuildInspectContainer(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI: We can omit the full namespace here, because we have a using for WSLAContainerImpl

}

// Include Docker configured port bindings.
for (const auto& [containerPort, bindings] : dockerInspect.HostConfig.PortBindings)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would recommend directly reading from m_mappedPorts and generating the list from there, that should be simpler than having to read the bindings returned by docker and mapping those to our port mappings


auto details = container.Inspect();
VERIFY_ARE_EQUAL(details.HostConfig.NetworkMode, "host");
VERIFY_ARE_EQUAL(details.NetworkMode, "host");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would recommend matching docker's JSON structure and keeping the HostConfig field here

}

// Include Docker configured port bindings.
for (const auto& [containerPort, bindings] : dockerInspect.HostConfig.PortBindings)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this would be misleading.

The HostPort returned from dockerInspect.HostConfig.PortBindings is not the same as the hostPort in m_mappedPorts. From the docker's perspective the host is actually the WSLA VM. The host in m_mappedPorts is the actual Windows host.

Copy link

@kvega005 kvega005 Jan 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@OneBlue Do we need this code? Should we just return the port bindings in m_mappedPorts? Those are the only ones that have information about the real host port which is the only thing WSLA users care about.

Or do we want to create a separate field called something like VMPort and leave the HostPort entry null or empty for the ports that don't have host bindings?

Copy link
Collaborator

@OneBlue OneBlue Jan 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed ! That was I was referring to this in this comment

I don't think we should return VmPort at all. These are implementation details that the caller shouldn't know about

portBinding.HostIp = defaultHostIp(e.Family);
portBinding.HostPort = std::to_string(e.HostPort);

if (!hasBinding(portBindings, portBinding.HostIp, portBinding.HostPort))

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe m_mappedPorts is guaranteed not to have duplicate entries. If it did, MapPorts() would fail.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants