mirror of
https://github.com/balena-os/balena-supervisor.git
synced 2024-12-23 23:42:29 +00:00
Don't require reboot if setting fan control
Signed-off-by: Christina Ying Wang <christina@balena.io>
This commit is contained in:
parent
828bd22ba0
commit
2f2b2e1c50
@ -41,6 +41,12 @@ export abstract class ConfigBackend {
|
|||||||
// Example an empty string should return null.
|
// Example an empty string should return null.
|
||||||
public abstract createConfigVarName(configName: string): string | null;
|
public abstract createConfigVarName(configName: string): string | null;
|
||||||
|
|
||||||
|
// Is a reboot required for the given config options?
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||||
|
public async isRebootRequired(_opts: ConfigOptions): Promise<boolean> {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
// Allow a chosen config backend to be initialised
|
// Allow a chosen config backend to be initialised
|
||||||
public async initialise(): Promise<ConfigBackend> {
|
public async initialise(): Promise<ConfigBackend> {
|
||||||
return this;
|
return this;
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import { isRight } from 'fp-ts/lib/Either';
|
import { isRight } from 'fp-ts/lib/Either';
|
||||||
import Reporter from 'io-ts-reporters';
|
import Reporter from 'io-ts-reporters';
|
||||||
import * as t from 'io-ts';
|
import * as t from 'io-ts';
|
||||||
|
import * as _ from 'lodash';
|
||||||
|
|
||||||
import { ConfigBackend } from './backend';
|
import { ConfigBackend } from './backend';
|
||||||
import type { ConfigOptions } from './backend';
|
import type { ConfigOptions } from './backend';
|
||||||
@ -145,6 +146,16 @@ export class PowerFanConfig extends ConfigBackend {
|
|||||||
return PowerFanConfig.CONFIGS.has(PowerFanConfig.stripPrefix(envVar));
|
return PowerFanConfig.CONFIGS.has(PowerFanConfig.stripPrefix(envVar));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async isRebootRequired(opts: ConfigOptions): Promise<boolean> {
|
||||||
|
const supportedOpts = _.pickBy(
|
||||||
|
_.mapKeys(opts, (_value, key) => PowerFanConfig.stripPrefix(key)),
|
||||||
|
(_value, key) => this.isSupportedConfig(key),
|
||||||
|
);
|
||||||
|
const current = await this.getBootConfig();
|
||||||
|
// A reboot is only required if the power mode is changing
|
||||||
|
return current.power_mode !== supportedOpts.power_mode;
|
||||||
|
}
|
||||||
|
|
||||||
public processConfigVarName(envVar: string): string {
|
public processConfigVarName(envVar: string): string {
|
||||||
return PowerFanConfig.stripPrefix(envVar).toLowerCase();
|
return PowerFanConfig.stripPrefix(envVar).toLowerCase();
|
||||||
}
|
}
|
||||||
|
@ -529,18 +529,21 @@ async function getBackendSteps(
|
|||||||
const { deviceType } = await config.getMany(['deviceType']);
|
const { deviceType } = await config.getMany(['deviceType']);
|
||||||
|
|
||||||
// Check for required bootConfig changes
|
// Check for required bootConfig changes
|
||||||
|
let rebootRequired = false;
|
||||||
for (const backend of backends) {
|
for (const backend of backends) {
|
||||||
if (changeRequired(backend, current, target, deviceType)) {
|
if (changeRequired(backend, current, target, deviceType)) {
|
||||||
steps.push({
|
steps.push({
|
||||||
action: 'setBootConfig',
|
action: 'setBootConfig',
|
||||||
target,
|
target,
|
||||||
});
|
});
|
||||||
|
rebootRequired =
|
||||||
|
(await backend.isRebootRequired(target)) || rebootRequired;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return [
|
return [
|
||||||
// All backend steps require a reboot
|
// All backend steps require a reboot except fan control
|
||||||
...(steps.length > 0
|
...(steps.length > 0 && rebootRequired
|
||||||
? [{ action: 'setRebootBreadcrumb' } as ConfigStep]
|
? [{ action: 'setRebootBreadcrumb' } as ConfigStep]
|
||||||
: []),
|
: []),
|
||||||
...steps,
|
...steps,
|
||||||
|
Loading…
Reference in New Issue
Block a user