mirror of
https://github.com/balena-os/balena-supervisor.git
synced 2025-01-31 00:23:57 +00:00
Avoid fetching an image when it might be available or when starting an app because it might not be necessary
This change removes the behavior where we would try to fetch an app image when starting the app. This might cause an unintended download of an app that is not really needed anymore because we're starting the app on boot and an update cycle would make this image unnecessary. So now we try to inspect the image, and if this fails we will throw an error, causing the app to be soft-deleted and the next update cycle to properly trigger a download of whatever image we need from the target state. We also improve the error catching when fetching an image, to specifically catch an "image not found" error before trying to download - otherwise, any other random error will cause us to try to download the image again, which will not be a noop if we're using deltas. If there's any other error, the correct behavior is to throw and retry later. Change-Type: patch Signed-off-by: Pablo Carranza Velez <pablo@resin.io>
This commit is contained in:
parent
0bc23df8c9
commit
ecf7e4206c
@ -210,7 +210,7 @@ fetch = (app, { deltaSource, setDeviceUpdateState = true } = {}) ->
|
||||
device.updateState(download_progress: progress.percentage)
|
||||
|
||||
docker.getImage(app.imageId).inspect()
|
||||
.catch (error) ->
|
||||
.catch ImageNotFoundError, ->
|
||||
device.updateState(status: 'Downloading', download_progress: 0)
|
||||
|
||||
Promise.try ->
|
||||
@ -286,7 +286,8 @@ application.start = start = (app) ->
|
||||
|
||||
# If there is no existing container then create one instead.
|
||||
containerPromise.catch ->
|
||||
fetch(app)
|
||||
# If the image is not available, we'll let the update cycle fix it
|
||||
docker.getImage(app.imageId).inspect()
|
||||
.then (imageInfo) ->
|
||||
logSystemEvent(logTypes.installApp, app)
|
||||
device.updateState(status: 'Installing')
|
||||
|
Loading…
x
Reference in New Issue
Block a user