Skip to content

fix: handle invalid cache entries for config location - #2372

Merged
yashmehrotra merged 1 commit into
mainfrom
fix-config-fk
Aug 25, 2026
Merged

fix: handle invalid cache entries for config location#2372
yashmehrotra merged 1 commit into
mainfrom
fix-config-fk

Conversation

@yashmehrotra

@yashmehrotra yashmehrotra commented Aug 25, 2026

Copy link
Copy Markdown
Member

Summary by CodeRabbit

  • Bug Fixes
    • Improved handling of deleted or missing configuration items during updates.
    • Invalid configuration locations are now skipped without causing update failures.
    • Prevented stale aliases from lingering after a configuration is removed.
    • Added bounded warnings when scrape locations reference unavailable configurations.
    • Preserved transaction safety when filtering invalid locations.

@github-actions

github-actions Bot commented Aug 25, 2026

Copy link
Copy Markdown

Benchstat

Base: 8ae3e4094abff6ff9e58b2c9f8ce4d7e4ec2c4e2
Head: 02b45600549a8f8c88ed1e1a9de6ac68276cc7f7

✅ 1 improvement(s)
Benchmark Base Head Change p-value
LocationFilter/largeEnv-4 36.06µ 35.78µ -0.76% 0.041
Full benchstat output
goos: linux
goarch: amd64
pkg: github.com/flanksource/config-db/bench
cpu: INTEL(R) XEON(R) PLATINUM 8573C
                                         │ bench-base.txt │           bench-head.txt           │
                                         │     sec/op     │    sec/op     vs base              │
LocationFilter/smallEnv-4                    16.14µ ± 14%   16.10µ ± 15%       ~ (p=0.394 n=6)
LocationFilter/largeEnv-4                    36.06µ ±  2%   35.78µ ±  2%  -0.76% (p=0.041 n=6)
RunTemplateBool/smallEnv-4                   8.039µ ±  1%   8.015µ ±  1%       ~ (p=0.240 n=6)
RunTemplateBool/largeEnv-4                   15.42µ ±  1%   15.47µ ±  2%       ~ (p=0.240 n=6)
BenchSaveResultsSeed/N=1000-4                 2.507 ±  7%    2.481 ±  9%       ~ (p=0.240 n=6)
BenchSaveResultsUpdateUnchanged/N=1000-4      2.499 ± 43%    2.624 ± 28%       ~ (p=0.485 n=6)
BenchSaveResultsUpdateChanged/N=1000-4        5.531 ± 12%    6.055 ± 10%       ~ (p=0.065 n=6)
geomean                                      3.058m         3.110m        +1.72%

                                         │ bench-base.txt │            bench-head.txt            │
                                         │      B/op      │     B/op      vs base                │
LocationFilter/smallEnv-4                    14.97Ki ± 0%   14.97Ki ± 0%       ~ (p=1.000 n=6) ¹
LocationFilter/largeEnv-4                    20.38Ki ± 0%   20.38Ki ± 0%       ~ (p=1.000 n=6) ¹
RunTemplateBool/smallEnv-4                   8.360Ki ± 0%   8.360Ki ± 0%       ~ (p=1.000 n=6) ¹
RunTemplateBool/largeEnv-4                   10.16Ki ± 0%   10.16Ki ± 0%       ~ (p=1.000 n=6) ¹
BenchSaveResultsSeed/N=1000-4                1.295Gi ± 0%   1.295Gi ± 0%       ~ (p=0.394 n=6)
BenchSaveResultsUpdateUnchanged/N=1000-4     32.03Mi ± 0%   32.01Mi ± 0%       ~ (p=0.394 n=6)
BenchSaveResultsUpdateChanged/N=1000-4       795.9Mi ± 1%   796.6Mi ± 1%       ~ (p=0.180 n=6)
geomean                                      991.3Ki        991.3Ki       +0.01%
¹ all samples are equal

                                         │ bench-base.txt │            bench-head.txt            │
                                         │   allocs/op    │  allocs/op    vs base                │
