cloudConfig: restart worker on submit

Restart osbuild-composer and the worker after updating the config, this
is a necessary step for osbuild-composer to register the changes.
This commit is contained in:
Gianluca Zuccarelli 2025-04-30 10:46:02 +00:00 committed by Sanne Raymaekers
parent 5afe1c1fc1
commit 1ed4380bfc

View file

@ -652,6 +652,39 @@ export const cockpitApi = contentSourcesApi.injectEndpoints({
});
});
const systemServices = [
'osbuild-composer.socket',
'osbuild-worker@*.service',
'osbuild-composer.service',
];
await cockpit.spawn(
[
'systemctl',
'stop',
// we need to be explicit here and stop all the services first,
// otherwise this step is a little bit flaky
...systemServices,
],
{
superuser: 'require',
}
);
await cockpit.spawn(
[
'systemctl',
'restart',
// we need to restart all the services explicitly too
// since the config doesn't always get reloaded if we
// only reload the worker service
...systemServices,
],
{
superuser: 'require',
}
);
return { data: TOML.parse(contents) };
} catch (error) {
return { error };