mirror of
https://github.com/balena-os/balena-supervisor.git
synced 2025-02-21 02:01:35 +00:00
Restore default value when clearing a special action config variable
Up to now we've only been running the "special actions" (like vpn on/off, logs on/off) when the target state includes a current value for the corresponding config variable. We now also check if there was a *previous* value, and in that case also call the action function. These functions are prepared to reset to a default when they're called with an undefined value. Change-Type: patch Signed-off-by: Pablo Carranza Velez <pablo@resin.io>
This commit is contained in:
parent
538e384442
commit
72f6b2cea5
@ -134,9 +134,15 @@ logSystemEvent = (logType, app = {}, error) ->
|
||||
|
||||
logSpecialAction = (action, value, success) ->
|
||||
if success
|
||||
msg = "Applied config variable #{action} = #{value}"
|
||||
if !value?
|
||||
msg = "Cleared config variable #{action}"
|
||||
else
|
||||
msg = "Applied config variable #{action} = #{value}"
|
||||
else
|
||||
msg = "Applying config variable #{action} = #{value}"
|
||||
if !value?
|
||||
msg = "Clearing config variable #{action}"
|
||||
else
|
||||
msg = "Applying config variable #{action} = #{value}"
|
||||
logSystemMessage(msg, {}, "Apply special action #{if success then "success" else "in progress"}")
|
||||
|
||||
application.kill = kill = (app, { updateDB = true, removeContainer = true } = {}) ->
|
||||
@ -435,7 +441,7 @@ executedSpecialActionConfigVars = {}
|
||||
|
||||
executeSpecialActionsAndHostConfig = (conf, oldConf) ->
|
||||
Promise.mapSeries specialActionConfigVars, ([ key, specialActionCallback ]) ->
|
||||
if conf[key]? && specialActionCallback?
|
||||
if (conf[key]? or oldConf[key]?) and specialActionCallback?
|
||||
# This makes the Special Action Envs only trigger their functions once.
|
||||
if executedSpecialActionConfigVars[key] != conf[key]
|
||||
logSpecialAction(key, conf[key])
|
||||
|
Loading…
x
Reference in New Issue
Block a user