mirror of
https://github.com/balena-os/balena-supervisor.git
synced 2024-12-20 14:13:08 +00:00
Auto-merge for PR #700 via VersionBot
Allow persistent logging to be enabled/disabled via env var
This commit is contained in:
commit
9dcf3ed697
@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file
|
|||||||
automatically by Versionist. DO NOT EDIT THIS FILE MANUALLY!
|
automatically by Versionist. DO NOT EDIT THIS FILE MANUALLY!
|
||||||
This project adheres to [Semantic Versioning](http://semver.org/).
|
This project adheres to [Semantic Versioning](http://semver.org/).
|
||||||
|
|
||||||
|
## v7.15.0 - 2018-07-17
|
||||||
|
|
||||||
|
* Allow the enabling and disabling of persistent logging via env var #700 [Cameron Diver]
|
||||||
|
* Refactor config code to be consistent in location #700 [Cameron Diver]
|
||||||
|
|
||||||
## v7.14.1 - 2018-07-16
|
## v7.14.1 - 2018-07-16
|
||||||
|
|
||||||
* Re-enable majority of tests #699 [Cameron Diver]
|
* Re-enable majority of tests #699 [Cameron Diver]
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "resin-supervisor",
|
"name": "resin-supervisor",
|
||||||
"description": "This is resin.io's Supervisor, a program that runs on IoT devices and has the task of running user Apps (which are Docker containers), and updating them as Resin's API informs it to.",
|
"description": "This is resin.io's Supervisor, a program that runs on IoT devices and has the task of running user Apps (which are Docker containers), and updating them as Resin's API informs it to.",
|
||||||
"version": "7.14.1",
|
"version": "7.15.0",
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
|
@ -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' },
|
||||||
|
@ -3,8 +3,8 @@ import * as childProcessSync from 'child_process';
|
|||||||
import * as _ from 'lodash';
|
import * as _ from 'lodash';
|
||||||
import { fs } from 'mz';
|
import { fs } from 'mz';
|
||||||
|
|
||||||
import * as constants from './constants';
|
import * as constants from '../lib/constants';
|
||||||
import * as fsUtils from './fs-utils';
|
import * as fsUtils from '../lib/fs-utils';
|
||||||
|
|
||||||
const childProcess: any = Promise.promisifyAll(childProcessSync);
|
const childProcess: any = Promise.promisifyAll(childProcessSync);
|
||||||
|
|
@ -1,12 +1,12 @@
|
|||||||
import * as _ from 'lodash';
|
import * as _ from 'lodash';
|
||||||
|
|
||||||
|
import { EnvVarObject } from '../lib/types';
|
||||||
import {
|
import {
|
||||||
ConfigOptions,
|
ConfigOptions,
|
||||||
DeviceConfigBackend,
|
DeviceConfigBackend,
|
||||||
ExtlinuxConfigBackend,
|
ExtlinuxConfigBackend,
|
||||||
RPiConfigBackend,
|
RPiConfigBackend,
|
||||||
} from './config-backend';
|
} from './backend';
|
||||||
import { EnvVarObject } from './types';
|
|
||||||
|
|
||||||
|
|
||||||
const configBackends = [
|
const configBackends = [
|
@ -4,7 +4,7 @@ _ = require 'lodash'
|
|||||||
systemd = require './lib/systemd'
|
systemd = require './lib/systemd'
|
||||||
{ checkTruthy, checkInt } = require './lib/validation'
|
{ checkTruthy, checkInt } = require './lib/validation'
|
||||||
{ UnitNotLoadedError } = require './lib/errors'
|
{ UnitNotLoadedError } = require './lib/errors'
|
||||||
configUtils = require './lib/config-utils'
|
configUtils = require './config/utils'
|
||||||
|
|
||||||
vpnServiceName = 'openvpn-resin'
|
vpnServiceName = 'openvpn-resin'
|
||||||
|
|
||||||
@ -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])
|
||||||
|
@ -9,7 +9,7 @@ prepare = require './lib/prepare'
|
|||||||
DeviceState = require '../src/device-state'
|
DeviceState = require '../src/device-state'
|
||||||
DB = require('../src/db')
|
DB = require('../src/db')
|
||||||
Config = require('../src/config')
|
Config = require('../src/config')
|
||||||
{ RPiConfigBackend } = require('../src/lib/config-backend')
|
{ RPiConfigBackend } = require('../src/config/backend')
|
||||||
|
|
||||||
Service = require '../src/compose/service'
|
Service = require '../src/compose/service'
|
||||||
|
|
||||||
@ -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': {
|
||||||
|
@ -9,7 +9,7 @@ prepare = require './lib/prepare'
|
|||||||
fsUtils = require '../src/lib/fs-utils'
|
fsUtils = require '../src/lib/fs-utils'
|
||||||
|
|
||||||
DeviceConfig = require '../src/device-config'
|
DeviceConfig = require '../src/device-config'
|
||||||
{ ExtlinuxConfigBackend, RPiConfigBackend } = require '../src/lib/config-backend'
|
{ ExtlinuxConfigBackend, RPiConfigBackend } = require '../src/config/backend'
|
||||||
|
|
||||||
extlinuxBackend = new ExtlinuxConfigBackend()
|
extlinuxBackend = new ExtlinuxConfigBackend()
|
||||||
rpiConfigBackend = new RPiConfigBackend()
|
rpiConfigBackend = new RPiConfigBackend()
|
||||||
|
@ -4,8 +4,8 @@ m = require 'mochainon'
|
|||||||
|
|
||||||
{ fs } = require 'mz'
|
{ fs } = require 'mz'
|
||||||
|
|
||||||
configUtils = require '../src/lib/config-utils'
|
configUtils = require '../src/config/utils'
|
||||||
{ ExtlinuxConfigBackend, RPiConfigBackend } = require '../src/lib/config-backend'
|
{ ExtlinuxConfigBackend, RPiConfigBackend } = require '../src/config/backend'
|
||||||
|
|
||||||
extlinuxBackend = new ExtlinuxConfigBackend()
|
extlinuxBackend = new ExtlinuxConfigBackend()
|
||||||
rpiBackend = new RPiConfigBackend()
|
rpiBackend = new RPiConfigBackend()
|
Loading…
Reference in New Issue
Block a user