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

fix: handle error so that it is shown in both page and task manager #247

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix: correct state during setup
Signed-off-by: lstocchi <lstocchi@redhat.com>
  • Loading branch information
lstocchi committed Oct 1, 2024
commit 9bc1a31d1cb8013634f3c8d28c7e092912819391
4 changes: 2 additions & 2 deletions src/crc-status.ts
Original file line number Diff line number Diff line change
@@ -44,7 +44,7 @@ export class CrcStatus {
try {
// we don't need to update status while setup is going
if (this.isSetupGoing) {
this._status = createStatus('Starting', this._status.Preset);
this._status = createStatus('Stopped', this._status.Preset);
return;
}
const oldStatus = this._status;
@@ -93,7 +93,7 @@ export class CrcStatus {
setSetupRunning(setup: boolean): void {
if (setup) {
this.isSetupGoing = true;
this._status = createStatus('Starting', this._status.Preset);
this._status = createStatus('Stopped', this._status.Preset);
} else {
this.isSetupGoing = false;
}
14 changes: 11 additions & 3 deletions src/extension.ts
Original file line number Diff line number Diff line change
@@ -269,7 +269,15 @@ async function initializeCrc(
): Promise<void> {
const hasToBeSetup = await needSetup();
if (hasToBeSetup) {
const hasSetupFinished = await setUpCrc(true);
crcStatus.setSetupRunning(true);
let hasSetupFinished = false;
try {
hasSetupFinished = await setUpCrc(true);
} catch (e) {
console.log(String(e));
} finally {
crcStatus.setSetupRunning(false);
}
if (!hasSetupFinished) {
throw new Error(`Failed at initializing ${productName}`);
}
@@ -346,7 +354,7 @@ function registerOpenShiftLocalCluster(
endpoint: {
apiURL,
},
status: () => 'stopped',
status: () => crcStatus.getConnectionStatus(),
};

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