[Backport 2025.1] fix(nemesis): prevent UnboundLocalError when exception raised before DisruptionEvent context#13689
Draft
scylladbbot wants to merge 1 commit intoscylladb:branch-2025.1from
Draft
Conversation
Fixed UnboundLocalError that occurred when KillNemesis exception was raised before entering the DisruptionEvent context manager. The error happened because nemesis_event variable was only defined inside the 'with' block, but was accessed unconditionally in the finally block. Changes: - Initialize nemesis_event to None at start of wrapper function - Add None check in finally block before accessing nemesis_event Co-authored-by: fruch <340979+fruch@users.noreply.github.com> (cherry picked from commit a3c67c0)
Author
|
@copilot - This PR has conflicts, therefore it was moved to |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
nemesis_eventwas accessed in finally block but only defined withinwith DisruptionEvent()context manager. WhenKillNemesisraised duringcheck_cluster_health()before entering the with block, variable was undefined → UnboundLocalError.Before:
After:
Changes:
sdcm/nemesis.py:6273: Initializenemesis_event = Nonesdcm/nemesis.py:6431-6432: Guard assignment with None checkTesting
PR pre-checks (self review)
backportlabelsReminders
sdcm/sct_config.py)unit-test/folder)Fixes: SCT-92
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.
Parent PR: #13628