mirror of
https://github.com/balena-os/balena-supervisor.git
synced 2025-06-05 09:10:49 +00:00
Allow the enabling and disabling of persistent logging via env var
Closes: #698 Change-type: minor Signed-off-by: Cameron Diver <cameron@resin.io>
This commit is contained in:
parent
0e29e5f6f7
commit
1604fdf276
@ -44,6 +44,7 @@ class Config extends EventEmitter {
|
|||||||
bootstrapRetryDelay: { source: 'config.json', default: 30000 },
|
bootstrapRetryDelay: { source: 'config.json', default: 30000 },
|
||||||
supervisorOfflineMode: { source: 'config.json', default: false },
|
supervisorOfflineMode: { source: 'config.json', default: false },
|
||||||
hostname: { source: 'config.json', mutable: true },
|
hostname: { source: 'config.json', mutable: true },
|
||||||
|
persistentLogging: { source: 'config.json', default: false, mutable: true },
|
||||||
|
|
||||||
version: { source: 'func' },
|
version: { source: 'func' },
|
||||||
currentApiKey: { source: 'func' },
|
currentApiKey: { source: 'func' },
|
||||||
|
@ -24,14 +24,20 @@ module.exports = class DeviceConfig
|
|||||||
deltaVersion: { envVarName: 'RESIN_SUPERVISOR_DELTA_VERSION', varType: 'int', defaultValue: '2' }
|
deltaVersion: { envVarName: 'RESIN_SUPERVISOR_DELTA_VERSION', varType: 'int', defaultValue: '2' }
|
||||||
lockOverride: { envVarName: 'RESIN_SUPERVISOR_OVERRIDE_LOCK', varType: 'bool', defaultValue: 'false' }
|
lockOverride: { envVarName: 'RESIN_SUPERVISOR_OVERRIDE_LOCK', varType: 'bool', defaultValue: 'false' }
|
||||||
nativeLogger: { envVarName: 'RESIN_SUPERVISOR_NATIVE_LOGGER', varType: 'bool', defaultValue: 'true' }
|
nativeLogger: { envVarName: 'RESIN_SUPERVISOR_NATIVE_LOGGER', varType: 'bool', defaultValue: 'true' }
|
||||||
|
persistentLogging: { envVarName: 'RESIN_SUPERVISOR_PERSISTENT_LOGGING', varType: 'bool', defaultValue: 'false', rebootRequired: true }
|
||||||
}
|
}
|
||||||
@validKeys = [ 'RESIN_SUPERVISOR_VPN_CONTROL', 'RESIN_OVERRIDE_LOCK' ].concat(_.map(@configKeys, 'envVarName'))
|
@validKeys = [
|
||||||
|
'RESIN_SUPERVISOR_VPN_CONTROL',
|
||||||
|
'RESIN_OVERRIDE_LOCK',
|
||||||
|
].concat(_.map(@configKeys, 'envVarName'))
|
||||||
@actionExecutors = {
|
@actionExecutors = {
|
||||||
changeConfig: (step) =>
|
changeConfig: (step) =>
|
||||||
@logger.logConfigChange(step.humanReadableTarget)
|
@logger.logConfigChange(step.humanReadableTarget)
|
||||||
@config.set(step.target)
|
@config.set(step.target)
|
||||||
.then =>
|
.then =>
|
||||||
@logger.logConfigChange(step.humanReadableTarget, { success: true })
|
@logger.logConfigChange(step.humanReadableTarget, { success: true })
|
||||||
|
if step.rebootRequired
|
||||||
|
@rebootRequired = true
|
||||||
.tapCatch (err) =>
|
.tapCatch (err) =>
|
||||||
@logger.logConfigChange(step.humanReadableTarget, { err })
|
@logger.logConfigChange(step.humanReadableTarget, { err })
|
||||||
setVPNEnabled: (step, { initial = false } = {}) =>
|
setVPNEnabled: (step, { initial = false } = {}) =>
|
||||||
@ -140,29 +146,37 @@ module.exports = class DeviceConfig
|
|||||||
# If the legacy lock override is used, place it as the new variable
|
# If the legacy lock override is used, place it as the new variable
|
||||||
if checkTruthy(target['RESIN_OVERRIDE_LOCK'])
|
if checkTruthy(target['RESIN_OVERRIDE_LOCK'])
|
||||||
target['RESIN_SUPERVISOR_OVERRIDE_LOCK'] = target['RESIN_OVERRIDE_LOCK']
|
target['RESIN_SUPERVISOR_OVERRIDE_LOCK'] = target['RESIN_OVERRIDE_LOCK']
|
||||||
for own key, { envVarName, varType } of @configKeys
|
reboot = false
|
||||||
|
for own key, { envVarName, varType, rebootRequired } of @configKeys
|
||||||
if !match[varType](current[envVarName], target[envVarName])
|
if !match[varType](current[envVarName], target[envVarName])
|
||||||
configChanges[key] = target[envVarName]
|
configChanges[key] = target[envVarName]
|
||||||
humanReadableConfigChanges[envVarName] = target[envVarName]
|
humanReadableConfigChanges[envVarName] = target[envVarName]
|
||||||
|
reboot = reboot || (rebootRequired ? false)
|
||||||
if !_.isEmpty(configChanges)
|
if !_.isEmpty(configChanges)
|
||||||
steps.push({
|
steps.push({
|
||||||
action: 'changeConfig'
|
action: 'changeConfig'
|
||||||
target: configChanges
|
target: configChanges
|
||||||
humanReadableTarget: humanReadableConfigChanges
|
humanReadableTarget: humanReadableConfigChanges
|
||||||
|
rebootRequired: reboot
|
||||||
})
|
})
|
||||||
return
|
return
|
||||||
|
|
||||||
|
# Check if we need to perform special case actions for the VPN
|
||||||
if !checkTruthy(offlineMode) &&
|
if !checkTruthy(offlineMode) &&
|
||||||
!_.isEmpty(target['RESIN_SUPERVISOR_VPN_CONTROL']) &&
|
!_.isEmpty(target['RESIN_SUPERVISOR_VPN_CONTROL']) &&
|
||||||
checkTruthy(current['RESIN_SUPERVISOR_VPN_CONTROL']) != checkTruthy(target['RESIN_SUPERVISOR_VPN_CONTROL'])
|
@checkBoolChanged(current, target, 'RESIN_SUPERVISOR_VPN_CONTROL')
|
||||||
steps.push({
|
steps.push({
|
||||||
action: 'setVPNEnabled'
|
action: 'setVPNEnabled'
|
||||||
target: target['RESIN_SUPERVISOR_VPN_CONTROL']
|
target: target['RESIN_SUPERVISOR_VPN_CONTROL']
|
||||||
})
|
})
|
||||||
|
|
||||||
|
# Do we need to change the boot config?
|
||||||
if @bootConfigChangeRequired(configBackend, current, target)
|
if @bootConfigChangeRequired(configBackend, current, target)
|
||||||
steps.push({
|
steps.push({
|
||||||
action: 'setBootConfig'
|
action: 'setBootConfig'
|
||||||
target
|
target
|
||||||
})
|
})
|
||||||
|
|
||||||
if !_.isEmpty(steps)
|
if !_.isEmpty(steps)
|
||||||
return
|
return
|
||||||
if @rebootRequired
|
if @rebootRequired
|
||||||
@ -210,3 +224,6 @@ module.exports = class DeviceConfig
|
|||||||
systemd.startService(vpnServiceName)
|
systemd.startService(vpnServiceName)
|
||||||
else
|
else
|
||||||
systemd.stopService(vpnServiceName)
|
systemd.stopService(vpnServiceName)
|
||||||
|
|
||||||
|
checkBoolChanged: (current, target, key) ->
|
||||||
|
checkTruthy(current[key]) != checkTruthy(target[key])
|
||||||
|
@ -46,6 +46,7 @@ testTarget1 = {
|
|||||||
'RESIN_SUPERVISOR_OVERRIDE_LOCK': 'false'
|
'RESIN_SUPERVISOR_OVERRIDE_LOCK': 'false'
|
||||||
'RESIN_SUPERVISOR_POLL_INTERVAL': '60000'
|
'RESIN_SUPERVISOR_POLL_INTERVAL': '60000'
|
||||||
'RESIN_SUPERVISOR_VPN_CONTROL': 'true'
|
'RESIN_SUPERVISOR_VPN_CONTROL': 'true'
|
||||||
|
'RESIN_SUPERVISOR_PERSISTENT_LOGGING': 'false'
|
||||||
}
|
}
|
||||||
apps: {
|
apps: {
|
||||||
'1234': {
|
'1234': {
|
||||||
@ -128,6 +129,7 @@ testTargetWithDefaults2 = {
|
|||||||
'RESIN_SUPERVISOR_OVERRIDE_LOCK': 'false'
|
'RESIN_SUPERVISOR_OVERRIDE_LOCK': 'false'
|
||||||
'RESIN_SUPERVISOR_POLL_INTERVAL': '60000'
|
'RESIN_SUPERVISOR_POLL_INTERVAL': '60000'
|
||||||
'RESIN_SUPERVISOR_VPN_CONTROL': 'true'
|
'RESIN_SUPERVISOR_VPN_CONTROL': 'true'
|
||||||
|
'RESIN_SUPERVISOR_PERSISTENT_LOGGING': 'false'
|
||||||
}
|
}
|
||||||
apps: {
|
apps: {
|
||||||
'1234': {
|
'1234': {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user