Skip to content

EvictionController: Fix potential panic on header access#284

Merged
fwiesel merged 1 commit intomainfrom
fix/eviction-header-access-panic
Apr 9, 2026
Merged

EvictionController: Fix potential panic on header access#284
fwiesel merged 1 commit intomainfrom
fix/eviction-header-access-panic

Conversation

@notandy
Copy link
Copy Markdown
Contributor

@notandy notandy commented Apr 8, 2026

Use Header.Get() instead of direct array indexing to safely access
X-Openstack-Request-Id header. This prevents panic if the header
is missing or empty.

Summary by CodeRabbit

  • Bug Fixes
    • Improved robustness of migration logging to safely handle missing OpenStack request identifiers, preventing potential issues when headers are unavailable.

Use Header.Get() instead of direct array indexing to safely access
X-Openstack-Request-Id header. This prevents panic if the header
is missing or empty.
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 8, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 919275ed-27f4-4154-a1a1-156bcad2dacc

📥 Commits

Reviewing files that changed from the base of the PR and between 499dcef and 71fa071.

📒 Files selected for processing (1)
  • internal/controller/eviction_controller.go

📝 Walkthrough

Walkthrough

Updated header retrieval in eviction controller logging by replacing direct slice indexing with the header accessor method .Get(). This change affects how missing X-Openstack-Request-Id headers are handled during live and cold migration logging operations.

Changes

Cohort / File(s) Summary
Header Accessor Refactoring
internal/controller/eviction_controller.go
Changed X-Openstack-Request-Id header retrieval from unsafe slice indexing to safe .Get() accessor method for live and cold migration logging, improving nil-safety handling.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~5 minutes

Poem

🐰 A header sought with safer paws,
No index bounds to break the laws,
The .Get() way, so clean and bright,
Makes missing headers safe tonight! ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: fixing a potential panic from unsafe header access in the EvictionController by replacing direct slice indexing with Header.Get().
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/eviction-header-access-panic

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 and usage tips.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 8, 2026

Merging this branch will not change overall coverage

Impacted Packages Coverage Δ 🤖
github.com/cobaltcore-dev/openstack-hypervisor-operator/internal/controller 63.27% (ø)

Coverage by file

Changed files (no unit tests)

Changed File Coverage Δ Total Covered Missed 🤖
github.com/cobaltcore-dev/openstack-hypervisor-operator/internal/controller/eviction_controller.go 30.56% (ø) 144 44 100

Please note that the "Total", "Covered", and "Missed" counts above refer to code statements instead of lines of code. The value in brackets refers to the test coverage of that file in the old version of the code.

@fwiesel fwiesel merged commit 25b9646 into main Apr 9, 2026
7 checks passed
@fwiesel fwiesel deleted the fix/eviction-header-access-panic branch April 9, 2026 07:20
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.

3 participants