mirror of
https://github.com/balena-os/balena-supervisor.git
synced 2024-12-24 15:56:40 +00:00
Merge pull request #316 from resin-io/fix-acknowledged-state
Do not use parsed JSON to compare dep. device state
This commit is contained in:
commit
c1788ec045
@ -1,3 +1,5 @@
|
|||||||
|
Do not use parsed JSON to compare dep. device state [Pablo]
|
||||||
|
|
||||||
# v2.6.0
|
# v2.6.0
|
||||||
|
|
||||||
* Fix docker utils getImageEnv by correctly parsing the returned array [Pablo]
|
* Fix docker utils getImageEnv by correctly parsing the returned array [Pablo]
|
||||||
|
@ -312,6 +312,13 @@ getHookEndpoint = (appId) ->
|
|||||||
conf.RESIN_DEPENDENT_DEVICES_HOOK_ADDRESS ?
|
conf.RESIN_DEPENDENT_DEVICES_HOOK_ADDRESS ?
|
||||||
"#{appConfig.proxyvisorHookReceiver}/v1/devices/"
|
"#{appConfig.proxyvisorHookReceiver}/v1/devices/"
|
||||||
|
|
||||||
|
formatTargetAsState = (device) ->
|
||||||
|
return {
|
||||||
|
commit: device.targetCommit
|
||||||
|
environment: device.targetEnvironment
|
||||||
|
config: device.targetConfig
|
||||||
|
}
|
||||||
|
|
||||||
do ->
|
do ->
|
||||||
acknowledgedState = {}
|
acknowledgedState = {}
|
||||||
sendUpdate = (device, endpoint) ->
|
sendUpdate = (device, endpoint) ->
|
||||||
@ -327,7 +334,7 @@ do ->
|
|||||||
}
|
}
|
||||||
.spread (response, body) ->
|
.spread (response, body) ->
|
||||||
if response.statusCode == 200
|
if response.statusCode == 200
|
||||||
acknowledgedState[device.uuid] = _.omit(stateToSend, 'appId')
|
acknowledgedState[device.uuid] = formatTargetAsState(device)
|
||||||
else
|
else
|
||||||
acknowledgedState[device.uuid] = null
|
acknowledgedState[device.uuid] = null
|
||||||
throw new Error("Hook returned #{response.statusCode}: #{body}") if response.statusCode != 202
|
throw new Error("Hook returned #{response.statusCode}: #{body}") if response.statusCode != 202
|
||||||
@ -350,11 +357,7 @@ do ->
|
|||||||
knex('dependentDevice').select()
|
knex('dependentDevice').select()
|
||||||
.map (device) ->
|
.map (device) ->
|
||||||
currentState = _.pick(device, 'commit', 'environment', 'config')
|
currentState = _.pick(device, 'commit', 'environment', 'config')
|
||||||
targetState = {
|
targetState = formatTargetAsState(device)
|
||||||
commit: device.targetCommit
|
|
||||||
environment: device.targetEnvironment
|
|
||||||
config: device.targetConfig
|
|
||||||
}
|
|
||||||
endpoints[device.appId] ?= getHookEndpoint(device.appId)
|
endpoints[device.appId] ?= getHookEndpoint(device.appId)
|
||||||
endpoints[device.appId]
|
endpoints[device.appId]
|
||||||
.then (endpoint) ->
|
.then (endpoint) ->
|
||||||
|
Loading…
Reference in New Issue
Block a user