Merge pull request #1900 from fosrl/copilot/fix-hc-health-status-unknown

Reset hcHealth to "unknown" when health check is disabled
This commit is contained in:
Owen Schwartz
2025-12-06 11:20:38 -05:00
committed by GitHub

View File

@@ -208,6 +208,12 @@ export async function updateTarget(
hcHeaders = JSON.stringify(parsedBody.data.hcHeaders);
}
// When health check is disabled, reset hcHealth to "unknown"
// to prevent previously unhealthy targets from being excluded
const hcHealthValue = (parsedBody.data.hcEnabled === false || parsedBody.data.hcEnabled === null)
? "unknown"
: undefined;
const [updatedHc] = await db
.update(targetHealthCheck)
.set({
@@ -223,7 +229,8 @@ export async function updateTarget(
hcHeaders: hcHeaders,
hcFollowRedirects: parsedBody.data.hcFollowRedirects,
hcMethod: parsedBody.data.hcMethod,
hcStatus: parsedBody.data.hcStatus
hcStatus: parsedBody.data.hcStatus,
...(hcHealthValue !== undefined && { hcHealth: hcHealthValue })
})
.where(eq(targetHealthCheck.targetId, targetId))
.returning();