Skip to content

Conversation

Transcendental-Programmer
Copy link

@Transcendental-Programmer Transcendental-Programmer commented May 30, 2025

Description

Earlier I implemented enhanced node selection capabilities in the krkn hogs scenario plugin, but for it to work properly I needed to fix a missing piece in krkn-lib.

The Issue:
The HogConfig class had a node_name field declared (line 126) but the from_yaml_dict() method wasn't parsing the node-name parameter from YAML configs. This forced me to use hacky dict access (scenario_dict.get('node-name')) instead of clean model access in my plugin.

My Fix:
Added the missing node-name parsing at line 182-183:

if "node-name" in yaml_dict.keys() and yaml_dict["node-name"]:
    config.node_name = yaml_dict["node-name"]

Why This Matters:
This enables my enhanced hogs plugin to use proper scenario_config.node_name access instead of bypassing the type system. It unlocks the precise node targeting functionality I built:

  • node-name: "worker-1" for specific nodes
  • Multiple input formats (strings, lists, comma-separated)
  • NODE_NAME environment variable support
  • Clean precedence handling

Without this fix, my enhanced functionality would be stuck with technical debt and unsafe dict access patterns.

complements

krkn-chaos/krkn#832

resolves

krkn-chaos/krkn#830

Documentation

  • Is documentation needed for this update?

If checked, a documentation PR must be created and merged in the website repository.

Related Documentation PR (if applicable)

Documentation will be handled in the main krkn plugin PR

- Add node_name field parsing in from_yaml_dict() method
- Support Union[str, List[str]] type for flexible input formats
- Enable proper model-based access instead of dict bypass
- Maintain backward compatibility with existing configurations
- Integrate seamlessly with enhanced krkn hogs scenario plugin

This change eliminates technical debt and provides type-safe
node targeting capabilities for the krkn chaos engineering platform.

Signed-off-by: Priyansh Saxena <[email protected]>
@paigerube14
Copy link
Contributor

thanks for the PR @Transcendental-Programmer, are you able to add in some tests for this new field in /test_krkn_kubernetes_models.py so that we can add coverage for this configuation option. TIA

@Transcendental-Programmer
Copy link
Author

thanks for the PR @Transcendental-Programmer, are you able to add in some tests for this new field in /test_krkn_kubernetes_models.py so that we can add coverage for this configuation option. TIA

Thanks for the feedback, @paigerube14

I’ll add cases to test_krkn_kubernetes_models.py that check all supported input formats: a single string, a comma-separated string, and a list. I’ll follow the pattern in test_hog_config() to make sure the field is parsed correctly from the YAML and stored properly in the node_name property.

I’ll get this into the PR shortly. Appreciate you flagging it!

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.

2 participants