balena-supervisor/src/lib/constants.ts
Christina Wang a9028e58ec
Prevent updates/reboots with locks when HUP breadcrumbs present
On HUP, some healthceck services need to complete before
it's safe for the Supervisor to reboot the device when
applying state changes. rollback-{health|altboot}-breadcrumb
are the two files that Supervisor looks for and locks the device
on when present in this patch.

Not closing issue 1459 because there is a possible case where,
on altboot rollback, the breadcrumbs are not present. 1459
may be closed when this edge case is investigated.

Change-type: patch
Connects-to: #1459
See: https://www.flowdock.com/app/rulemotion/r-supervisor/threads/cL7YfNOLSfTPfw05h59GEW0kfOt
Signed-off-by: Christina Wang <christina@balena.io>
2021-06-30 13:27:03 +09:00

81 lines
2.7 KiB
TypeScript

import { checkString } from './validation';
const bootMountPointFromEnv = checkString(process.env.BOOT_MOUNTPOINT);
const rootMountPoint = checkString(process.env.ROOT_MOUNTPOINT) || '/mnt/root';
const supervisorNetworkInterface = 'supervisor0';
const constants = {
rootMountPoint,
stateMountPoint: '/mnt/state',
databasePath:
checkString(process.env.DATABASE_PATH) || '/data/database.sqlite',
containerId: checkString(process.env.SUPERVISOR_CONTAINER_ID) || undefined,
dockerSocket: process.env.DOCKER_SOCKET || '/var/run/docker.sock',
// In-container location for docker socket
// Mount in /host/run to avoid clashing with systemd
containerDockerSocket: '/host/run/balena-engine.sock',
supervisorImage:
checkString(process.env.SUPERVISOR_IMAGE) || 'resin/rpi-supervisor',
ledFile:
checkString(process.env.LED_FILE) || '/sys/class/leds/led0/brightness',
vpnStatusPath:
checkString(process.env.VPN_STATUS_PATH) ||
`${rootMountPoint}/run/openvpn/vpn_status`,
hostOSVersionPath:
checkString(process.env.HOST_OS_VERSION_PATH) ||
`${rootMountPoint}/etc/os-release`,
macAddressPath:
checkString(process.env.MAC_ADDRESS_PATH) ||
`${rootMountPoint}/sys/class/net`,
privateAppEnvVars: [
'RESIN_SUPERVISOR_API_KEY',
'RESIN_API_KEY',
'BALENA_SUPERVISOR_API_KEY',
'BALENA_API_KEY',
],
bootMountPointFromEnv,
bootMountPoint: bootMountPointFromEnv || '/boot',
configJsonPathOnHost: checkString(process.env.CONFIG_JSON_PATH),
proxyvisorHookReceiver: 'http://0.0.0.0:1337',
configJsonNonAtomicPath: '/boot/config.json',
defaultMixpanelToken: process.env.DEFAULT_MIXPANEL_TOKEN,
supervisorNetworkInterface,
allowedInterfaces: [
'resin-vpn',
'tun0',
'docker0',
'lo',
supervisorNetworkInterface,
],
appsJsonPath: process.env.APPS_JSON_PATH || '/boot/apps.json',
ipAddressUpdateInterval: 30 * 1000,
imageCleanupErrorIgnoreTimeout: 3600 * 1000,
maxDeltaDownloads: 3,
defaultVolumeLabels: {
'io.balena.supervised': 'true',
},
bootBlockDevice: '/dev/mmcblk0p1',
hostConfigVarPrefix: 'HOST_',
migrationBackupFile: 'backup.tgz',
// Use this failure multiplied by 2**Number of failures to increase
// the backoff on subsequent failures
backoffIncrement: 500,
supervisorNetworkSubnet: '10.114.104.0/25',
supervisorNetworkGateway: '10.114.104.1',
// How often can we report our state to the server in ms
maxReportFrequency: 10 * 1000,
// How much of a jitter we can add to our api polling
// (this number is used as an upper bound when generating
// a random jitter)
maxApiJitterDelay: 60 * 1000,
validRedsocksProxyTypes: ['socks4', 'socks5', 'http-connect', 'http-relay'],
};
if (process.env.DOCKER_HOST == null) {
process.env.DOCKER_HOST = `unix://${constants.dockerSocket}`;
}
export = constants;