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!
|
||||
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
|
||||
|
||||
* Re-enable majority of tests #699 [Cameron Diver]
|
||||
|
@ -1,7 +1,7 @@
|
||||
{
|
||||
"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.",
|
||||
"version": "7.14.1",
|
||||
"version": "7.15.0",
|
||||
"license": "Apache-2.0",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
@ -44,6 +44,7 @@ class Config extends EventEmitter {
|
||||
bootstrapRetryDelay: { source: 'config.json', default: 30000 },
|
||||
supervisorOfflineMode: { source: 'config.json', default: false },
|
||||
hostname: { source: 'config.json', mutable: true },
|
||||
persistentLogging: { source: 'config.json', default: false, mutable: true },
|
||||
|
||||
version: { source: 'func' },
|
||||
currentApiKey: { source: 'func' },
|
||||
|
@ -3,8 +3,8 @@ import * as childProcessSync from 'child_process';
|
||||
import * as _ from 'lodash';
|
||||
import { fs } from 'mz';
|
||||
|
||||
import * as constants from './constants';
|
||||
import * as fsUtils from './fs-utils';
|
||||
import * as constants from '../lib/constants';
|
||||
import * as fsUtils from '../lib/fs-utils';
|
||||
|
||||
const childProcess: any = Promise.promisifyAll(childProcessSync);
|
||||
|
@ -1,12 +1,12 @@
|
||||
import * as _ from 'lodash';
|
||||
|
||||
import { EnvVarObject } from '../lib/types';
|
||||
import {
|
||||
ConfigOptions,
|
||||
DeviceConfigBackend,
|
||||
ExtlinuxConfigBackend,
|
||||
RPiConfigBackend,
|
||||
} from './config-backend';
|
||||
import { EnvVarObject } from './types';
|
||||
} from './backend';
|
||||
|
||||
|
||||
const configBackends = [
|
@ -4,7 +4,7 @@ _ = require 'lodash'
|
||||
systemd = require './lib/systemd'
|
||||
{ checkTruthy, checkInt } = require './lib/validation'
|
||||
{ UnitNotLoadedError } = require './lib/errors'
|
||||
configUtils = require './lib/config-utils'
|
||||
configUtils = require './config/utils'
|
||||
|
||||
vpnServiceName = 'openvpn-resin'
|
||||
|
||||
@ -24,14 +24,20 @@ module.exports = class DeviceConfig
|
||||
deltaVersion: { envVarName: 'RESIN_SUPERVISOR_DELTA_VERSION', varType: 'int', defaultValue: '2' }
|
||||
lockOverride: { envVarName: 'RESIN_SUPERVISOR_OVERRIDE_LOCK', varType: 'bool', defaultValue: 'false' }
|
||||
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 = {
|
||||
changeConfig: (step) =>
|
||||
@logger.logConfigChange(step.humanReadableTarget)
|
||||
@config.set(step.target)
|
||||
.then =>
|
||||
@logger.logConfigChange(step.humanReadableTarget, { success: true })
|
||||
if step.rebootRequired
|
||||
@rebootRequired = true
|
||||
.tapCatch (err) =>
|
||||
@logger.logConfigChange(step.humanReadableTarget, { err })
|
||||
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 checkTruthy(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])
|
||||
configChanges[key] = target[envVarName]
|
||||
humanReadableConfigChanges[envVarName] = target[envVarName]
|
||||
reboot = reboot || (rebootRequired ? false)
|
||||
if !_.isEmpty(configChanges)
|
||||
steps.push({
|
||||
action: 'changeConfig'
|
||||
target: configChanges
|
||||
humanReadableTarget: humanReadableConfigChanges
|
||||
rebootRequired: reboot
|
||||
})
|
||||
return
|
||||
|
||||
# Check if we need to perform special case actions for the VPN
|
||||
if !checkTruthy(offlineMode) &&
|
||||
!_.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({
|
||||
action: 'setVPNEnabled'
|
||||
target: target['RESIN_SUPERVISOR_VPN_CONTROL']
|
||||
})
|
||||
|
||||
# Do we need to change the boot config?
|
||||
if @bootConfigChangeRequired(configBackend, current, target)
|
||||
steps.push({
|
||||
action: 'setBootConfig'
|
||||
target
|
||||
})
|
||||
|
||||
if !_.isEmpty(steps)
|
||||
return
|
||||
if @rebootRequired
|
||||
@ -210,3 +224,6 @@ module.exports = class DeviceConfig
|
||||
systemd.startService(vpnServiceName)
|
||||
else
|
||||
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'
|
||||
DB = require('../src/db')
|
||||
Config = require('../src/config')
|
||||
{ RPiConfigBackend } = require('../src/lib/config-backend')
|
||||
{ RPiConfigBackend } = require('../src/config/backend')
|
||||
|
||||
Service = require '../src/compose/service'
|
||||
|
||||
@ -46,6 +46,7 @@ testTarget1 = {
|
||||
'RESIN_SUPERVISOR_OVERRIDE_LOCK': 'false'
|
||||
'RESIN_SUPERVISOR_POLL_INTERVAL': '60000'
|
||||
'RESIN_SUPERVISOR_VPN_CONTROL': 'true'
|
||||
'RESIN_SUPERVISOR_PERSISTENT_LOGGING': 'false'
|
||||
}
|
||||
apps: {
|
||||
'1234': {
|
||||
@ -128,6 +129,7 @@ testTargetWithDefaults2 = {
|
||||
'RESIN_SUPERVISOR_OVERRIDE_LOCK': 'false'
|
||||
'RESIN_SUPERVISOR_POLL_INTERVAL': '60000'
|
||||
'RESIN_SUPERVISOR_VPN_CONTROL': 'true'
|
||||
'RESIN_SUPERVISOR_PERSISTENT_LOGGING': 'false'
|
||||
}
|
||||
apps: {
|
||||
'1234': {
|
||||
|
@ -9,7 +9,7 @@ prepare = require './lib/prepare'
|
||||
fsUtils = require '../src/lib/fs-utils'
|
||||
|
||||
DeviceConfig = require '../src/device-config'
|
||||
{ ExtlinuxConfigBackend, RPiConfigBackend } = require '../src/lib/config-backend'
|
||||
{ ExtlinuxConfigBackend, RPiConfigBackend } = require '../src/config/backend'
|
||||
|
||||
extlinuxBackend = new ExtlinuxConfigBackend()
|
||||
rpiConfigBackend = new RPiConfigBackend()
|
||||
|
@ -4,8 +4,8 @@ m = require 'mochainon'
|
||||
|
||||
{ fs } = require 'mz'
|
||||
|
||||
configUtils = require '../src/lib/config-utils'
|
||||
{ ExtlinuxConfigBackend, RPiConfigBackend } = require '../src/lib/config-backend'
|
||||
configUtils = require '../src/config/utils'
|
||||
{ ExtlinuxConfigBackend, RPiConfigBackend } = require '../src/config/backend'
|
||||
|
||||
extlinuxBackend = new ExtlinuxConfigBackend()
|
||||
rpiBackend = new RPiConfigBackend()
|
Loading…
Reference in New Issue
Block a user