Skip to content

Add Open in Browser command to running containers#1429

Merged
philliphoff merged 8 commits intomasterfrom
philliphoff-browse-to-container
Nov 15, 2019
Merged

Add Open in Browser command to running containers#1429
philliphoff merged 8 commits intomasterfrom
philliphoff-browse-to-container

Conversation

@philliphoff
Copy link
Member

Adds an Open in Browser command to the context menu of running containers in the containers tree view.

Screen Shot 2019-11-14 at 11 51 43 AM

The command opens the browser to the first exposed port mapped to the host that likely represents a "web" endpoint. The heuristic works as follows:

  • Choose the first port from a prioritized list of ports common to various web stacks with SSL ports preferred over standard HTTP ports (e.g. 443, 80, 3000, 3001, 5001, 5000, 8080, 8081)
  • If none found, and if only a single port was mapped, use that port
  • Otherwise, if more than one port was mapped, display a quick-pick where the user can select the port.

Screen Shot 2019-11-14 at 11 52 00 AM

The "possible" ports as well as the selected port is captured by telemetry, in order to understand how that heuristic could be improved.

@philliphoff philliphoff requested a review from a team as a code owner November 14, 2019 20:06

if (possiblePorts.length === 0) {
// tslint:disable-next-line: no-floating-promises
ext.ui.showWarningMessage('No valid ports were mapped from the container to the host.');
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we want to leave a cancel step in telemetry here, and/or throw a UserCancelledError?

Copy link
Member Author

Choose a reason for hiding this comment

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

I tried several variants and this seemed to work best (or was the least worst). UserCancelledError doesn't seem technically correct, as the user didn't make a choice--the container just didn't have any ports to browse to. Throwing any other kind of error results in the error dialog with the "report issue" button, which we clearly don't want. You might argue that the command result should be Failed in this case, but I'm not sure it matters from the telemetry analysis point of view. We can pick out this scenario by looking for a completed command, where the possible ports is the empty set and no port was selected.

Copy link
Collaborator

Choose a reason for hiding this comment

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

For the somewhat similar case where the Azure registry already exists (the one Paul hit), I had it throw a UserCancelledError as a way of getting out of the execution; so it wouldn't be unprecedented.

@bwateratmsft bwateratmsft added this to the 0.9.0 milestone Nov 14, 2019
Copy link
Contributor

@karolz-ms karolz-ms left a comment

Choose a reason for hiding this comment

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

Looks good!, Just one question...

@philliphoff philliphoff merged commit de73eeb into master Nov 15, 2019
@philliphoff philliphoff deleted the philliphoff-browse-to-container branch November 15, 2019 20:53
@microsoft microsoft locked and limited conversation to collaborators Oct 27, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants