Improve auto-forwarding for GitHub Codespaces and devcontainers.#6780
Improve auto-forwarding for GitHub Codespaces and devcontainers.#6780mitchdenny merged 11 commits intomainfrom
Conversation
55d1717 to
ce5666a
Compare
|
We can’t mutate global machine state from the apphost. |
I think this is the only way we can do it unless we are given an API. |
fef7f8b to
9875f94
Compare
…s in cloud vs. codespaces locally.
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
| _devcontainersOptions = devcontainersOptions; | ||
| } | ||
|
|
||
| public async Task AfterEndpointsAllocatedAsync(DistributedApplicationModel appModel, CancellationToken cancellationToken) |
There was a problem hiding this comment.
Why do we want to use this event instead of BeforeResourceStart? That way it's not blocking startup of the dashboard.
There was a problem hiding this comment.
It is important to dump out the port forwarded URLs as soon as possible after the ports are allocated so that no other log message triggers port forwarding before the port attributes details are written to the log file. Otherwise they'll be forwarded with incorrect attributes (label missing, incorrect protocol etc).
There was a problem hiding this comment.
Also even though this executes before the dashboard starts its a local I/O operation so not a huge impact to overall start performance. In my experimentation the dashboard is up and running before I've decided to interact with it.
|
Great work @mitchdenny ! |
Description
This PR improves support for automatically forwarding ports for the following dev container scenarios:
This works by introducing a lifecycle hook that executes after endpoints are allocated. If execution within a codespace or local devcontainer is detected the hook will trigger the update to the machine wide
settings.jsonfile based on the configuration of endpoints within resources. In codespaces only http and https endpoints will be forwarded (developers can always set manual forwarding).There is some timing sensitivity here. The settings file needs to be updated before it sees the endpoint in the console logs, if it doesn't there is a chance that the wrong protocol/label will be applied.
Checklist
<remarks />and<code />elements on your triple slash comments?breaking-changetemplate):doc-ideatemplate):Microsoft Reviewers: Open in CodeFlow