mirror of
https://github.com/balena-os/balena-supervisor.git
synced 2024-12-20 14:13:08 +00:00
Merge pull request #1684 from balena-os/rename-resin-supervisor
supervisor: rename resin-supervisor to balena-supervisor
This commit is contained in:
commit
ca1b96bfc5
4
.gitignore
vendored
4
.gitignore
vendored
@ -1,7 +1,7 @@
|
||||
/node_modules/
|
||||
/automation/node_modules/
|
||||
/automation/meta-resin/
|
||||
/meta-resin/
|
||||
/automation/meta-balena/
|
||||
/meta-balena/
|
||||
*.swp
|
||||
/data/
|
||||
/build/
|
||||
|
@ -183,7 +183,7 @@ This will show the output of `journalctl` inside the Docker-in-Docker container.
|
||||
additional options, for instance, to see the logs from the supervisor service:
|
||||
|
||||
```bash
|
||||
./dindctl logs -fn 100 -u resin-supervisor
|
||||
./dindctl logs -fn 100 -u balena-supervisor
|
||||
```
|
||||
|
||||
#### Stop the supervisor
|
||||
|
8
dindctl
8
dindctl
@ -118,16 +118,16 @@ function parseOptions {
|
||||
|
||||
|
||||
SUPERVISOR_DIND_MOUNTS="-v ${DIND_DIR}/config/supervisor-image.tar:/usr/src/supervisor-image.tar:ro"
|
||||
SUPERVISOR_DIND_MOUNTS="${SUPERVISOR_DIND_MOUNTS} -v ${DIND_DIR}/config/supervisor.conf:/etc/resin-supervisor/supervisor.conf"
|
||||
SUPERVISOR_DIND_MOUNTS="${SUPERVISOR_DIND_MOUNTS} -v ${DIND_DIR}/config/supervisor.conf:/etc/balena-supervisor/supervisor.conf"
|
||||
|
||||
if [ "${MOUNT_DIST}" == "true" ]; then
|
||||
SUPERVISOR_DIND_MOUNTS="${SUPERVISOR_DIND_MOUNTS} -v ${DIND_DIR}/../../dist:/resin-supervisor/dist"
|
||||
SUPERVISOR_DIND_MOUNTS="${SUPERVISOR_DIND_MOUNTS} -v ${DIND_DIR}/../../dist:/balena-supervisor/dist"
|
||||
fi
|
||||
if [ "${PRELOADED_IMAGE}" == "true" ]; then
|
||||
SUPERVISOR_DIND_MOUNTS="${SUPERVISOR_DIND_MOUNTS} -v ${DIND_DIR}/apps.json:/mnt/data/apps.json"
|
||||
fi
|
||||
if [ "${MOUNT_NODE_MODULES}" == "true" ]; then
|
||||
SUPERVISOR_DIND_MOUNTS="${SUPERVISOR_DIND_MOUNTS} -v ${DIND_DIR}/../../node_modules:/resin-supervisor/node_modules"
|
||||
SUPERVISOR_DIND_MOUNTS="${SUPERVISOR_DIND_MOUNTS} -v ${DIND_DIR}/../../node_modules:/balena-supervisor/node_modules"
|
||||
fi
|
||||
if [ "${MOUNT_BACKUP}" == "true" ]; then
|
||||
SUPERVISOR_DIND_MOUNTS="${SUPERVISOR_DIND_MOUNTS} -v ${DIND_DIR}/backup.tgz:/mnt/data/backup.tgz.mounted"
|
||||
@ -154,7 +154,7 @@ function buildSupervisorSrc {
|
||||
function refreshSupervisorSrc {
|
||||
buildSupervisorSrc
|
||||
echo "Restarting the supervisor container"
|
||||
docker exec -ti balena-container-$CONTAINER_NAME systemctl restart resin-supervisor
|
||||
docker exec -ti balena-container-$CONTAINER_NAME systemctl restart balena-supervisor
|
||||
}
|
||||
|
||||
function runDind {
|
||||
|
@ -22,7 +22,7 @@ On older devices (with v4.0.0 <= supervisor version < v7.22.0) the lock is locat
|
||||
Legacy supervisors (< v4.0.0) have the lock at `/data/resin-updates.lock`. This lock is only supported on devices running balenaOS 1.X.
|
||||
This old lock has the problem that the supervisor has to clear whenever it starts up to avoid deadlocks. If the user app
|
||||
has taken the lock before the supervisor starts up, the lock will be cleared and the app can operate under the false
|
||||
assumption that updates are locked (see [issue #20](https://github.com/resin-io/resin-supervisor/issues/20)). We therefore strongly recommend switching to the new lock location as soon as possible.
|
||||
assumption that updates are locked (see [issue #20](https://github.com/balena-os/balena-supervisor/issues/20)). We therefore strongly recommend switching to the new lock location as soon as possible.
|
||||
|
||||
### Creating the lockfile
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
"license": "Apache-2.0",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/resin-io/resin-supervisor.git"
|
||||
"url": "https://github.com/balena-os/balena-supervisor.git"
|
||||
},
|
||||
"scripts": {
|
||||
"start": "./entry.sh",
|
||||
|
@ -43,7 +43,7 @@ export const fnSchema = {
|
||||
async () => {
|
||||
try {
|
||||
// FIXME: We should be mounting the following file into the supervisor from the
|
||||
// start-resin-supervisor script, changed in meta-resin - but until then, hardcode it
|
||||
// start-balena-supervisor script, changed in meta-balena - but until then, hardcode it
|
||||
const data = await fs.readFile(
|
||||
`${constants.rootMountPoint}${constants.bootMountPoint}/device-type.json`,
|
||||
'utf8',
|
||||
@ -62,7 +62,7 @@ export const fnSchema = {
|
||||
async () => {
|
||||
try {
|
||||
// FIXME: We should be mounting the following file into the supervisor from the
|
||||
// start-resin-supervisor script, changed in meta-resin - but until then, hardcode it
|
||||
// start-balena-supervisor script, changed in meta-balena - but until then, hardcode it
|
||||
const data = await fs.readFile(
|
||||
`${constants.rootMountPoint}${constants.bootMountPoint}/device-type.json`,
|
||||
'utf8',
|
||||
|
@ -59,7 +59,8 @@ export class EngineSnapshotRecord {
|
||||
}
|
||||
|
||||
/** Container name used to inspect own resources when container ID cannot be resolved. */
|
||||
const SUPERVISOR_CONTAINER_NAME_FALLBACK = 'resin_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
|
||||
@ -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 !== 'resin_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: ['resin_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 resin-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 resin-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(
|
||||
|
@ -127,7 +127,7 @@ describe.skip('LocalModeManager', () => {
|
||||
},
|
||||
Image: 'super-image-1',
|
||||
HostConfig: {
|
||||
ContainerIDFile: '/resin-data/resin-supervisor/container-id',
|
||||
ContainerIDFile: '/resin-data/balena-supervisor/container-id',
|
||||
},
|
||||
Mounts: [
|
||||
{
|
||||
|
@ -1,6 +1,6 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Adapted from: https://github.com/balena-os/meta-balena/blob/v2.45.0/meta-balena-common/recipes-containers/resin-supervisor/resin-supervisor/start-resin-supervisor
|
||||
# Adapted from: https://github.com/balena-os/meta-balena/blob/v2.45.0/meta-balena-common/recipes-containers/balena-supervisor/balena-supervisor/start-balena-supervisor
|
||||
|
||||
# We still need to include resin-vars on legacy systems
|
||||
if [ -f /usr/sbin/resin-vars ]; then
|
||||
@ -25,7 +25,7 @@ APPSJSON=/mnt/data/apps.json
|
||||
if [ ! -f "$APPSJSON" ]; then
|
||||
if [ -d "$APPSJSON" ]; then
|
||||
rm -rf "$APPSJSON"
|
||||
balena rm -f resin_supervisor || true
|
||||
balena rm -f balena_supervisor || true
|
||||
echo '{}' > "$APPSJSON"
|
||||
elif [ ! -e "$APPSJSON" ]; then
|
||||
echo '{}' > "$APPSJSON"
|
||||
@ -33,7 +33,7 @@ if [ ! -f "$APPSJSON" ]; then
|
||||
fi
|
||||
|
||||
SUPERVISOR_IMAGE_ID=$(balena inspect --format='{{.Id}}' "$SUPERVISOR_IMAGE:$SUPERVISOR_TAG")
|
||||
SUPERVISOR_CONTAINER_IMAGE_ID=$(balena inspect --format='{{.Image}}' resin_supervisor || echo "")
|
||||
SUPERVISOR_CONTAINER_IMAGE_ID=$(balena inspect --format='{{.Image}}' balena_supervisor || echo "")
|
||||
|
||||
# If self-signed root CA exists, add the CA for the specified registry
|
||||
if [ -n "$BALENA_ROOT_CA" ]; then
|
||||
@ -65,7 +65,7 @@ hasValueChanged() {
|
||||
|
||||
configIsUnchanged() {
|
||||
|
||||
SUPERVISOR_CONTAINER_ENV_JSON="$(balena inspect resin_supervisor | jq '.[0].Config.Env | map(.| { (.[0:index("=")]): .[index("=")+1:] }) | add')"
|
||||
SUPERVISOR_CONTAINER_ENV_JSON="$(balena inspect balena_supervisor | jq '.[0].Config.Env | map(.| { (.[0:index("=")]): .[index("=")+1:] }) | add')"
|
||||
|
||||
if hasValueChanged "BOOT_MOUNTPOINT" "$BOOT_MOUNTPOINT" "$SUPERVISOR_CONTAINER_ENV_JSON" || \
|
||||
hasValueChanged "REGISTRY_ENDPOINT" "$REGISTRY_ENDPOINT" "$SUPERVISOR_CONTAINER_ENV_JSON" || \
|
||||
@ -84,15 +84,15 @@ configIsUnchanged() {
|
||||
}
|
||||
|
||||
runSupervisor() {
|
||||
balena rm --force resin_supervisor || true
|
||||
balena run --privileged --name resin_supervisor \
|
||||
balena rm --force balena_supervisor || true
|
||||
balena run --privileged --name balena_supervisor \
|
||||
--restart=always \
|
||||
--net=host \
|
||||
--cidenv=SUPERVISOR_CONTAINER_ID \
|
||||
-v /var/run/balena-engine.sock:/var/run/balena-engine.sock \
|
||||
-v "$CONFIG_PATH:/boot/config.json" \
|
||||
-v /mnt/data/apps.json:/boot/apps.json \
|
||||
-v /resin-data/resin-supervisor:/data \
|
||||
-v /resin-data/balena-supervisor:/data \
|
||||
-v /proc/net/fib_trie:/mnt/fib_trie \
|
||||
-v /var/log/supervisor-log:/var/log \
|
||||
-v /:/mnt/root \
|
||||
@ -112,10 +112,10 @@ runSupervisor() {
|
||||
|
||||
if [ -z "$SUPERVISOR_IMAGE_ID" ]; then
|
||||
# No supervisor image exists on the device, try to pull it
|
||||
systemctl start update-resin-supervisor
|
||||
systemctl start update-balena-supervisor
|
||||
elif [ "$SUPERVISOR_IMAGE_ID" = "$SUPERVISOR_CONTAINER_IMAGE_ID" ] && configIsUnchanged; then
|
||||
# Supervisor image exists, and the current supervisor container is created from
|
||||
balena start --attach resin_supervisor
|
||||
balena start --attach balena_supervisor
|
||||
else
|
||||
# No supervisor container exists or there's a different supervisor image to run
|
||||
runSupervisor
|
@ -26,7 +26,7 @@ const syncOpts = {
|
||||
deviceIp: process.argv[2],
|
||||
baseDir: __dirname + '/dist',
|
||||
destination: '/usr/src/app/dist',
|
||||
appName: 'resin_supervisor',
|
||||
appName: 'balena_supervisor',
|
||||
skipGitignore: true,
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user