mirror of
https://github.com/balena-os/balena-supervisor.git
synced 2025-05-02 00:52:57 +00:00
Backwards compatility changes for old resin namespaces
Change-type: patch Signed-off-by: Kyle Harding <kyle@balena.io>
This commit is contained in:
parent
09615c9d82
commit
301aa52f03
@ -60,6 +60,7 @@ export class EngineSnapshotRecord {
|
|||||||
|
|
||||||
/** Container name used to inspect own resources when container ID cannot be resolved. */
|
/** Container name used to inspect own resources when container ID cannot be resolved. */
|
||||||
const SUPERVISOR_CONTAINER_NAME_FALLBACK = 'balena_supervisor';
|
const SUPERVISOR_CONTAINER_NAME_FALLBACK = 'balena_supervisor';
|
||||||
|
const SUPERVISOR_LEGACY_CONTAINER_NAME_FALLBACK = 'resin_supervisor';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class handles any special cases necessary for switching
|
* This class handles any special cases necessary for switching
|
||||||
@ -162,14 +163,25 @@ export class LocalModeManager {
|
|||||||
);
|
);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (this.containerId !== undefined) {
|
if (this.containerId !== undefined) {
|
||||||
// Inspect operation fails (container ID is out of sync?).
|
try {
|
||||||
const fallback = SUPERVISOR_CONTAINER_NAME_FALLBACK;
|
// Inspect operation fails (container ID is out of sync?).
|
||||||
log.warn(
|
const fallback = SUPERVISOR_CONTAINER_NAME_FALLBACK;
|
||||||
'Supervisor container resources cannot be obtained by container ID. ' +
|
log.warn(
|
||||||
`Using '${fallback}' name instead.`,
|
'Supervisor container resources cannot be obtained by container ID. ' +
|
||||||
e.message,
|
`Using '${fallback}' name instead.`,
|
||||||
);
|
e.message,
|
||||||
return this.collectContainerResources(fallback);
|
);
|
||||||
|
return this.collectContainerResources(fallback);
|
||||||
|
} catch (e) {
|
||||||
|
// Inspect operation fails (using legacy container name?).
|
||||||
|
const fallback = SUPERVISOR_LEGACY_CONTAINER_NAME_FALLBACK;
|
||||||
|
log.warn(
|
||||||
|
'Supervisor container resources cannot be obtained by container ID. ' +
|
||||||
|
`Using '${fallback}' name instead.`,
|
||||||
|
e.message,
|
||||||
|
);
|
||||||
|
return this.collectContainerResources(fallback);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
throw new SupervisorContainerNotFoundError(e);
|
throw new SupervisorContainerNotFoundError(e);
|
||||||
}
|
}
|
||||||
|
@ -158,7 +158,11 @@ class LogMonitor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private handleRow(row: JournalRow) {
|
private handleRow(row: JournalRow) {
|
||||||
if (row.CONTAINER_ID_FULL && row.CONTAINER_NAME !== 'balena_supervisor') {
|
if (
|
||||||
|
row.CONTAINER_ID_FULL &&
|
||||||
|
row.CONTAINER_NAME !== 'balena_supervisor' &&
|
||||||
|
row.CONTAINER_NAME !== 'resin_supervisor'
|
||||||
|
) {
|
||||||
const containerId = row.CONTAINER_ID_FULL;
|
const containerId = row.CONTAINER_ID_FULL;
|
||||||
const message = messageFieldToString(row.MESSAGE);
|
const message = messageFieldToString(row.MESSAGE);
|
||||||
const isStdErr = row.PRIORITY === '3';
|
const isStdErr = row.PRIORITY === '3';
|
||||||
|
@ -24,7 +24,7 @@ export async function getSupervisorContainer(
|
|||||||
): Promise<Docker.ContainerInfo> {
|
): Promise<Docker.ContainerInfo> {
|
||||||
// First get the supervisor container id
|
// First get the supervisor container id
|
||||||
const containers = await docker.listContainers({
|
const containers = await docker.listContainers({
|
||||||
filters: { name: ['balena_supervisor'] },
|
filters: { name: ['balena_supervisor', 'resin_supervisor'] },
|
||||||
all: !requireRunning,
|
all: !requireRunning,
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -157,12 +157,20 @@ async function runSshCommand(address: string, command: string) {
|
|||||||
return stdout;
|
return stdout;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function stopSupervisor(address: string) {
|
export async function stopSupervisor(address: string) {
|
||||||
return runSshCommand(address, 'systemctl stop balena-supervisor');
|
try {
|
||||||
|
await runSshCommand(address, 'systemctl stop balena-supervisor');
|
||||||
|
} catch {
|
||||||
|
await runSshCommand(address, 'systemctl stop resin-supervisor');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function startSupervisor(address: string) {
|
export async function startSupervisor(address: string) {
|
||||||
return runSshCommand(address, 'systemctl start balena-supervisor');
|
try {
|
||||||
|
await runSshCommand(address, 'systemctl start balena-supervisor');
|
||||||
|
} catch {
|
||||||
|
await runSshCommand(address, 'systemctl start resin-supervisor');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function replaceSupervisorImage(
|
export async function replaceSupervisorImage(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user