Skip to content

fix(links): report Kafka probe failures as degraded, not unavailable - #1140

Open
Tyagiquamar wants to merge 13 commits into
databuddy-analytics:mainfrom
Tyagiquamar:fix-links-health-fail-kafka-719
Open

Tyagiquamar wants to merge 13 commits into
databuddy-analytics:mainfrom
Tyagiquamar:fix-links-health-fail-kafka-719

Conversation

@Tyagiquamar

@Tyagiquamar Tyagiquamar commented Oct 18, 2026 •

Copy link
Copy Markdown

Summary

Addresses maintainer feedback on #721 (supersedes the closed PR).

  • Keeps calculateLinkReadiness as the single HTTP status policy: Kafka down with ClickHouse up stays HTTP 200 degraded.
  • Maps Redpanda to error when the health probe leaves the producer in idle but didKafkaConnectFail() is true (fixes false ok readiness).
  • No blanket 503 short-circuit on Kafka connect failure.

Linked issue

Fixes #719

Test plan

  • bun test apps/links/src/lib/health.test.ts (6 pass)

AI disclosure

AI-assisted implementation; human-reviewed against izadoesdev review on #721.


Summary by cubic

Fixes the links service health check so Kafka failures report degraded instead of unavailable, and no longer reports false ok readiness after a connect failure.

  • Kafka down with ClickHouse up now returns HTTP 200 degraded via calculateLinkReadiness, replacing the previous 503 short-circuit.
  • A failed Kafka connect now maps Redpanda to error even when the producer state is idle, fixing the false ok.
  • refreshProducerConnection rejects loudly on failure and records a kafka_health_connect_failed attribute.
  • sendLinkVisit keeps falling back to ClickHouse when Kafka is unreachable, and disconnectProducer no longer fails if a pending connection dies during shutdown.
  • Redpanda SSL is now disabled when REDPANDA_SSL or REDPANDA_SSL_ENABLED is set to false (previously always on).

Written for commit 56c792a. Summary will update on new commits.

View guided diff

Tyagiquamar and others added 11 commits September 4, 2026 17:58
…ll assertions

Co-authored-by: Cursor <cursoragent@cursor.com>
…ss decide HTTP status

Removes the health endpoint short-circuit that returned 503 whenever
didKafkaConnectFail() was set. Kafka down with ClickHouse up is a
degradation (HTTP 200), which calculateLinkReadiness already encodes.
The loud rejection from refreshProducerConnection and the
kafka_health_connect_failed attribute are unchanged. Also extends the
links CI status poll past the 60s producer reconnect cooldown so one
transient first-connect failure does not fail the job.
External pull requests cannot modify workflow files in this repo
(tripwire protected-file rule). The links status poll extension is
dropped from this PR; a maintainer can land it separately if wanted.
Keep calculateLinkReadiness as the single HTTP status policy. Treat idle
producer state after a connect failure as redpanda error so Kafka+CH stays
HTTP 200 degraded instead of falsely reporting ok.
@coderabbitai

coderabbitai Bot commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: 83c35dd2-0166-4fb5-af4f-ded3dc976982

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@vercel

vercel Bot commented Oct 18, 2026

Copy link
Copy Markdown

@Tyagiquamar is attempting to deploy a commit to the Databuddy OSS Team on Vercel.

A member of the Team first needs to authorize it.

@greptile-apps

greptile-apps Bot commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 4/5

[Medium impact] The changes affect health reporting and Kafka connections within the Links service.

The behavior changes look sound, but the new tests must satisfy the explicit project rules before merging.

Findings

  1. P2 Tests break project rules ▶

Summary

The PR reports failed Kafka probes as degraded without making Kafka failure alone return HTTP 503.

  • Kafka connection failures show up as Redpanda errors in Links health checks.
  • Kafka health refreshes reject failures without interrupting link-visit handling.
  • Kafka SSL can be disabled through either supported environment setting.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Kafka health probe] --> B{Connected?}
  B -->|Yes| C[Redpanda ok]
  B -->|No| D[Redpanda error]
  C --> E[calculateLinkReadiness]
  D --> E
  E --> F{Postgres and Redis healthy?}
  F -->|No| G[HTTP 503 unavailable]
  F -->|Yes| H{ClickHouse or Redpanda healthy?}
  H -->|No| G
  H -->|Yes, one failed| I[HTTP 200 degraded]
  H -->|Yes, none failed| J[HTTP 200 ok]
Loading

Reviews (1) · Last reviewed commit: "fix(links): map failed Kafka probe to de..." · Reviewed by Greptile

Comment thread apps/links/src/lib/producer.test.ts Outdated
process.env.REDPANDA_BROKER = "redpanda.test:9092";
const realNow = Date.now;
let now = 1000;
Date.now = () => now;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Tests break project rules

The new tests assign directly to Date.now and use delete on environment fields. The project guide forbids assignments to native objects and use of the delete operator. Use a restorable clock spy and Reflect.deleteProperty for the environment cleanup. These repository requirements must be satisfied before merging.

Context Used: Ultracite Rules - AI-Ready Formatter and Linter (source)

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

@Tyagiquamar

Copy link
Copy Markdown
Author

Supersedes closed #721 per izadoesdev review: no Kafka 503 short-circuit; \mapRedpandaServiceStatus\ maps \idle\ + \didKafkaConnectFail()\ to \error\ so Kafka-down + ClickHouse-up stays HTTP 200 \degraded. Tests: \�un test apps/links/src/lib/health.test.ts\ (6 pass) on \c055751c0.

Tyagiquamar and others added 2 commits October 20, 2026 09:37
Use spyOn for Date.now and Reflect.deleteProperty for env cleanup in producer tests.
@vercel

vercel Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

2 Skipped Deployments
Project Deployment Actions Updated
dashboard Skipped Skipped Oct 20, 2026 4:53am UTC
documentation Skipped Skipped Oct 20, 2026 4:53am UTC

@vercel
vercel Bot temporarily deployed to Preview – documentation October 20, 2026 04:53 Inactive
@vercel
vercel Bot temporarily deployed to Preview – dashboard October 20, 2026 04:53 Inactive

This branch was previously deployed

2 inactive deployments
Preview – dashboard — 56c792a5 Deployed Oct 20, 2026 by vercel[bot]
Preview – documentation — 56c792a5 Deployed Oct 20, 2026 by vercel[bot]
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.

links health check no longer exercises Kafka delivery

2 participants