fix: implement rollback support for Node Outage Scenario (#916)#1210
fix: implement rollback support for Node Outage Scenario (#916)#1210NETIZEN-11 wants to merge 1 commit intokrkn-chaos:mainfrom
Conversation
) - Add @set_rollback_context_decorator to run() to integrate with the rollback framework - Add REVERSIBLE_ACTIONS map: node_stop_scenario->node_start_scenario, stop_kubelet_scenario->restart_kubelet_scenario - Add _register_rollback() to encode node/action metadata and register rollback callable before each reversible action executes - Add rollback_node_action() static method with all imports local (required by version_template.j2 serializer) - Remove unused imports: log_exception, krkn.utils - Fix dead else-branch in cloud-type dispatch inside rollback callable - Switch to percent-style logging to match project conventions Irreversible actions (no rollback registered): node_termination_scenario, node_crash_scenario, node_reboot_scenario, node_disk_detach_attach_scenario, node_stop_start_scenario Closes krkn-chaos#916 Signed-off-by: Nitesh <nitesh@example.com>
Review Summary by QodoImplement rollback support for node outage scenarios
WalkthroughsDescription• Implement rollback support for node outage scenarios using decorator pattern • Add REVERSIBLE_ACTIONS map for node_stop and kubelet_stop with inverse actions • Register rollback callables before executing reversible actions for safe recovery • Encode node metadata as base64 JSON for self-contained rollback serialization • Switch to percent-style logging and remove unused imports for consistency Diagramflowchart LR
A["Node Action Execution"] -->|@set_rollback_context_decorator| B["Rollback Framework"]
A -->|reversible action| C["_register_rollback"]
C -->|encode metadata| D["base64 JSON payload"]
D -->|set_rollback_callable| E["rollback_node_action"]
E -->|decode payload| F["Reconstruct cloud provider"]
F -->|execute inverse action| G["Cluster Restored"]
File Changes1. krkn/scenario_plugins/node_actions/node_actions_scenario_plugin.py
|
Code Review by Qodo
1. RollbackHandler uses placeholder scenario_type
|
Type of change
Description
Implements rollback support for node outage scenarios to ensure the cluster is restored to its original state when a failure occurs during execution.
This integrates the node actions scenario with the existing rollback framework and ensures safe recovery from partial failures.
Changes
Add
@set_rollback_context_decoratortorun()to integrate with the rollback frameworkAdd
REVERSIBLE_ACTIONSmap:node_stop_scenario→node_start_scenariostop_kubelet_scenario→restart_kubelet_scenarioAdd
_register_rollback()to encode node/action metadata and register rollback callable before each reversible action executesAdd
rollback_node_action()static method with local imports (required by serializer)Remove unused imports:
log_exception,krkn.utilsFix dead
elsebranch in cloud-type dispatch inside rollback callableSwitch to percent-style logging to match project conventions
Irreversible actions (no rollback registered)
node_termination_scenarionode_crash_scenarionode_reboot_scenarionode_disk_detach_attach_scenarionode_stop_start_scenarioRelated Tickets & Documents
Documentation
Related Documentation PR (if applicable)
N/A
Checklist before requesting a review
Test Execution
Sample Output
INFO Starting Kraken run INFO Executing node_stop_scenario on node worker-1 ERROR Scenario failed due to exception INFO Triggering rollback for node actions INFO Executing rollback: node_start_scenario on node worker-1 INFO Rollback completed successfully INFO Kraken run completed