feat(ch-cloud): ClickHouse Cloud connect preset + optional billing usage sync (plan 41) by duyet · Pull Request #2240 · chmonitor/chmonitor · GitHub
Skip to content

feat(ch-cloud): ClickHouse Cloud connect preset + optional billing usage sync (plan 41) - #2240

Merged
duyet merged 4 commits into
mainfrom
advisor/41-clickhouse-cloud-connect-wizard
Jul 3, 2026
Merged

feat(ch-cloud): ClickHouse Cloud connect preset + optional billing usage sync (plan 41)#2240
duyet merged 4 commits into
mainfrom
advisor/41-clickhouse-cloud-connect-wizard

Conversation

@duyet

@duyet duyet commented Jul 3, 2026

Copy link
Copy Markdown
Member

What (plan 41 — ClickHouse Cloud connect wizard)

  • ClickHouse Cloud preset in the add-host wizard (connection-presets.ts + connection-form.tsx) — additive; the manual add-host flow is untouched and the SSRF/host-validation guard is preserved.
  • Optional CH-Cloud billing usage sync (lib/ch-cloud/billing-sync.ts), fail-open without config.
  • 11 tests pass (presets + billing-sync); bun run check + depcruise clean.

🔶 Held for review

Touches the connection form (SSRF-adjacent surface) and adds a billing-usage sync. Also overlaps held #2225 (plan 66)'s add-host dialog — reconcile at merge. Docs were the only unfinished piece (agent stalled before the docs step); code + tests are complete.

Co-Authored-By: duyetbot bot@duyet.net

duyet and others added 2 commits July 3, 2026 20:50
Add a "Self-hosted / ClickHouse Cloud" connection-type selector to
ConnectionForm. Selecting Cloud sets host-field placeholder/hint text for
the Cloud hostname pattern, defaults username to "default" when empty, and
normalizes a pasted host on blur to https + port 8443 (the HTTPS interface
ClickHouse Cloud requires) so a Cloud service connects on the first try.

The connection model stores a single `host` URL string (no separate
secure/port fields), so the preset works by normalizing that string rather
than toggling fields. An explicit http:// choice is never silently
rewritten — instead the Test Connection error panel gets a Cloud-specific
TLS/port hint when the preset is active. Self-host behavior and the
existing SSRF-guarded test/create routes are unchanged.

Co-Authored-By: duyetbot <bot@duyet.net>
New src/lib/ch-cloud/billing-sync.ts, off by default. Only runs when both
CHM_FEATURE_CLOUD_BILLING_SYNC and full API credentials
(CLICKHOUSE_CLOUD_API_KEY_ID/_SECRET/_ORG_ID) are configured; otherwise a
true no-op (no network call, no data, no placeholder numbers).

When configured, fetches organization usage/cost from the ClickHouse Cloud
API through the same SSRF-guarded fetch the add-host wizard uses
(createHostValidationFetch/validateHostUrl) rather than opening a second,
unguarded outbound path, and caches successful results for an hour via the
shared in-memory cache.

Two things deliberately left for a follow-up once a real consumer exists
(no cost-card UI or cost-aware alerts exist in this codebase yet): the
response is returned as `unknown` rather than parsed into named cost
fields, and the auth format (HTTP Basic, key id/secret) was not
independently re-verified against ClickHouse's current API reference.
Also note the guarded fetch's DNS-pinning needs Node's `node:dns`, so this
sync only runs end-to-end under Node.js (self-hosted); on the Cloudflare
Workers runtime it fails closed with a reported error, never a crash.

Co-Authored-By: duyetbot <bot@duyet.net>
@github-actions github-actions Bot added the app: dashboard Changes to the apps/dashboard TanStack Start app label Jul 3, 2026
@github-actions

github-actions Bot commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

bun 1.3.13's lcov coverage writer intermittently throws "error: An
internal error occurred (WriteFailed)" after all tests have already
passed. Reproduced deterministically in CI on both main and this PR
(all 5000+ tests pass, then the coverage writer step fails); a local
run against bun 1.3.14 is clean. Bump the unit-tests job's pinned
bun-version to 1.3.14.

Co-Authored-By: duyetbot <bot@duyet.net>
@github-actions github-actions Bot added the area: ci CI / workflows / .github label Jul 3, 2026
@github-actions

github-actions Bot commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

☁️ Cloudflare Preview Deployment

App Preview URL
Dashboard https://preview.dash.chmonitor.dev
MCP https://preview.dash.chmonitor.dev/api/mcp
Landing https://preview.chmonitor.dev
Docs https://preview.docs.chmonitor.dev
Property Value
Commit 3c993dd
Deployed at 2026-07-03T16:18:35.401Z

Previews are automatically updated on every push to this PR.
Unchanged apps keep their previous preview (path-filtered deploys).

@duyet
duyet enabled auto-merge (squash) July 3, 2026 17:48
@github-actions

github-actions Bot commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

☁️ Cloudflare Preview Deployment

App Preview URL
Dashboard https://preview.dash.chmonitor.dev
MCP https://preview.dash.chmonitor.dev/api/mcp
Landing https://preview.chmonitor.dev
Docs https://preview.docs.chmonitor.dev
Property Value
Commit 436a17f
Deployed at 2026-07-03T17:51:22.210Z

Previews are automatically updated on every push to this PR.
Unchanged apps keep their previous preview (path-filtered deploys).

@duyet
duyet merged commit 63aa030 into main Jul 3, 2026
18 of 20 checks passed
@duyet
duyet deleted the advisor/41-clickhouse-cloud-connect-wizard branch July 3, 2026 17:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app: dashboard Changes to the apps/dashboard TanStack Start app area: ci CI / workflows / .github

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant