mirror of
https://github.com/rancher-sandbox/rancher-desktop.git
synced 2021-10-13 00:04:06 +03:00
Add a VM_STARTED state
* This is the point where containerd is running, so we can get images * Change UI so it no longer suggests the image manager is dependent on Kubernetes. Signed-off-by: Eric Promislow <epromislow@suse.com>
This commit is contained in:
@@ -259,7 +259,7 @@ async function relayImageProcessorNamespaces() {
|
||||
}
|
||||
|
||||
Electron.ipcMain.on('images-namespaces-read', (event) => {
|
||||
if (k8smanager.state === K8s.State.STARTED) {
|
||||
if ([K8s.State.VM_STARTED, K8s.State.STARTED].includes(k8smanager.state)) {
|
||||
relayImageProcessorNamespaces().catch((err) => {
|
||||
console.log('Error trying to get namespaces: ', err);
|
||||
});
|
||||
@@ -284,7 +284,7 @@ function writeSettings(arg: RecursivePartial<settings.Settings>) {
|
||||
mainEvents.emit('settings-update', cfg);
|
||||
|
||||
Electron.ipcMain.emit('k8s-restart-required');
|
||||
if (imageProcessor.namespace !== cfg.images.namespace) {
|
||||
if (imageProcessor && imageProcessor.namespace !== cfg.images.namespace) {
|
||||
imageProcessor.namespace = cfg.images.namespace;
|
||||
imageProcessor.refreshImages().catch((err) => {
|
||||
console.log(`Error refreshing images:`, err);
|
||||
@@ -354,6 +354,7 @@ Electron.ipcMain.on('k8s-restart', async() => {
|
||||
try {
|
||||
switch (k8smanager.state) {
|
||||
case K8s.State.STOPPED:
|
||||
case K8s.State.VM_STARTED:
|
||||
case K8s.State.STARTED:
|
||||
// Calling start() will restart the backend, possible switching versions
|
||||
// as a side-effect.
|
||||
|
||||
@@ -95,10 +95,7 @@
|
||||
</Card>
|
||||
</div>
|
||||
<div v-else>
|
||||
<h3 v-if="state === 'K8S_UNREADY'">
|
||||
{{ t('images.state.k8sUnready') }}
|
||||
</h3>
|
||||
<h3 v-else-if="state === 'IMAGE_MANAGER_UNREADY'">
|
||||
<h3 v-if="state === 'IMAGE_MANAGER_UNREADY'">
|
||||
{{ t('images.state.imagesUnready') }}
|
||||
</h3>
|
||||
<h3 v-else>
|
||||
@@ -125,19 +122,23 @@ export default {
|
||||
type: Array,
|
||||
required: true,
|
||||
},
|
||||
imageNamespaces: {
|
||||
type: Array,
|
||||
required: true,
|
||||
},
|
||||
selectedNamespace: {
|
||||
type: String,
|
||||
default: 'default',
|
||||
},
|
||||
state: {
|
||||
type: String,
|
||||
default: 'K8S_UNREADY',
|
||||
validator: value => ['K8S_UNREADY', 'IMAGE_MANAGER_UNREADY', 'READY'].includes(value),
|
||||
default: 'IMAGE_MANAGER_UNREADY',
|
||||
validator: value => ['IMAGE_MANAGER_UNREADY', 'READY'].includes(value),
|
||||
},
|
||||
showAll: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
selectedNamespace: {
|
||||
type: String,
|
||||
default: 'default',
|
||||
}
|
||||
},
|
||||
|
||||
data() {
|
||||
@@ -174,7 +175,6 @@ export default {
|
||||
fieldToClear: '',
|
||||
imageOutputCuller: null,
|
||||
mainWindowScroll: -1,
|
||||
imageNamespaces: [],
|
||||
postCloseOutputWindowHandler: null,
|
||||
};
|
||||
},
|
||||
@@ -269,10 +269,6 @@ export default {
|
||||
ipcRenderer.on('image-process-output', (event, data, isStderr) => {
|
||||
this.appendImageManagerOutput(data, isStderr);
|
||||
});
|
||||
ipcRenderer.on('images-namespaces', (event, namespaces) => {
|
||||
this.imageNamespaces = namespaces;
|
||||
});
|
||||
ipcRenderer.send('images-namespaces-read');
|
||||
},
|
||||
|
||||
methods: {
|
||||
|
||||
@@ -67,7 +67,7 @@ export abstract class ImageProcessor extends EventEmitter {
|
||||
}
|
||||
});
|
||||
mainEvents.on('k8s-check-state', (mgr: K8s.KubernetesBackend) => {
|
||||
this.isK8sReady = mgr.state === K8s.State.STARTED;
|
||||
this.isK8sReady = [K8s.State.VM_STARTED, K8s.State.STARTED].includes(mgr.state);
|
||||
this.updateWatchStatus();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ export { KubeClient as Client, ServiceEntry } from './client';
|
||||
export enum State {
|
||||
STOPPED = 0, // The engine is not running.
|
||||
STARTING, // The engine is attempting to start.
|
||||
VM_STARTED, // The VM is up, but k8s hasn't started yet
|
||||
STARTED, // The engine is started; the dashboard is not yet ready.
|
||||
STOPPING, // The engine is attempting to stop.
|
||||
ERROR, // There is an error and we cannot recover automatically.
|
||||
|
||||
@@ -30,13 +30,6 @@ import K3sHelper, { ShortVersion } from './k3sHelper';
|
||||
import ProgressTracker from './progressTracker';
|
||||
import * as K8s from './k8s';
|
||||
|
||||
// Helpers for setting progress
|
||||
enum Progress {
|
||||
INDETERMINATE = '<indeterminate>',
|
||||
DONE = '<done>',
|
||||
EMPTY = '<empty>',
|
||||
}
|
||||
|
||||
/**
|
||||
* Enumeration for tracking what operation the backend is undergoing.
|
||||
*/
|
||||
@@ -753,6 +746,7 @@ export default class LimaBackend extends events.EventEmitter implements K8s.Kube
|
||||
console.debug('/etc/rancher/k3s/k3s.yaml is ready.');
|
||||
}
|
||||
);
|
||||
this.setState(K8s.State.VM_STARTED);
|
||||
await this.progressTracker.action(
|
||||
'Updating kubeconfig',
|
||||
50,
|
||||
@@ -785,7 +779,7 @@ export default class LimaBackend extends events.EventEmitter implements K8s.Kube
|
||||
100,
|
||||
this.client?.waitForReadyNodes() ?? Promise.reject(new Error('No client')));
|
||||
|
||||
this.setState(K8s.State.STARTED);
|
||||
this.setState(K8s.State.VM_STARTED);
|
||||
} catch (err) {
|
||||
console.error('Error starting lima:', err);
|
||||
this.setState(K8s.State.ERROR);
|
||||
|
||||
@@ -174,11 +174,12 @@ export class Tray {
|
||||
|
||||
protected updateMenu() {
|
||||
const labels = {
|
||||
[State.STOPPED]: 'Kubernetes is stopped',
|
||||
[State.STARTING]: 'Kubernetes is starting',
|
||||
[State.STARTED]: 'Kubernetes is running',
|
||||
[State.STOPPING]: 'Kubernetes is shutting down',
|
||||
[State.ERROR]: 'Kubernetes has encountered an error',
|
||||
[State.STOPPED]: 'Kubernetes is stopped',
|
||||
[State.STARTING]: 'Kubernetes is starting',
|
||||
[State.VM_STARTED]: 'VM is ready',
|
||||
[State.STARTED]: 'Kubernetes is running',
|
||||
[State.STOPPING]: 'Kubernetes is shutting down',
|
||||
[State.ERROR]: 'Kubernetes has encountered an error',
|
||||
};
|
||||
|
||||
let icon = resources.get('icons/kubernetes-icon-black.png');
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
<Images
|
||||
class="content"
|
||||
:images="images"
|
||||
:image-namespaces="imageNamespaces"
|
||||
:state="state"
|
||||
:show-all="settings.images.showAll"
|
||||
:selected-namespace="settings.images.namespace"
|
||||
@@ -25,13 +26,14 @@ export default {
|
||||
k8sState: ipcRenderer.sendSync('k8s-state'),
|
||||
imageManagerState: false,
|
||||
images: [],
|
||||
imageNamespaces: [],
|
||||
};
|
||||
},
|
||||
|
||||
computed: {
|
||||
state() {
|
||||
if (this.k8sState !== K8s.State.STARTED) {
|
||||
return 'K8S_UNREADY';
|
||||
if (![K8s.State.VM_STARTED, K8s.State.STARTED].includes(this.k8sState)) {
|
||||
return 'IMAGE_MANAGER_UNREADY';
|
||||
}
|
||||
|
||||
return this.imageManagerState ? 'READY' : 'IMAGE_MANAGER_UNREADY';
|
||||
@@ -45,6 +47,9 @@ export default {
|
||||
);
|
||||
ipcRenderer.on('images-changed', (event, images) => {
|
||||
this.$data.images = images;
|
||||
if (this.$data.imageNamespaces.length === 0) {
|
||||
ipcRenderer.send('images-namespaces-read');
|
||||
}
|
||||
});
|
||||
ipcRenderer.on('k8s-check-state', (event, state) => {
|
||||
this.$data.k8sState = state;
|
||||
@@ -62,6 +67,10 @@ export default {
|
||||
(async() => {
|
||||
this.$data.imageManagerState = await ipcRenderer.invoke('images-check-state');
|
||||
})();
|
||||
ipcRenderer.on('images-namespaces', (event, namespaces) => {
|
||||
this.$data.imageNamespaces = namespaces;
|
||||
});
|
||||
ipcRenderer.send('images-namespaces-read');
|
||||
},
|
||||
|
||||
beforeDestroy() {
|
||||
|
||||
Reference in New Issue
Block a user