Skip to content

Commit

Permalink
Try to find out why the test resolver extension would not be present …
Browse files Browse the repository at this point in the history
…in CI (#192938)

Try to find out why the test resolver extension would not be present in CI (#192584)
  • Loading branch information
alexdima committed Sep 12, 2023
1 parent 15c9686 commit f01155c
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 13 deletions.
21 changes: 20 additions & 1 deletion src/vs/workbench/api/common/extHostExtensionService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ import { Schemas } from 'vs/base/common/network';
import { IResolveAuthorityResult } from 'vs/workbench/services/extensions/common/extensionHostProxy';
import { IExtHostLocalizationService } from 'vs/workbench/api/common/extHostLocalizationService';
import { StopWatch } from 'vs/base/common/stopwatch';
import { setTimeout0 } from 'vs/base/common/platform';
import { isCI, setTimeout0 } from 'vs/base/common/platform';
import { IExtHostManagedSockets } from 'vs/workbench/api/common/extHostManagedSockets';
import { Dto } from 'vs/workbench/services/extensions/common/proxyIdentifier';

Expand Down Expand Up @@ -164,6 +164,12 @@ export abstract class AbstractExtHostExtensionService extends Disposable impleme
this._activationEventsReader,
filterExtensions(this._globalRegistry, myExtensionsSet)
);

if (isCI) {
this._logService.info(`Creating extension host with the following global extensions: ${printExtIds(this._globalRegistry)}`);
this._logService.info(`Creating extension host with the following local extensions: ${printExtIds(this._myRegistry)}`);
}

this._storage = new ExtHostStorage(this._extHostContext, this._logService);
this._secretState = new ExtHostSecretState(this._extHostContext);
this._storagePath = storagePath;
Expand Down Expand Up @@ -963,6 +969,11 @@ export abstract class AbstractExtHostExtensionService extends Disposable impleme
this._globalRegistry.set(globalRegistry.getAllExtensionDescriptions());
this._myRegistry.set(myExtensions);

if (isCI) {
this._logService.info(`$startExtensionHost: global extensions: ${printExtIds(this._globalRegistry)}`);
this._logService.info(`$startExtensionHost: local extensions: ${printExtIds(this._myRegistry)}`);
}

return this._startExtensionHost();
}

Expand Down Expand Up @@ -999,6 +1010,11 @@ export abstract class AbstractExtHostExtensionService extends Disposable impleme
this._globalRegistry.set(globalRegistry.getAllExtensionDescriptions());
this._myRegistry.set(myExtensions);

if (isCI) {
this._logService.info(`$deltaExtensions: global extensions: ${printExtIds(this._globalRegistry)}`);
this._logService.info(`$deltaExtensions: local extensions: ${printExtIds(this._myRegistry)}`);
}

return Promise.resolve(undefined);
}

Expand Down Expand Up @@ -1073,6 +1089,9 @@ function getTelemetryActivationEvent(extensionDescription: IExtensionDescription
return event;
}

function printExtIds(registry: ExtensionDescriptionRegistry) {
return registry.getAllExtensionDescriptions().map(ext => ext.identifier.value).join(',');
}

