fix: report partial inventory refresh

This commit is contained in:
ajnart committed 2026-08-26 15:46:35 +02:00
1 parent 25cc3b9402
commit 6f85e18065
4 files changed
+13 -5

No files matched your search

+3
View File
@@ -144,6 +144,9 @@ Docker or Podman endpoints from targeting the wrong service.
Docker environment, or pass one or more IDs returned by `docker.getEndpoints` to query only those Dockerode clients. The
Docker widget uses the same behavior for its environment selector.
`docker.refreshInventory` always refreshes the current replica and returns `scope: "all"` after cross-replica publication or
`scope: "local"` when Redis is unavailable. A local result is partial success: retry after restoring Redis to refresh every replica.
## Partial integration failures
Multi-integration widget queries keep data from integrations that remain available. Calendar and media-server results include
@@ -239,10 +239,8 @@ export const createSessionQueryPersister = (
const persistNow = (client: PersistedClient) => {
if (!storage || persistenceDisabled) return;
let candidate: PersistedClient | undefined;
let sanitizedQueryCount = 0;
try {
const sanitizedClient = sanitizePersistedClient(client);
sanitizedQueryCount = sanitizedClient.clientState.queries.length;
candidate = trimToQueryLimit(sanitizedClient);
} catch {
persistenceDisabled = true;
@@ -254,10 +252,11 @@ export const createSessionQueryPersister = (
return;
}
let quotaLimited = false;
while (candidate) {
try {
storage.setItem(key, stringify(candidate));
if (candidate.clientState.queries.length < sanitizedQueryCount) {
if (quotaLimited) {
persistedQueryLimit = Math.min(persistedQueryLimit, candidate.clientState.queries.length);
}
return;
@@ -267,6 +266,7 @@ export const createSessionQueryPersister = (
persistenceDisabled = true;
return;
}
quotaLimited = true;
candidate = keepNewestQueries(candidate, Math.floor(candidate.clientState.queries.length / 2));
}
}
@@ -199,12 +199,13 @@ export function DockerTable({ initialData }: DockerTableProps) {
refetchOnMount: false,
});
const refreshInventory = clientApi.docker.refreshInventory.useMutation({
async onSuccess() {
async onSuccess(result) {
await Promise.all([
utils.docker.getContainers.invalidate(),
utils.docker.reconcileServices.invalidate(),
utils.docker.getServiceHealth.invalidate(),
]);
if (result.scope === "local") return;
showSuccessNotification({
title: tDocker("action.refresh.notification.success.title"),
message: tDocker("action.refresh.notification.success.message"),
@@ -44,10 +44,12 @@ try {
const publishDockerInventoryRefreshAsync = async () => {
try {
await dockerInventoryRefreshChannel.publishAsync({ requestedAt: Date.now() });
return true;
} catch (error) {
if (!isRedisDisabled()) {
logger.warn(new Error("Failed to publish Docker inventory refresh", { cause: error }));
}
return false;
}
};
@@ -91,7 +93,9 @@ export const dockerRouter = createTRPCRouter({
.concat(dockerMiddleware())
.mutation(async () => {
resetDockerInventory();
await publishDockerInventoryRefreshAsync();
const propagated = await publishDockerInventoryRefreshAsync();
if (propagated) return { scope: "all" as const };
return { scope: "local" as const };
}),
getContainers: permissionRequiredProcedure
.requiresPermission("admin")