mirror of
https://github.com/balena-os/balena-supervisor.git
synced 2025-02-20 17:52:51 +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. */
|
||||
const SUPERVISOR_CONTAINER_NAME_FALLBACK = 'balena_supervisor';
|
||||
const SUPERVISOR_LEGACY_CONTAINER_NAME_FALLBACK = 'resin_supervisor';
|
||||
|
||||
/**
|
||||
* This class handles any special cases necessary for switching
|
||||
@ -162,14 +163,25 @@ export class LocalModeManager {
|
||||
);
|
||||
} catch (e) {
|
||||
if (this.containerId !== undefined) {
|
||||
// Inspect operation fails (container ID is out of sync?).
|
||||
const fallback = SUPERVISOR_CONTAINER_NAME_FALLBACK;
|
||||
log.warn(
|
||||
'Supervisor container resources cannot be obtained by container ID. ' +
|
||||
`Using '${fallback}' name instead.`,
|
||||
e.message,
|
||||
);
|
||||
return this.collectContainerResources(fallback);
|
||||
try {
|
||||
// Inspect operation fails (container ID is out of sync?).
|
||||
const fallback = SUPERVISOR_CONTAINER_NAME_FALLBACK;
|
||||
log.warn(
|
||||
'Supervisor container resources cannot be obtained by container ID. ' +
|
||||
`Using '${fallback}' name instead.`,
|
||||
e.message,
|
||||
);
|
||||
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);
|
||||
}
|
||||
|
@ -158,7 +158,11 @@ class LogMonitor {
|
||||
}
|
||||
|
||||
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 message = messageFieldToString(row.MESSAGE);
|
||||
const isStdErr = row.PRIORITY === '3';
|
||||
|
@ -24,7 +24,7 @@ export async function getSupervisorContainer(
|
||||
): Promise<Docker.ContainerInfo> {
|
||||
// First get the supervisor container id
|
||||
const containers = await docker.listContainers({
|
||||
filters: { name: ['balena_supervisor'] },
|
||||
filters: { name: ['balena_supervisor', 'resin_supervisor'] },
|
||||
all: !requireRunning,
|
||||
});
|
||||
|
||||
@ -157,12 +157,20 @@ async function runSshCommand(address: string, command: string) {
|
||||
return stdout;
|
||||
}
|
||||
|
||||
export function stopSupervisor(address: string) {
|
||||
return runSshCommand(address, 'systemctl stop balena-supervisor');
|
||||
export async function stopSupervisor(address: string) {
|
||||
try {
|
||||
await runSshCommand(address, 'systemctl stop balena-supervisor');
|
||||
} catch {
|
||||
await runSshCommand(address, 'systemctl stop resin-supervisor');
|
||||
}
|
||||
}
|
||||
|
||||
export function startSupervisor(address: string) {
|
||||
return runSshCommand(address, 'systemctl start balena-supervisor');
|
||||
export async function startSupervisor(address: string) {
|
||||
try {
|
||||
await runSshCommand(address, 'systemctl start balena-supervisor');
|
||||
} catch {
|
||||
await runSshCommand(address, 'systemctl start resin-supervisor');
|
||||
}
|
||||
}
|
||||
|
||||
export async function replaceSupervisorImage(
|
||||
|
Loading…
x
Reference in New Issue
Block a user