LocationFilter/smallEnv-4                     278.0 ±  0%    278.0 ±  0%       ~ (p=1.000 n=6) ¹
LocationFilter/largeEnv-4                     522.0 ±  0%    522.0 ±  0%       ~ (p=1.000 n=6) ¹
RunTemplateBool/smallEnv-4                    216.0 ±  0%    216.0 ±  0%       ~ (p=1.000 n=6) ¹
RunTemplateBool/largeEnv-4                    297.0 ±  0%    297.0 ±  0%       ~ (p=1.000 n=6) ¹
BenchSaveResultsSeed/N=1000-4                741.7k ±  0%   741.7k ±  0%       ~ (p=1.000 n=6)
BenchSaveResultsUpdateUnchanged/N=1000-4     405.9k ±  0%   405.9k ±  0%       ~ (p=1.000 n=6)
BenchSaveResultsUpdateChanged/N=1000-4       992.0k ± 12%   992.1k ± 12%       ~ (p=0.180 n=6)
geomean                                      8.329k         8.329k        +0.00%
¹ all samples are equal

                                         │ bench-base.txt │           bench-head.txt           │
                                         │      MB/s      │    MB/s     vs base                │
BenchSaveResultsSeed/N=1000-4                0.000 ± 0%     0.000 ± 0%       ~ (p=1.000 n=6) ¹
BenchSaveResultsUpdateUnchanged/N=1000-4     0.000 ± 0%     0.000 ± 0%       ~ (p=1.000 n=6) ¹
BenchSaveResultsUpdateChanged/N=1000-4       0.000 ± 0%     0.000 ± 0%       ~ (p=1.000 n=6) ¹
geomean                                                 ²               +0.00%               ²
¹ all samples are equal
² summaries must be >0 to compute geomean

@coderabbitai

coderabbitai Bot commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 590aa4db-9619-4b68-b571-a6810eae46a7

📥 Commits

Reviewing files that changed from the base of the PR and between 8ae3e40 and 02b4560.

📒 Files selected for processing (4)
  • api/cache.go
  • api/cache_test.go
  • db/update.go
  • db/update_locations_test.go

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.


Walkthrough

TempCache.Delete now invalidates stale config items and aliases. Database updates skip locations for missing config items, preserve transactions, remove stale cache entries, and record bounded warnings.

Changes

Stale Config Location Handling

Layer / File(s) Summary
Temporary cache deletion
api/cache.go, api/cache_test.go
TempCache.Delete removes cached config items, records missing IDs, removes matching aliases, and is covered by a deletion test.
Missing config location handling
db/update.go, db/update_locations_test.go
saveConfigLocations filters missing config items and returns skipped locations. saveResults removes stale cache entries and records bounded warnings. Tests verify skipped locations, transaction preservation, and warning behavior.

Sequence Diagram(s)

sequenceDiagram
  participant saveResults
  participant saveConfigLocations
  participant Database
  participant TempCache

  saveResults->>saveConfigLocations: save result locations
  saveConfigLocations->>Database: check config item IDs
  Database-->>saveConfigLocations: return existing IDs
  saveConfigLocations-->>saveResults: return skipped locations
  saveResults->>TempCache: delete stale config IDs
  saveResults->>saveResults: record bounded warning
Loading

Suggested reviewers: adityathebe

Merge Risk: ⚪ Minimal · up to 02b45

The PR updates handling for invalid config-location cache entries and adds related test changes; no actionable merge-blocking risk remains in the supplied evidence.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 3 functions across 4 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main change: handling invalid cache entries when saving config locations.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix-config-fk
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch fix-config-fk

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.

@github-actions

Copy link
Copy Markdown

Gavel results

Gavel exited with code 1.

View full results

@yashmehrotra
yashmehrotra merged commit 1258d17 into main Aug 25, 2026
17 of 18 checks passed
@yashmehrotra
yashmehrotra deleted the fix-config-fk branch August 25, 2026 11:18
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