mirror of
https://github.com/balena-os/balena-supervisor.git
synced 2025-02-25 03:06:33 +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!
|
||||
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
|
||||
|
||||
* Update gitignore to ignore new test files #653 [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.5.6",
|
||||
"version": "7.6.0",
|
||||
"license": "Apache-2.0",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
@ -82,19 +82,28 @@ module.exports = class APIBinder
|
||||
@cachedResinApi = @resinApi.clone({}, cache: {})
|
||||
|
||||
start: =>
|
||||
@config.getMany([ 'offlineMode', 'bootstrapRetryDelay' ])
|
||||
.then ({ offlineMode, bootstrapRetryDelay }) =>
|
||||
@config.getMany([ 'resinApiEndpoint', 'offlineMode', 'bootstrapRetryDelay' ])
|
||||
.then ({ resinApiEndpoint, offlineMode, bootstrapRetryDelay }) =>
|
||||
if offlineMode
|
||||
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
|
||||
console.log('Ensuring device is provisioned')
|
||||
@provisionDevice()
|
||||
.then =>
|
||||
@config.get('initialConfigReported')
|
||||
.then (reported) =>
|
||||
if !checkTruthy(reported)
|
||||
@config.getMany([ 'initialConfigReported', 'resinApiEndpoint' ])
|
||||
.then ({ initialConfigReported, resinApiEndpoint }) =>
|
||||
|
||||
# Either we haven't reported our initial config or we've
|
||||
# been re-provisioned
|
||||
if resinApiEndpoint != initialConfigReported
|
||||
console.log('Reporting initial configuration')
|
||||
@reportInitialConfig(bootstrapRetryDelay)
|
||||
@reportInitialConfig(resinApiEndpoint, bootstrapRetryDelay)
|
||||
.then =>
|
||||
console.log('Starting current state report')
|
||||
@startCurrentStateReport()
|
||||
@ -277,7 +286,7 @@ module.exports = class APIBinder
|
||||
|
||||
# Creates the necessary config vars in the API to match the current device state,
|
||||
# without overwriting any variables that are already set.
|
||||
_reportInitialEnv: =>
|
||||
_reportInitialEnv: (apiEndpoint) =>
|
||||
Promise.join(
|
||||
@deviceState.getCurrentForComparison()
|
||||
@getTargetState()
|
||||
@ -301,15 +310,15 @@ module.exports = class APIBinder
|
||||
body: envVar
|
||||
)
|
||||
.then =>
|
||||
@config.set({ initialConfigReported: 'true' })
|
||||
@config.set({ initialConfigReported: apiEndpoint })
|
||||
|
||||
reportInitialConfig: (retryDelay) =>
|
||||
@_reportInitialEnv()
|
||||
reportInitialConfig: (apiEndpoint, retryDelay) =>
|
||||
@_reportInitialEnv(apiEndpoint)
|
||||
.catch (err) =>
|
||||
console.error('Error reporting initial configuration, will retry', err)
|
||||
Promise.delay(retryDelay)
|
||||
.then =>
|
||||
@reportInitialConfig(retryDelay)
|
||||
@reportInitialConfig(apiEndpoint, retryDelay)
|
||||
|
||||
getTargetState: =>
|
||||
@config.getMany([ 'uuid', 'resinApiEndpoint', 'apiTimeout' ])
|
||||
|
Loading…
x
Reference in New Issue
Block a user