mirror of
https://github.com/balena-os/balena-supervisor.git
synced 2024-12-22 06:57:49 +00:00
Merge pull request #2162 from balena-os/host-config-hostname
Do not restart balena-hostname on rename
This commit is contained in:
commit
a9e4bee68e
@ -185,22 +185,10 @@ async function readHostname() {
|
||||
}
|
||||
|
||||
async function setHostname(val: string) {
|
||||
// Changing the hostname on config.json will trigger
|
||||
// the OS config-json service to restart the necessary services
|
||||
// so the change gets reflected on containers
|
||||
await config.set({ hostname: val });
|
||||
|
||||
// restart balena-hostname if it is loaded and NOT PartOf config-json.target
|
||||
if (
|
||||
(
|
||||
await Promise.any([
|
||||
dbus.servicePartOf('balena-hostname'),
|
||||
dbus.servicePartOf('resin-hostname'),
|
||||
])
|
||||
).includes('config-json.target') === false
|
||||
) {
|
||||
await Promise.any([
|
||||
dbus.restartService('balena-hostname'),
|
||||
dbus.restartService('resin-hostname'),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
export async function get(): Promise<HostConfig> {
|
||||
|
@ -122,17 +122,10 @@ describe('host-config', () => {
|
||||
it('patches hostname', async () => {
|
||||
await hostConfig.patch({ network: { hostname: 'test' } });
|
||||
// /etc/hostname isn't changed until the balena-hostname service
|
||||
// is restarted through dbus, so we verify the change from config.
|
||||
// is restarted by the OS.
|
||||
expect(await config.get('hostname')).to.equal('test');
|
||||
});
|
||||
|
||||
it('skips restarting hostname services if they are part of config-json.target', async () => {
|
||||
(dbus.servicePartOf as SinonStub).resolves('config-json.target');
|
||||
await hostConfig.patch({ network: { hostname: 'newdevice' } });
|
||||
expect(dbus.restartService as SinonStub).to.not.have.been.called;
|
||||
expect(await config.get('hostname')).to.equal('newdevice');
|
||||
});
|
||||
|
||||
it('patches proxy', async () => {
|
||||
await hostConfig.patch({
|
||||
network: {
|
||||
|
Loading…
Reference in New Issue
Block a user