mirror of
https://github.com/balena-os/balena-supervisor.git
synced 2025-05-04 18:12:56 +00:00
Merge pull request #427 from resin-io/dont-update-deviceconfig-if-unchanged
Avoid writing target device config to DB if it hasn't changed
This commit is contained in:
commit
ac2531368c
@ -500,7 +500,7 @@ getAndApplyDeviceConfig = ->
|
|||||||
.then ({ values, targetValues }) ->
|
.then ({ values, targetValues }) ->
|
||||||
executeSpecialActionsAndHostConfig(targetValues, values)
|
executeSpecialActionsAndHostConfig(targetValues, values)
|
||||||
.tap ->
|
.tap ->
|
||||||
deviceConfig.set({ values: targetValues })
|
deviceConfig.set({ values: targetValues }) if !_.isEqual(values, targetValues)
|
||||||
.then (needsReboot) ->
|
.then (needsReboot) ->
|
||||||
if needsReboot
|
if needsReboot
|
||||||
logSystemMessage('Rebooting', {}, 'Reboot')
|
logSystemMessage('Rebooting', {}, 'Reboot')
|
||||||
@ -719,11 +719,16 @@ application.update = update = (force, scheduled = false) ->
|
|||||||
remoteDeviceConfig = {}
|
remoteDeviceConfig = {}
|
||||||
_.map remoteAppIds, (appId) ->
|
_.map remoteAppIds, (appId) ->
|
||||||
_.merge(remoteDeviceConfig, JSON.parse(remoteApps[appId].config))
|
_.merge(remoteDeviceConfig, JSON.parse(remoteApps[appId].config))
|
||||||
deviceConfig.set({ targetValues: remoteDeviceConfig })
|
deviceConfig.get()
|
||||||
.then ->
|
.then ({ values, targetValues }) ->
|
||||||
getAndApplyDeviceConfig()
|
# If the new device config is different from the target values we had, or if
|
||||||
|
# for some reason it hasn't been applied yet (values don't match target), we apply it.
|
||||||
|
if !_.isEqual(targetValues, remoteDeviceConfig) or !_.isEqual(targetValues, values)
|
||||||
|
deviceConfig.set({ targetValues: remoteDeviceConfig })
|
||||||
|
.then ->
|
||||||
|
getAndApplyDeviceConfig()
|
||||||
.catch (err) ->
|
.catch (err) ->
|
||||||
logSystemMessage("Error applying device configuration: #{err}", { error: err }, 'Set device configuration error')
|
logSystemMessage("Error fetching/applying device configuration: #{err}", { error: err }, 'Set device configuration error')
|
||||||
.return(allAppIds)
|
.return(allAppIds)
|
||||||
.map (appId) ->
|
.map (appId) ->
|
||||||
return if application.localMode
|
return if application.localMode
|
||||||
|
Loading…
x
Reference in New Issue
Block a user