Skip to content

Commit f5edaa6

Browse files
committed
fix: correct state during setup
Signed-off-by: lstocchi <[email protected]>
1 parent 3b3e1c2 commit f5edaa6

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

src/crc-status.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export class CrcStatus {
4444
try {
4545
// we don't need to update status while setup is going
4646
if (this.isSetupGoing) {
47-
this._status = createStatus('Starting', this._status.Preset);
47+
this._status = createStatus('Stopped', this._status.Preset);
4848
return;
4949
}
5050
const oldStatus = this._status;
@@ -93,7 +93,7 @@ export class CrcStatus {
9393
setSetupRunning(setup: boolean): void {
9494
if (setup) {
9595
this.isSetupGoing = true;
96-
this._status = createStatus('Starting', this._status.Preset);
96+
this._status = createStatus('Stopped', this._status.Preset);
9797
} else {
9898
this.isSetupGoing = false;
9999
}

src/extension.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,15 @@ async function initializeCrc(
269269
): Promise<void> {
270270
const hasToBeSetup = await needSetup();
271271
if (hasToBeSetup) {
272-
const hasSetupFinished = await setUpCrc(true);
272+
crcStatus.setSetupRunning(true);
273+
let hasSetupFinished = false;
274+
try {
275+
hasSetupFinished = await setUpCrc(true);
276+
} catch (e) {
277+
console.log(String(e));
278+
} finally {
279+
crcStatus.setSetupRunning(false);
280+
}
273281
if (!hasSetupFinished) {
274282
throw new Error(`Failed at initializing ${productName}`);
275283
}
@@ -346,7 +354,7 @@ function registerOpenShiftLocalCluster(
346354
endpoint: {
347355
apiURL,
348356
},
349-
status: () => 'stopped',
357+
status: () => crcStatus.getConnectionStatus(),
350358
};
351359

352360
connectionDisposable = provider.registerKubernetesProviderConnection(kubernetesProviderConnection);
@@ -432,6 +440,6 @@ async function presetChanged(
432440
// podman connection
433441
registerPodmanConnection(provider, extensionContext);
434442
} else if (preset === 'openshift' || preset === 'microshift') {
435-
await registerOpenShiftLocalCluster(getPresetLabel(preset), provider, extensionContext, telemetryLogger);
443+
registerOpenShiftLocalCluster(getPresetLabel(preset), provider, extensionContext, telemetryLogger);
436444
}
437445
}

0 commit comments

Comments
 (0)