Skip to content

Improve ports #24

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

Closed
wants to merge 2 commits into from
Closed

Improve ports #24

wants to merge 2 commits into from

Conversation

jeanp413
Copy link
Member

Description

Related Issue(s)

Fixes gitpod-io/gitpod#8377

How to test

  1. Open a workspace with ports configured in gitpod.yml
  2. Check the ports are forwarded when connecting in ports view
  3. Run some command that uses some port
  4. Check the port is forwarded automatically

Release Notes

NONE

@@ -1028,6 +1030,71 @@ export default class RemoteConnector extends Disposable {
}
}

private async configureMachineSettings(wsConfig: WorkspaceConfig) {
Copy link
Member

Choose a reason for hiding this comment

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

Should not this logic implemented in remote extension? It has access to machine setitngs, supervisor and VS Code api. I don't see a point to implement in local extension.

@@ -1057,6 +1124,8 @@ export default class RemoteConnector extends Disposable {

await this.context.globalState.update(`${RemoteConnector.SSH_DEST_KEY}${sshDestStr}`, { ...connectionInfo, isFirstConnection: false });

this.configureMachineSettings(workspaceInfo.workspace.config).then(() => this.tunnelPortsFromConfig(workspaceInfo.workspace.config.ports ?? []));
Copy link
Member

Choose a reason for hiding this comment

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

config.ports are not real ports, they are intitial configuration for supervisor.

We should observe port status endpoint from supervisor and reconcile it with VS Code as here: https://github.com/gitpod-io/openvscode-server/blob/849af772ba8e6a3a2944ccaf004d70cb549d3f3e/extensions/gitpod-web/src/extension.ts#L551-L592


// settings.json is a json with comments file so we use jsonc-parser library
const settingsJson = parseJson(settingsStr);
if (settingsJson['remote.autoForwardPortsSource'] === undefined) {
Copy link
Member

Choose a reason for hiding this comment

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

I don't think it is necessary if we are listening to supervisor changes and call asExternalUri. Less VS Code needs to scan is better.

const machineSettingsResource = extRemoteLogsUri.with({ path: path.posix.join(remoteUserDataPath, 'Machine', 'settings.json') });
try {
let settingsStr: string = '{}';
const fileExists = await vscode.workspace.fs.stat(machineSettingsResource).then(() => true, () => false);
Copy link
Member

Choose a reason for hiding this comment

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

Should not we use document API to respect dirty changes from a user?

@jeanp413 jeanp413 closed this Sep 21, 2022
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.

VS Code Desktop: Auto forward ports from .gitpod.yml (sometimes ports are not detected or shown)
2 participants