mirror of
https://github.com/balena-os/balena-supervisor.git
synced 2025-02-25 11:12:47 +00:00
Auto-merge for PR #657 via VersionBot
Change intialConfigReported value to be an api endpoint
This commit is contained in:
commit
ddfa7f3e63
@ -4,6 +4,10 @@ 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.6.0 - 2018-05-16
|
||||||
|
|
||||||
|
* Change intialConfigReported value to be an api endpoint #657 [Cameron Diver]
|
||||||
|
|
||||||
## v7.5.6 - 2018-05-14
|
## v7.5.6 - 2018-05-14
|
||||||
|
|
||||||
* Update gitignore to ignore new test files #653 [Cameron Diver]
|
* Update gitignore to ignore new test files #653 [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.5.6",
|
"version": "7.6.0",
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
|
@ -82,19 +82,28 @@ module.exports = class APIBinder
|
|||||||
@cachedResinApi = @resinApi.clone({}, cache: {})
|
@cachedResinApi = @resinApi.clone({}, cache: {})
|
||||||
|
|
||||||
start: =>
|
start: =>
|
||||||
@config.getMany([ 'offlineMode', 'bootstrapRetryDelay' ])
|
@config.getMany([ 'resinApiEndpoint', 'offlineMode', 'bootstrapRetryDelay' ])
|
||||||
.then ({ offlineMode, bootstrapRetryDelay }) =>
|
.then ({ resinApiEndpoint, offlineMode, bootstrapRetryDelay }) =>
|
||||||
if offlineMode
|
if offlineMode
|
||||||
console.log('Offline Mode is set, skipping API binder initialization')
|
console.log('Offline Mode is set, skipping API binder initialization')
|
||||||
|
# If we are offline because there is no apiEndpoint, there's a chance
|
||||||
|
# we've went through a deprovision. We need to set the initialConfigReported
|
||||||
|
# value to '', to ensure that when we do re-provision, we'll report
|
||||||
|
# the config and hardward-specific options won't be lost
|
||||||
|
if !Boolean(resinApiEndpoint)
|
||||||
|
return @config.set({ initialConfigReported: '' })
|
||||||
return
|
return
|
||||||
console.log('Ensuring device is provisioned')
|
console.log('Ensuring device is provisioned')
|
||||||
@provisionDevice()
|
@provisionDevice()
|
||||||
.then =>
|
.then =>
|
||||||
@config.get('initialConfigReported')
|
@config.getMany([ 'initialConfigReported', 'resinApiEndpoint' ])
|
||||||
.then (reported) =>
|
.then ({ initialConfigReported, resinApiEndpoint }) =>
|
||||||
if !checkTruthy(reported)
|
|
||||||
|
# Either we haven't reported our initial config or we've
|
||||||
|
# been re-provisioned
|
||||||
|
if resinApiEndpoint != initialConfigReported
|
||||||
console.log('Reporting initial configuration')
|
console.log('Reporting initial configuration')
|
||||||
@reportInitialConfig(bootstrapRetryDelay)
|
@reportInitialConfig(resinApiEndpoint, bootstrapRetryDelay)
|
||||||
.then =>
|
.then =>
|
||||||
console.log('Starting current state report')
|
console.log('Starting current state report')
|
||||||
@startCurrentStateReport()
|
@startCurrentStateReport()
|
||||||
@ -277,7 +286,7 @@ module.exports = class APIBinder
|
|||||||
|
|
||||||
# Creates the necessary config vars in the API to match the current device state,
|
# Creates the necessary config vars in the API to match the current device state,
|
||||||
# without overwriting any variables that are already set.
|
# without overwriting any variables that are already set.
|
||||||
_reportInitialEnv: =>
|
_reportInitialEnv: (apiEndpoint) =>
|
||||||
Promise.join(
|
Promise.join(
|
||||||
@deviceState.getCurrentForComparison()
|
@deviceState.getCurrentForComparison()
|
||||||
@getTargetState()
|
@getTargetState()
|
||||||
@ -301,15 +310,15 @@ module.exports = class APIBinder
|
|||||||
body: envVar
|
body: envVar
|
||||||
)
|
)
|
||||||
.then =>
|
.then =>
|
||||||
@config.set({ initialConfigReported: 'true' })
|
@config.set({ initialConfigReported: apiEndpoint })
|
||||||
|
|
||||||
reportInitialConfig: (retryDelay) =>
|
reportInitialConfig: (apiEndpoint, retryDelay) =>
|
||||||
@_reportInitialEnv()
|
@_reportInitialEnv(apiEndpoint)
|
||||||
.catch (err) =>
|
.catch (err) =>
|
||||||
console.error('Error reporting initial configuration, will retry', err)
|
console.error('Error reporting initial configuration, will retry', err)
|
||||||
Promise.delay(retryDelay)
|
Promise.delay(retryDelay)
|
||||||
.then =>
|
.then =>
|
||||||
@reportInitialConfig(retryDelay)
|
@reportInitialConfig(apiEndpoint, retryDelay)
|
||||||
|
|
||||||
getTargetState: =>
|
getTargetState: =>
|
||||||
@config.getMany([ 'uuid', 'resinApiEndpoint', 'apiTimeout' ])
|
@config.getMany([ 'uuid', 'resinApiEndpoint', 'apiTimeout' ])
|
||||||
|
Loading…
x
Reference in New Issue
Block a user