fix(services): считать failover по DNS-пулу а не по статусу ноды
quality / commitlint (push) Skipped
CD / update-wiki (push) Successful in 7s
quality / changes (push) Successful in 9s
quality / api (push) Skipped
quality / docker-check (push) Skipped
CD / quality (push) Canceled after 34s
CD / publish (push) Canceled after 0s
quality / web (push) Canceled after 22s
quality / commitlint (push) Skipped
CD / update-wiki (push) Successful in 7s
quality / changes (push) Successful in 9s
quality / api (push) Skipped
quality / docker-check (push) Skipped
CD / quality (push) Canceled after 34s
CD / publish (push) Canceled after 0s
quality / web (push) Canceled after 22s
Красный инцидент только если адреса нет в active_addresses, даже при unhealthy. Co-authored-by: Cursor <[email protected]>
This commit is contained in:
@@ -53,8 +53,8 @@ export function FailoverTimeline({ events }: { events: FailoverEvent[] }) {
|
||||
return (
|
||||
<EmptyState
|
||||
icon={ShieldCheckIcon}
|
||||
title="Пул стабилен"
|
||||
description="События появятся, когда нода станет unhealthy или down и будет выведена из пула"
|
||||
title="Пул в DNS на месте"
|
||||
description="Красным только адреса, которых нет в активном пуле A-записей"
|
||||
stackedIcon={false}
|
||||
centered={false}
|
||||
/>
|
||||
@@ -93,8 +93,8 @@ export function FailoverTimeline({ events }: { events: FailoverEvent[] }) {
|
||||
<TimelineContent className="flex flex-col gap-2">
|
||||
<p className="text-foreground text-sm">
|
||||
{isChecking
|
||||
? 'Health-check ещё не завершён — нода не в активном пуле'
|
||||
: 'Нода выведена из активного пула'}
|
||||
? 'Снята с DNS, идёт восстановление'
|
||||
: 'Снята с DNS — в A-записях этого адреса нет'}
|
||||
</p>
|
||||
{event.lastFailureReason ? (
|
||||
<code
|
||||
|
||||
@@ -40,10 +40,12 @@ function failoverCountLabel(count: number): string {
|
||||
*/
|
||||
export function ServiceFailoverPanel({
|
||||
nodes,
|
||||
activeAddresses,
|
||||
}: {
|
||||
nodes: readonly FailoverNodeInput[]
|
||||
activeAddresses: readonly string[]
|
||||
}) {
|
||||
const events = toFailoverEvents(nodes)
|
||||
const events = toFailoverEvents(nodes, activeAddresses)
|
||||
|
||||
return (
|
||||
<Frame stacked spacing="sm" className="min-w-0 w-full">
|
||||
@@ -62,7 +64,7 @@ export function ServiceFailoverPanel({
|
||||
)}
|
||||
</FrameTitle>
|
||||
<FrameDescription>
|
||||
Нездоровые ноды выведены из пула · причина последней ошибки
|
||||
Только адреса, которых нет в DNS-пуле · не статус строки ноды
|
||||
</FrameDescription>
|
||||
</FrameHeader>
|
||||
|
||||
@@ -71,7 +73,7 @@ export function ServiceFailoverPanel({
|
||||
<UnplugIcon aria-hidden="true" />
|
||||
<AlertTitle>{failoverCountLabel(events.length)}</AlertTitle>
|
||||
<AlertDescription>
|
||||
Трафик на эти адреса не идёт, пока health не восстановится
|
||||
Эти IP сняты с A-записей
|
||||
</AlertDescription>
|
||||
</Alert>
|
||||
) : null}
|
||||
|
||||
@@ -20,34 +20,72 @@ function node(
|
||||
}
|
||||
|
||||
describe('toFailoverEvents', () => {
|
||||
it('оставляет только unhealthy / down / checking', () => {
|
||||
it('не считает healthy failover-событием', () => {
|
||||
expect(isFailoverEventStatus('healthy')).toBe(false)
|
||||
expect(isFailoverEventStatus('unhealthy')).toBe(true)
|
||||
})
|
||||
|
||||
it('без DNS-пула ничего не показывает — нельзя врать про вывод', () => {
|
||||
const events = toFailoverEvents([
|
||||
node({ address: '10.0.0.1', health_status: 'healthy' }),
|
||||
node({
|
||||
address: '130.49.213.153',
|
||||
health_status: 'unhealthy',
|
||||
consecutive_failures: 9,
|
||||
last_failure_reason: 'fetch failed',
|
||||
last_check_at: '2026-08-20 07:00:00',
|
||||
}),
|
||||
node({ address: '10.0.0.3', health_status: 'checking' }),
|
||||
node({ address: '10.0.0.4', health_status: 'disabled' }),
|
||||
])
|
||||
|
||||
expect(events.map((event) => event.address)).toEqual([
|
||||
'130.49.213.153',
|
||||
'10.0.0.3',
|
||||
])
|
||||
expect(events[0]).toMatchObject({
|
||||
consecutiveFailures: 9,
|
||||
lastFailureReason: 'fetch failed',
|
||||
lastCheckAt: '2026-08-20 07:00:00',
|
||||
status: 'unhealthy',
|
||||
})
|
||||
expect(events).toEqual([])
|
||||
})
|
||||
|
||||
it('не считает healthy failover-событием', () => {
|
||||
expect(isFailoverEventStatus('healthy')).toBe(false)
|
||||
expect(isFailoverEventStatus('unhealthy')).toBe(true)
|
||||
it('нездоровый адрес в DNS-пуле не инцидент (last-resort / ещё в A-записи)', () => {
|
||||
const events = toFailoverEvents(
|
||||
[
|
||||
node({
|
||||
address: '130.49.213.153',
|
||||
health_status: 'unhealthy',
|
||||
consecutive_failures: 9,
|
||||
last_failure_reason: 'fetch failed',
|
||||
}),
|
||||
node({ address: '10.0.0.3', health_status: 'checking' }),
|
||||
],
|
||||
['130.49.213.153', '10.0.0.2'],
|
||||
)
|
||||
expect(events.map((event) => event.address)).toEqual(['10.0.0.3'])
|
||||
})
|
||||
|
||||
it('здоровый standby вне пула не инцидент', () => {
|
||||
const events = toFailoverEvents(
|
||||
[
|
||||
node({ address: '10.0.0.1', health_status: 'healthy' }),
|
||||
node({ address: '10.0.0.2', health_status: 'healthy' }),
|
||||
],
|
||||
['10.0.0.1'],
|
||||
)
|
||||
expect(events).toEqual([])
|
||||
})
|
||||
|
||||
it('нездоровый адрес без A-записи — реальный вывод из пула', () => {
|
||||
const events = toFailoverEvents(
|
||||
[
|
||||
node({
|
||||
address: '130.49.213.153',
|
||||
health_status: 'unhealthy',
|
||||
consecutive_failures: 9,
|
||||
last_failure_reason: 'fetch failed',
|
||||
last_check_at: '2026-08-20 07:00:00',
|
||||
}),
|
||||
],
|
||||
['10.0.0.1'],
|
||||
)
|
||||
expect(events).toEqual([
|
||||
{
|
||||
id: '130.49.213.153',
|
||||
address: '130.49.213.153',
|
||||
status: 'unhealthy',
|
||||
consecutiveFailures: 9,
|
||||
lastFailureReason: 'fetch failed',
|
||||
lastCheckAt: '2026-08-20 07:00:00',
|
||||
},
|
||||
])
|
||||
})
|
||||
})
|
||||
|
||||
@@ -22,15 +22,25 @@ export function isFailoverEventStatus(status: string): boolean {
|
||||
return FAILOVER_STATUSES.has(status)
|
||||
}
|
||||
|
||||
/**
|
||||
* Инцидент failover = нездоровый адрес, которого нет в DNS-пуле.
|
||||
* Нода в activeAddresses (в т.ч. last-resort) — не «выведена».
|
||||
*/
|
||||
export function toFailoverEvents(
|
||||
nodes: readonly FailoverNodeInput[],
|
||||
activeAddresses: readonly string[] = [],
|
||||
): FailoverEvent[] {
|
||||
return nodes.filter((node) => isFailoverEventStatus(node.health_status)).map((node) => ({
|
||||
id: String(node.id ?? node.address),
|
||||
address: node.address,
|
||||
status: node.health_status,
|
||||
consecutiveFailures: node.consecutive_failures,
|
||||
lastFailureReason: node.last_failure_reason,
|
||||
lastCheckAt: node.last_check_at ?? null,
|
||||
}))
|
||||
const pool = new Set(activeAddresses)
|
||||
if (pool.size === 0) return []
|
||||
|
||||
return nodes
|
||||
.filter((node) => isFailoverEventStatus(node.health_status) && !pool.has(node.address))
|
||||
.map((node) => ({
|
||||
id: String(node.id ?? node.address),
|
||||
address: node.address,
|
||||
status: node.health_status,
|
||||
consecutiveFailures: node.consecutive_failures,
|
||||
lastFailureReason: node.last_failure_reason,
|
||||
lastCheckAt: node.last_check_at ?? null,
|
||||
}))
|
||||
}
|
||||
|
||||
@@ -313,7 +313,10 @@ function ServiceDetailPage() {
|
||||
statuses={providerStatuses}
|
||||
isLoading={logQuery.isLoading}
|
||||
/>
|
||||
<ServiceFailoverPanel nodes={failoverNodes} />
|
||||
<ServiceFailoverPanel
|
||||
nodes={failoverNodes}
|
||||
activeAddresses={overview?.active_addresses ?? service.active_ips}
|
||||
/>
|
||||
</section>
|
||||
|
||||
{service.ips.length === 0 && service.domains.length === 0 ? (
|
||||
|
||||
Reference in New Issue
Block a user