export const IExtHostExtensionService = createDecorator<IExtHostExtensionService>('IExtHostExtensionService');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ export class ExtensionService extends AbstractExtensionService implements IExten
instantiationService,
remoteAgentService,
remoteAuthorityResolverService,
extensionEnablementService
extensionEnablementService,
logService
);
super(
extensionsProposedApi,
Expand Down Expand Up @@ -220,6 +221,7 @@ class BrowserExtensionHostFactory implements IExtensionHostFactory {
@IRemoteAgentService private readonly _remoteAgentService: IRemoteAgentService,
@IRemoteAuthorityResolverService private readonly _remoteAuthorityResolverService: IRemoteAuthorityResolverService,
@IWorkbenchExtensionEnablementService private readonly _extensionEnablementService: IWorkbenchExtensionEnablementService,
@ILogService private readonly _logService: ILogService,
) { }

createExtensionHost(runningLocations: ExtensionRunningLocationTracker, runningLocation: ExtensionRunningLocation, isInitialStart: boolean): IExtensionHost | null {
Expand Down Expand Up @@ -250,7 +252,7 @@ class BrowserExtensionHostFactory implements IExtensionHostFactory {
getInitData: async (): Promise<IWebWorkerExtensionHostInitData> => {
if (isInitialStart) {
// Here we load even extensions that would be disabled by workspace trust
const localExtensions = checkEnabledAndProposedAPI(this._extensionEnablementService, this._extensionsProposedApi, await this._scanWebExtensions(), /* ignore workspace trust */true);
const localExtensions = checkEnabledAndProposedAPI(this._logService, this._extensionEnablementService, this._extensionsProposedApi, await this._scanWebExtensions(), /* ignore workspace trust */true);
const runningLocation = runningLocations.computeRunningLocation(localExtensions, [], false);
const myExtensions = filterExtensionDescriptions(localExtensions, runningLocation, extRunningLocation => desiredRunningLocation.equals(extRunningLocation));
return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { Emitter } from 'vs/base/common/event';
import { Disposable } from 'vs/base/common/lifecycle';
import { Schemas } from 'vs/base/common/network';
import * as perf from 'vs/base/common/performance';
import { isCI } from 'vs/base/common/platform';
import { isEqualOrParent } from 'vs/base/common/resources';
import { StopWatch } from 'vs/base/common/stopwatch';
import { URI } from 'vs/base/common/uri';
Expand Down Expand Up @@ -138,11 +139,17 @@ export abstract class AbstractExtensionService extends Disposable implements IEx
toRemove.push(extension);
}
}
if (isCI) {
this._logService.info(`AbstractExtensionService.onEnablementChanged fired for ${extensions.map(e => e.identifier.id).join(', ')}`);
}
this._handleDeltaExtensions(new DeltaExtensionsQueueItem(toAdd, toRemove));
}));

this._register(this._extensionManagementService.onDidChangeProfile(({ added, removed }) => {
if (added.length || removed.length) {
if (isCI) {
this._logService.info(`AbstractExtensionService.onDidChangeProfile fired`);
}
this._handleDeltaExtensions(new DeltaExtensionsQueueItem(added, removed));
}
}));
Expand All @@ -155,13 +162,19 @@ export abstract class AbstractExtensionService extends Disposable implements IEx
}
}
if (extensions.length) {
if (isCI) {
this._logService.info(`AbstractExtensionService.onDidInstallExtensions fired for ${extensions.map(e => e.identifier.id).join(', ')}`);
}
this._handleDeltaExtensions(new DeltaExtensionsQueueItem(extensions, []));
}
}));

this._register(this._extensionManagementService.onDidUninstallExtension((event) => {
if (!event.error) {
// an extension has been uninstalled
if (isCI) {
this._logService.info(`AbstractExtensionService.onDidUninstallExtension fired for ${event.identifier.id}`);
}
this._handleDeltaExtensions(new DeltaExtensionsQueueItem([], [event.identifier.id]));
}
}));
Expand Down Expand Up @@ -218,6 +231,9 @@ export abstract class AbstractExtensionService extends Disposable implements IEx
}

