balena-supervisor/src
Pablo Carranza Velez 42737cb9e9 Fix a race condition that could cause an unnecessary restart of a service immediately after download
Up to now, there was a slim but non-zero chance that an image would be downloaded between the call to `@getTarget` inside deviceState
(which gets the target state and creates Service objects using information from available images), and the call to
`@images.getAvailable` in ApplicationManager (which is used to determine whether we should keep waiting for a download or start the
service). If this race condition happened, then the ApplicationManager would infer that a service was ready to be started (because
the image appears as available), but would have incomplete information about the service because the image wasn't available when
the Service object was created. The result would be that the service would be started, and then immediately on the next applyTarget
the ApplicationManager would try to kill it and restart it to update it with the complete information from the image.

This patch changes this behavior by ensuring that all of the additional information about the current state, which includes available images,
is gathered *before* building the current and target states that we compare. This means that if the image is downloaded after the call to getAvailable, the Service might be constructed with all the information about the image, but it won't be started until the next pass, because ApplicationManager will treat it as still downloading.

Change-type: patch
Signed-off-by: Pablo Carranza Velez <pablo@balena.io>
2018-12-17 15:41:12 -03:00
..
compose Add the ability to restore volumes from a backup.tgz in the data partition 2018-12-12 14:17:33 -03:00
config config: Force config values to strings when storing in db 2018-12-17 10:53:23 +00:00
device-api device-api: Add container id endpoint 2018-11-28 16:44:19 +00:00
lib Add the ability to restore volumes from a backup.tgz in the data partition 2018-12-12 14:17:33 -03:00
logging-backends config: Replace supervisorOfflineMode and offlineMode with unmanaged 2018-12-14 15:01:41 +00:00
migrations Move config.json flag back to the database 2018-12-14 15:01:40 +00:00
types types: Remove temporary Service type in favour of actual compose class 2018-09-24 12:04:51 +01:00
api-binder.coffee Replace offline -> unmanaged in logs and tests 2018-12-17 10:53:24 +00:00
app.coffee Introduce workaround for IPv6 DNS resolution until nodejs becomes RFC 3484 compliant 2018-03-07 07:01:43 -08:00
application-manager.coffee Fix a race condition that could cause an unnecessary restart of a service immediately after download 2018-12-17 15:41:12 -03:00
application-manager.d.ts fix: Correctly type bluebird promises in application-manager typings 2018-11-05 11:44:26 +00:00
db.ts Run prettier on the typescript files 2018-11-02 14:50:13 +00:00
device-config.coffee unmanaged: Default to local mode in target state when unmanaged 2018-12-17 10:53:23 +00:00
device-state.coffee Fix a race condition that could cause an unnecessary restart of a service immediately after download 2018-12-17 15:41:12 -03:00
event-tracker.ts config: Replace supervisorOfflineMode and offlineMode with unmanaged 2018-12-14 15:01:41 +00:00
host-config.coffee Replace the gosuper component with a node module that handles communication with systemd, and stop using an init system in the supervisor container 2018-03-22 15:55:15 +00:00
local-mode.ts Switch to local mode in unmanaged mode 2018-12-14 15:01:41 +00:00
logger.ts config: Replace supervisorOfflineMode and offlineMode with unmanaged 2018-12-14 15:01:41 +00:00
network.ts Convert network module to typescript 2018-11-28 15:15:06 +00:00
proxyvisor.coffee Rename most of the documentation and variable names from resin to balena 2018-11-01 17:00:13 -07:00
supervisor-api.coffee Require an apikey for supervisor api in production unmanaged 2018-12-14 15:01:41 +00:00
supervisor.coffee config: Replace supervisorOfflineMode and offlineMode with unmanaged 2018-12-14 15:01:41 +00:00