Handle docker server failures if others succeed

pull/719/head
Michael Shamoon 1 year ago
parent cac21ebd38
commit 6b90d3ef28

@ -52,7 +52,7 @@ export async function servicesResponse() {
discoveredServices = cleanServiceGroups(await servicesFromDocker());
} catch (e) {
console.error("Failed to discover services, please check docker.yaml for errors or remove example entries.");
if (e) console.error(e);
if (e) console.error(e.toString());
discoveredServices = [];
}
@ -60,7 +60,7 @@ export async function servicesResponse() {
configuredServices = cleanServiceGroups(await servicesFromConfig());
} catch (e) {
console.error("Failed to load services.yaml, please check for errors");
if (e) console.error(e);
if (e) console.error(e.toString());
configuredServices = [];
}
@ -68,7 +68,7 @@ export async function servicesResponse() {
initialSettings = await getSettings();
} catch (e) {
console.error("Failed to load settings.yaml, please check for errors");
if (e) console.error(e);
if (e) console.error(e.toString());
initialSettings = {};
}

@ -44,6 +44,7 @@ export async function servicesFromDocker() {
const serviceServers = await Promise.all(
Object.keys(servers).map(async (serverName) => {
try {
const docker = new Docker(getDockerArguments(serverName).conn);
const containers = await docker.listContainers({
all: true,
@ -74,9 +75,17 @@ export async function servicesFromDocker() {
});
return { server: serverName, services: discovered.filter((filteredService) => filteredService) };
} catch (e) {
// a server failed, but others may succeed
return { server: serverName, services: [] };
}
})
);
if (serviceServers.every(server => server.services.length === 0)) {
throw new Error('All docker servers failed to connect or returned no containers');
}
const mappedServiceGroups = [];
serviceServers.forEach((server) => {

Loading…
Cancel
Save