mirror of
https://github.com/balena-os/balena-supervisor.git
synced 2024-12-18 13:26:26 +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.
|
||||
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
|
||||
public async initialise(): Promise<ConfigBackend> {
|
||||
return this;
|
||||
|
@ -1,6 +1,7 @@
|
||||
import { isRight } from 'fp-ts/lib/Either';
|
||||
import Reporter from 'io-ts-reporters';
|
||||
import * as t from 'io-ts';
|
||||
import * as _ from 'lodash';
|
||||
|
||||
import { ConfigBackend } from './backend';
|
||||
import type { ConfigOptions } from './backend';
|
||||
@ -145,6 +146,16 @@ export class PowerFanConfig extends ConfigBackend {
|
||||
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 {
|
||||
return PowerFanConfig.stripPrefix(envVar).toLowerCase();
|
||||
}
|
||||
|
@ -529,18 +529,21 @@ async function getBackendSteps(
|
||||
const { deviceType } = await config.getMany(['deviceType']);
|
||||
|
||||
// Check for required bootConfig changes
|
||||
let rebootRequired = false;
|
||||
for (const backend of backends) {
|
||||
if (changeRequired(backend, current, target, deviceType)) {
|
||||
steps.push({
|
||||
action: 'setBootConfig',
|
||||
target,
|
||||
});
|
||||
rebootRequired =
|
||||
(await backend.isRebootRequired(target)) || rebootRequired;
|
||||
}
|
||||
}
|
||||
|
||||
return [
|
||||
// All backend steps require a reboot
|
||||
...(steps.length > 0
|
||||
// All backend steps require a reboot except fan control
|
||||
...(steps.length > 0 && rebootRequired
|
||||
? [{ action: 'setRebootBreadcrumb' } as ConfigStep]
|
||||
: []),
|
||||
...steps,
|
||||
|
Loading…
Reference in New Issue
Block a user