Skip to content

Keep autodiscovered datasource when a probe errors#282

Open
damilolaedwards wants to merge 1 commit into
ethpandaops:masterfrom
damilolaedwards:fix/clickhouse-autodiscover-transient-removal
Open

Keep autodiscovered datasource when a probe errors#282
damilolaedwards wants to merge 1 commit into
ethpandaops:masterfrom
damilolaedwards:fix/clickhouse-autodiscover-transient-removal

Conversation

@damilolaedwards

Copy link
Copy Markdown

Problem

reconcileClickHouseAutodiscover removed a present ClickHouse datasource whenever a probe reported it unavailable, but clickHouseAutodiscoverAvailable returns available=false for two different outcomes: the probe succeeded and the database is genuinely absent, and the probe failed. The removal branch (!available && *present) ran before the err != nil check, so a transient failure fell straight into removal.

A single probe timeout, network blip, or 5xx therefore tore down a healthy datasource, with no retry or debounce. The datasource then flapped back on the next successful probe. The parent context is not cancelled by a client-side timeout, so the existing ctx.Err() guard does not catch this. Under intermittent backend slowness the datasource, its module, and its MCP resources flap in and out, and queries fail with "datasource not found" against a healthy backend.

Fix

Check the probe error before the add and remove branches. On error, log and leave the current state unchanged, so removal only happens when a probe succeeds and reports the database absent.

Tests

Updated the reconcile test, which previously used a probe error to trigger removal. It now asserts that a transient probe error keeps the datasource, and that a successful probe reporting the database absent removes it. The updated test fails on the old code and passes on the new code. Full pkg/proxy suite passes.

reconcileClickHouseAutodiscover removed a present datasource whenever a
probe reported unavailable, treating a probe failure the same as a
confirmed absence. A transient timeout, network blip, or 5xx therefore
tore down a healthy datasource, which flapped back on the next
successful probe.

Handle the probe error before the add and remove branches and leave the
current state unchanged on error, so removal only happens when a probe
succeeds and reports the database absent. Update the reconcile test to
cover surviving a transient error and removal on genuine absence.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant