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

Docker context support #1790

Merged
merged 11 commits into from
Mar 30, 2020
Merged

Docker context support #1790

merged 11 commits into from
Mar 30, 2020

Conversation

karolz-ms
Copy link
Contributor

Docker context changes are detected and UI/commands are refreshed accordingly

Also cleans up warning suppressions for async Dockerode calls and does a few minor refactorings

@karolz-ms karolz-ms requested a review from a team as a code owner March 26, 2020 00:41
@karolz-ms
Copy link
Contributor Author

Tested on MacOS, Windows and Ubuntu. Still fighting with WSL2+Docker Desktop Edge...

@karolz-ms
Copy link
Contributor Author

WSL2 is working ☺️

Will fix tests tomorrow

src/tree/containers/ContainerTreeItem.ts Show resolved Hide resolved
src/tree/images/ImageTreeItem.ts Show resolved Hide resolved
src/tree/networks/NetworkTreeItem.ts Show resolved Hide resolved
src/tree/volumes/VolumeTreeItem.ts Show resolved Hide resolved
src/debugging/DockerServerReadyAction.ts Outdated Show resolved Hide resolved
src/utils/callDockerode.ts Outdated Show resolved Hide resolved
src/utils/callDockerode.ts Outdated Show resolved Hide resolved
const DOCKER_CONTEXT: string = 'DOCKER_CONTEXT';
const DefaultRefreshIntervalSec: number = 20;
const osp = new LocalOSProvider();
const DockerConfigFilePath: string = osp.pathJoin(osp.os, osp.homedir, '.docker', 'config.json');
Copy link
Collaborator

Choose a reason for hiding this comment

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

@philliphoff might disagree so I definitely want him to chime in if he feels strongly--
I'd rather leave LocalOSProvider where it is, and just us os for this. We run our tests across all three platforms which mitigates the need for a unit-test-overridable OS provider. Relatedly, I did some perf analysis recently and the time spent in registerDebugConfigurationProvider (which initializes a lot of these XProviders / XManagers) during extension activation was surprisingly long.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sounds good. The rationale for this change is that I needed to construct a file path in a platform-neutral way and the LocalOSProvider functionality was a very good fit.

Also, LocalOSProvider really isn't specific to debugging in any way, and in this case I am just using it to initialize the manager, so no registration is taking place.

Copy link
Collaborator

@bwateratmsft bwateratmsft Mar 27, 2020

Choose a reason for hiding this comment

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

Surprisingly it wasn't the registering, but all the constructing, that was slowing things down. IIRC that single function was around 30-50% of our non-loading-of-files activation time.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Something fishy must be going on here. LocalOSProvider doesn't even have a constructor defined. And it has no state. It is just a bunch of methods.

Copy link
Collaborator

Choose a reason for hiding this comment

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

It wasn't only LocalOSProvider, there were a couple dozen parts being constructed and assembled.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So @philliphoff what do you think about lifting LocalOSProvider into utilities?

Copy link
Member

Choose a reason for hiding this comment

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

I think it's fine to lift LocalOSProvider out of the debugging folder and make it a more generalized service. I'm not sure I'd switch to os directly (yet) until I saw the data that new'ing even a couple dozen objects was, itself, a significant performance hit (and not a consequence of something else being done in registerDebugConfigurationProvider()). Even then, just dispensing with that individual service wouldn't (one would think) save any significant amount of time, so it would still have benefit from being consistent with the DI pattern of the other components. (As opposed to a larger refactor to optimize load/init performance where we might rethink the DI pattern altogether.)

Copy link
Collaborator

Choose a reason for hiding this comment

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

@philliphoff @karolz-ms Sounds good. In any case, by far the majority of the activation time is in loading/compiling the JS--by a couple orders of magnitude. The only ways we can improve on that are to reduce our dependencies and to lazy-load, if that's possible.

src/utils/dockerContextManager.ts Outdated Show resolved Hide resolved
src/utils/dockerContextManager.ts Outdated Show resolved Hide resolved
package.nls.json Outdated Show resolved Hide resolved
Copy link
Collaborator

@bwateratmsft bwateratmsft 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 to me. There's the one item I added about package.nls.json; and let's reach consensus on the LocalOSProvider thing.

@karolz-ms karolz-ms merged commit 91b0d82 into microsoft:master Mar 30, 2020
@karolz-ms karolz-ms deleted the dev/karolz/docker-context branch May 11, 2020 15:11
Dmarch28 pushed a commit to Dmarch28/vscode-docker that referenced this pull request Mar 4, 2021
Docker context changes are detected and UI/commands are refreshed accordingly
Also cleans up warning suppressions for async Dockerode calls
@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.

3 participants