refactor: consolidate kubernetes_functions (#1120)#1121
refactor: consolidate kubernetes_functions (#1120)#1121AR21SM wants to merge 1 commit intokrkn-chaos:mainfrom
Conversation
Signed-off-by: AR21SM <mahajanashishar21sm@gmail.com>
PR Compliance Guide 🔍Below is a summary of compliance checks for this PR:
Compliance status legend🟢 - Fully Compliant🟡 - Partial Compliant 🔴 - Not Compliant ⚪ - Requires Further Human Verification 🏷️ - Compliance label |
|||||||||||||||||||||||||||||||
PR Code Suggestions ✨Explore these optional code suggestions:
|
||||||||||||||||
|
@AR21SM thanks so much for this PR, we are currently working toward removing the "native" style scenarios in the future in favor of this work: #849 |
Thank you for the context @paigerube14 , makes sense. Happy to help in the future! |
Type of change
Description
Consolidate duplicate
kubernetes_functions.pyfiles by creating a shared module atkrkn/scenario_plugins/native/common/kubernetes_utils.py.Changes:
native/common/kubernetes_utils.pywith 11 shared functionslist_podsusing superset signature(cli, namespace, label_selector=None, exclude_label=None)network/kubernetes_functions.py(285 → 62 lines)pod_network_outage/kubernetes_functions.py(275 → 35 lines)Preserved unique functionality:
setup_kubernetes()- kept separate (different return types per scenario)create_ifb()/delete_ifb()- kept in network module onlyRelated Tickets & Documents
Documentation
No documentation changes needed - internal refactor with no API changes.
PR Type
Enhancement
Description
Consolidate duplicate Kubernetes utility functions into shared module
Reduce code duplication across network and pod_network_outage plugins
Network module reduced from 285 to 62 lines via imports
Pod_network_outage module reduced from 275 to 35 lines via imports
Diagram Walkthrough
File Walkthrough
__init__.py
Create common package for native pluginskrkn/scenario_plugins/native/common/init.py
kubernetes_utils.py
Create shared Kubernetes utility functions modulekrkn/scenario_plugins/native/common/kubernetes_utils.py
exec_cmd_in_pod, list_pods, get_job_status, get_pod_log, read_pod,
delete_job, list_ready_nodes, get_node
kubernetes_functions.py
Refactor network module to use shared utilitieskrkn/scenario_plugins/native/network/kubernetes_functions.py
kubernetes_functions.py
Refactor pod_network_outage module to use shared utilitieskrkn/scenario_plugins/native/pod_network_outage/kubernetes_functions.py