Skip to content

Commit

Permalink
KUBECONFIG for steve must point to only a single config file
Browse files Browse the repository at this point in the history
Signed-off-by: Jan Dubois <[email protected]>
  • Loading branch information
jandubois committed Feb 10, 2025
1 parent 163a426 commit 6a4ee05
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 19 deletions.
40 changes: 22 additions & 18 deletions background.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1243,27 +1243,31 @@ function newK8sManager() {
const arch = process.arch === 'arm64' ? 'aarch64' : 'x86_64';
const mgr = K8sFactory(arch, dockerDirManager);

mgr.on('state-changed', (state: K8s.State) => {
mainEvents.emit('k8s-check-state', mgr);
window.send('k8s-check-state', state);
if ([K8s.State.STARTED, K8s.State.DISABLED].includes(state)) {
if (!cfg.kubernetes.version) {
writeSettings({ kubernetes: { version: mgr.kubeBackend.version } });
}
currentImageProcessor?.relayNamespaces();
mgr.on('state-changed', async(state: K8s.State) => {
try {
mainEvents.emit('k8s-check-state', mgr);
window.send('k8s-check-state', state);
if ([K8s.State.STARTED, K8s.State.DISABLED].includes(state)) {
if (!cfg.kubernetes.version) {
writeSettings({ kubernetes: { version: mgr.kubeBackend.version } });
}
currentImageProcessor?.relayNamespaces();

if (enabledK8s) {
Steve.getInstance().start();
if (enabledK8s) {
await Steve.getInstance().start();
}
}
}

if (state === K8s.State.STOPPING) {
Steve.getInstance().stop();
}
if (pendingRestartContext !== undefined && !backendIsBusy()) {
// If we restart immediately the QEMU process in the VM doesn't always respond to a shutdown messages
setTimeout(doFullRestart, 2_000, pendingRestartContext);
pendingRestartContext = undefined;
if (state === K8s.State.STOPPING) {
Steve.getInstance().stop();
}
if (pendingRestartContext !== undefined && !backendIsBusy()) {
// If we restart immediately the QEMU process in the VM doesn't always respond to a shutdown messages
setTimeout(doFullRestart, 2_000, pendingRestartContext);
pendingRestartContext = undefined;
}
} catch (ex) {
console.error(ex);
}
});

Expand Down
10 changes: 9 additions & 1 deletion pkg/rancher-desktop/backend/steve.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { ChildProcess, spawn } from 'child_process';
import os from 'os';
import path from 'path';

import K3sHelper from '@pkg/backend/k3sHelper';
import Logging from '@pkg/utils/logging';
import paths from '@pkg/utils/paths';

Expand Down Expand Up @@ -35,7 +36,7 @@ export class Steve {
/**
* @description Starts the Steve API if one is not already running.
*/
public start() {
public async start() {
const { pid } = this.process || { };

if (this.isRunning && pid) {
Expand All @@ -46,7 +47,13 @@ export class Steve {

const osSpecificName = /^win/i.test(os.platform()) ? 'steve.exe' : 'steve';
const stevePath = path.join(paths.resources, os.platform(), 'internal', osSpecificName);
const env = Object.assign({}, process.env);

try {
env.KUBECONFIG = await K3sHelper.findKubeConfigToUpdate('rancher-desktop');
} catch {
// do nothing
}
this.process = spawn(
stevePath,
[
Expand All @@ -57,6 +64,7 @@ export class Steve {
'--offline',
'true',
],
{ env },
);

const { stdout, stderr } = this.process;
Expand Down

0 comments on commit 6a4ee05

Please sign in to comment.