From ae3b5a0157b0869e366f6a6301b0661b68fbb9f9 Mon Sep 17 00:00:00 2001 From: Denis Golovin Date: Tue, 13 Feb 2024 22:53:41 -0800 Subject: [PATCH] fix: log exit code when podman ssh command fails in VM Signed-off-by: Denis Golovin --- src/podman-cli.ts | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/src/podman-cli.ts b/src/podman-cli.ts index fa35f8b3..d69505c8 100644 --- a/src/podman-cli.ts +++ b/src/podman-cli.ts @@ -73,31 +73,43 @@ export async function runSubscriptionManager(): Promise { await extensionApi.process.exec(getPodmanCli(), PODMAN_COMMANDS.SM_VERSION()); return 0; } catch (err) { - return (err as extensionApi.RunError).exitCode; + const exitCode = (err as extensionApi.RunError).exitCode; + console.error(`Subscription manager execution returned exit code: ${exitCode}`); + return exitCode; } } -export async function runRpmInstallSubscriptionManager() { +export async function runRpmInstallSubscriptionManager(): Promise { try { await extensionApi.process.exec(getPodmanCli(), PODMAN_COMMANDS.RPM_INSTALL_SM()); return 0; } catch (err) { - return (err as extensionApi.RunError).exitCode; + const exitCode = (err as extensionApi.RunError).exitCode; + console.error(`Subscription manager installation returned exit code: ${exitCode}`); + return exitCode; } } -export async function runSubscriptionManagerActivationStatus() { +export async function runSubscriptionManagerActivationStatus(): Promise { try { await extensionApi.process.exec(getPodmanCli(), PODMAN_COMMANDS.SM_ACTIVATION_STATUS()); return 0; } catch (err) { - return (err as extensionApi.RunError).exitCode; + const exitCode = (err as extensionApi.RunError).exitCode; + console.error(`Subscription manager subscription activation check returned exit code: ${exitCode}`); + return exitCode; } } -export async function runSubscriptionManagerRegister(activationKeyName: string, orgId: string): Promise { +export async function runSubscriptionManagerRegister(activationKeyName: string, orgId: string): Promise { + try { const result = await extensionApi.process.exec(getPodmanCli(), PODMAN_COMMANDS.SM_ACTIVATE_SUBS(activationKeyName, orgId)); return 0; + } catch (err) { + const exitCode = (err as extensionApi.RunError).exitCode; + console.error(`Subscription manager registration returned exit code: ${exitCode}`); + return exitCode; + } } export async function restartPodmanMachine() {