Skip to content

Commit

Permalink
improve machine error when running on Linux
Browse files Browse the repository at this point in the history
On Linux, Podman Desktop can talk to the Podman socket of the host and
to the ones of the Linux VM.  As outlinted in #42, talking to socket of
the host's Podman is currently not supported by the extension.  While
logging into the container registry is perfectly fine, running
subscriptio-manager is not; it requires root privileges to install and
run it.  So instead of a silent error, throw a user-visible error
indicating that it's currently not supported on a Linux host.

Fixes: #42
Signed-off-by: Valentin Rothberg <[email protected]>
  • Loading branch information
vrothberg committed Feb 16, 2024
1 parent d5e55da commit 12692fd
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import path from 'node:path';
import { accessSync, constants, existsSync, readFileSync } from 'node:fs';
import { restartPodmanMachine, runRpmInstallSubscriptionManager, runSubscriptionManager, runSubscriptionManagerActivationStatus, runSubscriptionManagerRegister } from './podman-cli';
import { SubscriptionManagerClient } from '@redhat-developer/rhsm-client';
import { isLinux } from './util';

let loginService: RedHatAuthenticationService;
let currentSession: extensionApi.AuthenticationSession | undefined;
Expand Down Expand Up @@ -156,7 +157,7 @@ async function createOrReuseActivationKey() {

function isPodmanMachineRunning(): boolean {
const conns = extensionApi.provider.getContainerConnections();
const startedPodman = conns.filter(conn => conn.providerId === 'podman' && conn.connection.status() === 'started');
const startedPodman = conns.filter(conn => conn.providerId === 'podman' && conn.connection.status() === 'started' && !conn.connection.endpoint.socketPath.startsWith("/run/user/"));
return startedPodman.length === 1;
}

Expand Down Expand Up @@ -255,7 +256,11 @@ export async function activate(extensionContext: extensionApi.ExtensionContext):
location: extensionApi.ProgressLocation.TASK_WIDGET, title: 'Activating Red Hat Subscription'
}, async (progress) => {
if (!isPodmanMachineRunning()) {
await extensionApi.window.showInformationMessage('Podman machine is not running. Please start it and try again.');
if (isLinux()) {
await extensionApi.window.showInformationMessage('Signing into a Red Hat account requires a running Podman machine, and is currently not supported on a Linux host. Please start a Podman machine and try again.');
} else {
await extensionApi.window.showInformationMessage('Signing into a Red Hat account requires a running Podman machine. Please start one and try again.');
}
return;
} else {
if (!(await isSubscriptionManagerInstalled())) {
Expand Down

0 comments on commit 12692fd

Please sign in to comment.