Keep autodiscovered datasource when a probe errors#282
Open
damilolaedwards wants to merge 1 commit into
Open
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
reconcileClickHouseAutodiscoverremoved a present ClickHouse datasource whenever a probe reported it unavailable, butclickHouseAutodiscoverAvailablereturnsavailable=falsefor two different outcomes: the probe succeeded and the database is genuinely absent, and the probe failed. The removal branch (!available && *present) ran before theerr != nilcheck, 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/proxysuite passes.