private async _deltaExtensions(lock: ExtensionDescriptionRegistryLock, _toAdd: IExtension[], _toRemove: string[] | IExtension[]): Promise<void> {
if (isCI) {
this._logService.info(`AbstractExtensionService._deltaExtensions: toAdd: [${_toAdd.map(e => e.identifier.id).join(',')}] toRemove: [${_toRemove.map(e => typeof e === 'string' ? e : e.identifier.id).join(',')}]`);
}
let toRemove: IExtensionDescription[] = [];
for (let i = 0, len = _toRemove.length; i < len; i++) {
const extensionOrId = _toRemove[i];
Expand Down Expand Up @@ -301,6 +317,11 @@ export abstract class AbstractExtensionService extends Disposable implements IEx
const myToAdd = this._runningLocations.filterByExtensionHostManager(toAdd, extensionHostManager);
const myToRemove = filterExtensionIdentifiers(toRemove, removedRunningLocation, extRunningLocation => extensionHostManager.representsRunningLocation(extRunningLocation));
const addActivationEvents = ImplicitActivationEvents.createActivationEventsMap(toAdd);
if (isCI) {
const printExtIds = (extensions: IExtensionDescription[]) => extensions.map(e => e.identifier.value).join(',');
const printIds = (extensions: ExtensionIdentifier[]) => extensions.map(e => e.value).join(',');
this._logService.info(`AbstractExtensionService: Calling deltaExtensions: toRemove: [${printIds(toRemove)}], toAdd: [${printExtIds(toAdd)}], myToRemove: [${printIds(myToRemove)}], myToAdd: [${printExtIds(myToAdd)}],`);
}
await extensionHostManager.deltaExtensions({ toRemove, toAdd, addActivationEvents, myToRemove, myToAdd: myToAdd.map(extension => extension.identifier) });
}

Expand Down Expand Up @@ -437,8 +458,8 @@ export abstract class AbstractExtensionService extends Disposable implements IEx

private _processExtensions(lock: ExtensionDescriptionRegistryLock, resolvedExtensions: ResolvedExtensions): void {
const { allowRemoteExtensionsInLocalWebWorker, hasLocalProcess } = resolvedExtensions;
const localExtensions = checkEnabledAndProposedAPI(this._extensionEnablementService, this._extensionsProposedApi, resolvedExtensions.local, false);
let remoteExtensions = checkEnabledAndProposedAPI(this._extensionEnablementService, this._extensionsProposedApi, resolvedExtensions.remote, false);
const localExtensions = checkEnabledAndProposedAPI(this._logService, this._extensionEnablementService, this._extensionsProposedApi, resolvedExtensions.local, false);
let remoteExtensions = checkEnabledAndProposedAPI(this._logService, this._extensionEnablementService, this._extensionsProposedApi, resolvedExtensions.remote, false);

// `initializeRunningLocation` will look at the complete picture (e.g. an extension installed on both sides),
// takes care of duplicates and picks a running location for each extension
Expand Down Expand Up @@ -1167,19 +1188,19 @@ class DeltaExtensionsQueueItem {
* @argument extensions The extensions to be checked.
* @argument ignoreWorkspaceTrust Do not take workspace trust into account.
*/
export function checkEnabledAndProposedAPI(extensionEnablementService: IWorkbenchExtensionEnablementService, extensionsProposedApi: ExtensionsProposedApi, extensions: IExtensionDescription[], ignoreWorkspaceTrust: boolean): IExtensionDescription[] {
export function checkEnabledAndProposedAPI(logService: ILogService, extensionEnablementService: IWorkbenchExtensionEnablementService, extensionsProposedApi: ExtensionsProposedApi, extensions: IExtensionDescription[], ignoreWorkspaceTrust: boolean): IExtensionDescription[] {
// enable or disable proposed API per extension
extensionsProposedApi.updateEnabledApiProposals(extensions);

// keep only enabled extensions
return filterEnabledExtensions(extensionEnablementService, extensions, ignoreWorkspaceTrust);
return filterEnabledExtensions(logService, extensionEnablementService, extensions, ignoreWorkspaceTrust);
}

/**
* Return the subset of extensions that are enabled.
* @argument ignoreWorkspaceTrust Do not take workspace trust into account.
*/
export function filterEnabledExtensions(extensionEnablementService: IWorkbenchExtensionEnablementService, extensions: IExtensionDescription[], ignoreWorkspaceTrust: boolean): IExtensionDescription[] {
export function filterEnabledExtensions(logService: ILogService, extensionEnablementService: IWorkbenchExtensionEnablementService, extensions: IExtensionDescription[], ignoreWorkspaceTrust: boolean): IExtensionDescription[] {
const enabledExtensions: IExtensionDescription[] = [], extensionsToCheck: IExtensionDescription[] = [], mappedExtensions: IExtension[] = [];
for (const extension of extensions) {
if (extension.isUnderDevelopment) {
Expand All @@ -1195,6 +1216,10 @@ export function filterEnabledExtensions(extensionEnablementService: IWorkbenchEx
for (let index = 0; index < enablementStates.length; index++) {
if (extensionEnablementService.isEnabledEnablementState(enablementStates[index])) {
enabledExtensions.push(extensionsToCheck[index]);
} else {
if (isCI) {
logService.info(`filterEnabledExtensions: extension '${extensionsToCheck[index].identifier.value}' is disabled`);
}
}
}

Expand All @@ -1205,8 +1230,8 @@ export function filterEnabledExtensions(extensionEnablementService: IWorkbenchEx
* @argument extension The extension to be checked.
* @argument ignoreWorkspaceTrust Do not take workspace trust into account.
*/
export function extensionIsEnabled(extensionEnablementService: IWorkbenchExtensionEnablementService, extension: IExtensionDescription, ignoreWorkspaceTrust: boolean): boolean {
return filterEnabledExtensions(extensionEnablementService, [extension], ignoreWorkspaceTrust).includes(extension);
export function extensionIsEnabled(logService: ILogService, extensionEnablementService: IWorkbenchExtensionEnablementService, extension: IExtensionDescription, ignoreWorkspaceTrust: boolean): boolean {
return filterEnabledExtensions(logService, extensionEnablementService, [extension], ignoreWorkspaceTrust).includes(extension);
}

function includes(extensions: IExtensionDescription[], identifier: ExtensionIdentifier): boolean {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ export class NativeExtensionService extends AbstractExtensionService implements
extensionEnablementService,
configurationService,
remoteAgentService,
remoteAuthorityResolverService
remoteAuthorityResolverService,
logService
);
super(
extensionsProposedApi,
Expand Down Expand Up @@ -463,7 +464,7 @@ export class NativeExtensionService extends AbstractExtensionService implements
const allExtensions = await this._scanAllLocalExtensions();
const extension = allExtensions.filter(e => e.identifier.value === resolverExtensionId)[0];
if (extension) {
if (!extensionIsEnabled(this._extensionEnablementService, extension, false)) {
if (!extensionIsEnabled(this._logService, this._extensionEnablementService, extension, false)) {
const message = nls.localize('enableResolver', "Extension '{0}' is required to open the remote window.\nOK to enable?", recommendation.friendlyName);
this._notificationService.prompt(Severity.Info, message,
[{
Expand Down Expand Up @@ -524,6 +525,7 @@ class NativeExtensionHostFactory implements IExtensionHostFactory {
@IConfigurationService configurationService: IConfigurationService,
@IRemoteAgentService private readonly _remoteAgentService: IRemoteAgentService,
@IRemoteAuthorityResolverService private readonly _remoteAuthorityResolverService: IRemoteAuthorityResolverService,
@ILogService private readonly _logService: ILogService,
) {
this._webWorkerExtHostEnablement = determineLocalWebWorkerExtHostEnablement(environmentService, configurationService);
}
Expand Down Expand Up @@ -564,9 +566,22 @@ class NativeExtensionHostFactory implements IExtensionHostFactory {
getInitData: async (): Promise<ILocalProcessExtensionHostInitData> => {
if (isInitialStart) {
// Here we load even extensions that would be disabled by workspace trust
const localExtensions = checkEnabledAndProposedAPI(this._extensionEnablementService, this._extensionsProposedApi, await this._extensionScanner.scannedExtensions, /* ignore workspace trust */true);
const scannedExtensions = await this._extensionScanner.scannedExtensions;
if (isCI) {
this._logService.info(`NativeExtensionHostFactory._createLocalProcessExtensionHostDataProvider.scannedExtensions: ${scannedExtensions.map(ext => ext.identifier.value).join(',')}`);
}

const localExtensions = checkEnabledAndProposedAPI(this._logService, this._extensionEnablementService, this._extensionsProposedApi, scannedExtensions, /* ignore workspace trust */true);
if (isCI) {
this._logService.info(`NativeExtensionHostFactory._createLocalProcessExtensionHostDataProvider.localExtensions: ${localExtensions.map(ext => ext.identifier.value).join(',')}`);
}

const runningLocation = runningLocations.computeRunningLocation(localExtensions, [], false);
const myExtensions = filterExtensionDescriptions(localExtensions, runningLocation, extRunningLocation => desiredRunningLocation.equals(extRunningLocation));
if (isCI) {
this._logService.info(`NativeExtensionHostFactory._createLocalProcessExtensionHostDataProvider.myExtensions: ${myExtensions.map(ext => ext.identifier.value).join(',')}`);
}

return {
allExtensions: localExtensions,
myExtensions: myExtensions.map(extension => extension.identifier)
Expand Down

0 comments on commit f01155c

Please sign in to comment.