mirror of
https://github.com/balena-os/balena-supervisor.git
synced 2025-02-20 17:52:51 +00:00
Log takeLock and releaseLock steps as system events
Signed-off-by: Christina Ying Wang <christina@balena.io>
This commit is contained in:
parent
fd7d58f89a
commit
7220e994dc
@ -5,6 +5,8 @@ export type EventTrackProperties = Dictionary<any>;
|
||||
|
||||
const mixpanelMask = [
|
||||
'appId',
|
||||
'force',
|
||||
'services',
|
||||
'delay',
|
||||
'error',
|
||||
'interval',
|
||||
|
@ -168,3 +168,13 @@ export const removeNetworkError: LogType = {
|
||||
eventName: 'Network removal error',
|
||||
humanName: 'Error removing network',
|
||||
};
|
||||
|
||||
export const takeLock: LogType = {
|
||||
eventName: 'Take update locks',
|
||||
humanName: 'Taking update locks',
|
||||
};
|
||||
|
||||
export const releaseLock: LogType = {
|
||||
eventName: 'Release update locks',
|
||||
humanName: 'Releasing update locks',
|
||||
};
|
||||
|
@ -14,6 +14,8 @@ import * as config from '../config';
|
||||
import * as lockfile from './lockfile';
|
||||
import { NumericIdentifier, StringIdentifier, DockerName } from '../types';
|
||||
import { takeGlobalLockRW } from './process-lock';
|
||||
import * as logger from '../logger';
|
||||
import * as logTypes from './log-types';
|
||||
|
||||
const decodedUid = NumericIdentifier.decode(process.env.LOCKFILE_UID);
|
||||
export const LOCKFILE_UID = isRight(decodedUid) ? decodedUid.right : 65534;
|
||||
@ -87,6 +89,12 @@ export async function takeLock(
|
||||
services: string[],
|
||||
force: boolean = false,
|
||||
) {
|
||||
logger.logSystemEvent(logTypes.takeLock, {
|
||||
appId,
|
||||
services,
|
||||
force,
|
||||
});
|
||||
|
||||
const release = await takeGlobalLockRW(appId);
|
||||
try {
|
||||
const actuallyLocked: string[] = [];
|
||||
@ -122,6 +130,8 @@ export async function takeLock(
|
||||
* Release all locks for an appId | appUuid.
|
||||
*/
|
||||
export async function releaseLock(appId: number) {
|
||||
logger.logSystemEvent(logTypes.releaseLock, { appId });
|
||||
|
||||
const release = await takeGlobalLockRW(appId);
|
||||
await dispose(appId, release);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user