-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Add WSLA runtime inspect schema and mapping #14132
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
base: feature/wsl-for-apps
Are you sure you want to change the base?
Add WSLA runtime inspect schema and mapping #14132
Conversation
| wslaInspect.Id = dockerInspect.Id; | ||
| wslaInspect.Name = dockerInspect.Name; | ||
|
|
||
| // Remove leading '/' from Docker container names. |
There was a problem hiding this comment.
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.
OneBlue
left a comment
There was a problem hiding this 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( |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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"); |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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)) |
There was a problem hiding this comment.
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.
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
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