Merge pull request #1093 from balena-io/1083-fix-purge

Fix purge action, after v10 volume rework
This commit is contained in:
CameronDiver 2019-09-18 09:45:49 +01:00 committed by GitHub
commit 19582a1551
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 3 deletions

View File

@ -1,3 +1,4 @@
Bluebird = require('bluebird')
_ = require('lodash')
{ appNotFoundMessage } = require('../lib/messages')
@ -23,7 +24,7 @@ exports.doRestart = (applications, appId, force) ->
deviceState.triggerApplyTarget()
exports.doPurge = (applications, appId, force) ->
{ logger, _lockingIfNecessary, deviceState } = applications
{ logger, _lockingIfNecessary, deviceState, volumes } = applications
logger.logSystemMessage("Purging data for app #{appId}", { appId }, 'Purge data')
_lockingIfNecessary appId, { force }, ->
@ -38,6 +39,12 @@ exports.doPurge = (applications, appId, force) ->
currentState.local.apps[appId] = purgedApp
deviceState.pausingApply ->
deviceState.applyIntermediateTarget(currentState, { skipLock: true })
.then ->
# Now that we're not running anything, explicitly
# remove the volumes, we must do this here, as the
# application-manager will not remove any volumes
# which are part of an active application
Bluebird.each(volumes.getAllByAppId(appId), (vol) -> vol.remove())
.then ->
currentState.local.apps[appId] = app
deviceState.applyIntermediateTarget(currentState, { skipLock: true })

View File

@ -203,8 +203,12 @@ export class BalenaLogBackend extends LogBackend {
}
if (this.writable) {
this.writable = this.stream.write(JSON.stringify(message) + '\n');
this.flush();
try {
this.writable = this.stream.write(JSON.stringify(message) + '\n');
this.flush();
} catch (e) {
log.error('Failed to write to logging stream, dropping message.', e);
}
} else {
this.dropCount += 1;
}