Skip to content

in_kubernetes_events: add sqlite indexes - #12366

Open
cosmo0920 wants to merge 2 commits into
masterfrom
cosmo0920-add-sqlite-indexes-on-in_k8s_events
Open

in_kubernetes_events: add sqlite indexes#12366
cosmo0920 wants to merge 2 commits into
masterfrom
cosmo0920-add-sqlite-indexes-on-in_k8s_events

Conversation

@cosmo0920

@cosmo0920 cosmo0920 commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Implemented SQLite indexes for in_kubernetes_events.

  • Added idempotent indexes for uid and created in kubernetes_events_sql.h.
  • Indexes are created after configured SQLite pragmas; failures are fatal in kubernetes_events_conf.c.
  • Added fresh-database and legacy migration coverage in in_kubernetes_events.c. The legacy fixture includes duplicate UIDs, confirming the indexes remain non-unique.

Verification passed:

  • cmake --build build -j8 --target flb-rt-in_kubernetes_events
  • Focused fresh/migration tests: passed.
  • ctest --test-dir build -R '^flb-rt-in_kubernetes_events$' --output-on-failure: all 7 tests passed.
  • Valgrind focused tests: 0 errors, 0 definitely/possibly lost bytes.
  • git diff --check: passed.

Closes #12327.


Enter [N/A] in the box, if an item is not applicable to your change.

Testing
Before we can approve your change; please submit the following in a comment:

  • Example configuration file for the change
  • Debug log output from testing the change
  • Attached Valgrind output that shows no leaks or memory corruption was found

If this is a change to packaging of containers or native binaries then please confirm it works for all targets.

  • Run local packaging test showing all targets (including any new ones) build.
  • Set ok-package-test label to test for all targets (requires maintainer to do).

Documentation

  • Documentation required for this feature

Backporting

  • Backport to latest stable release.

Fluent Bit is licensed under Apache 2.0, by submitting this pull request I understand that this code will be released under the terms of that license.

Summary by CodeRabbit

  • Performance

    • Improved Kubernetes event database lookup performance by adding indexes for event IDs and creation timestamps.
  • Reliability

    • Database initialization now verifies that required indexes are created and reports failures cleanly if setup cannot be completed.
  • Testing

    • Added coverage for index creation on both new and existing Kubernetes event databases.

@cosmo0920
cosmo0920 requested a review from edsiper as a code owner September 4, 2026 05:58
@cosmo0920 cosmo0920 changed the title in_kubernetes_events: add sqlite indexes on in k8s events in_kubernetes_events: add sqlite indexes Sep 4, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 4, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-04T06:01:02.856047Z 63dcee9 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@coderabbitai

coderabbitai Bot commented Sep 4, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Team

Run ID: e111485a-5955-4377-9325-9f9cc47ecee3

📥 Commits

Reviewing files that changed from the base of the PR and between 98f3bde and 63dcee9.

📒 Files selected for processing (3)
  • plugins/in_kubernetes_events/kubernetes_events_conf.c
  • plugins/in_kubernetes_events/kubernetes_events_sql.h
  • tests/runtime/in_kubernetes_events.c

Included review availability: Your plan provides up to 8 included reviews per hour; 7 remain after this review.


📝 Walkthrough

Walkthrough

The Kubernetes events plugin now creates SQLite indexes on uid and created during database initialization. Initialization fails cleanly if index creation fails. Runtime tests verify indexes for fresh and legacy databases.

Changes

Kubernetes events database indexes

Layer / File(s) Summary
Define and create database indexes
plugins/in_kubernetes_events/kubernetes_events_sql.h, plugins/in_kubernetes_events/kubernetes_events_conf.c
Adds uid and created indexes and handles SQLite index-creation failures during initialization.
Validate new and legacy database indexes
tests/runtime/in_kubernetes_events.c
Adds database-path setup, legacy database creation, index queries, fresh and migrated database tests, updated call sites, and test registration.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Merge Risk: ⚪ Minimal · up to ce0e6

The change adds the requested SQLite indexes while preserving duplicate UIDs and covering both new and existing databases. No merge-blocking risk remains.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 45.45% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 11 functions across 3 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The implementation adds the required indexes, idx_in_kubernetes_events_uid and idx_in_kubernetes_events_created, for fresh and legacy databases. The tests verify index creation and non-unique UID supp…
Out of Scope Changes check ✅ Passed All changes support the requested SQLite index feature. The initialization logic, SQL macro, migration coverage, and runtime tests are within scope.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: adding SQLite indexes to in_kubernetes_events.
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 2
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch cosmo0920-add-sqlite-indexes-on-in_k8s_events

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.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 63dcee948f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread plugins/in_kubernetes_events/kubernetes_events_conf.c
…huge table

Signed-off-by: Hiroshi Hatake <hiroshi@chronosphere.io>
Signed-off-by: Hiroshi Hatake <hiroshi@chronosphere.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

in_kubernetes_events: add SQLite indexes for event deduplication and cleanup

1 participant