Skip to content

Feature/taint improvements - #309

Merged
davidB merged 11 commits into
davidB:masterfrom
lwabish:feature/taint-filtering-improvements
Feb 2, 2026
Merged

davidB merged 11 commits into
davidB:masterfrom
lwabish:feature/taint-filtering-improvements

Conversation

@lwabish

@lwabish lwabish commented Dec 12, 2025

Copy link
Copy Markdown
Contributor

This PR adds a new --ignore-taints parameter with improved default behavior that shows only untainted nodes, making the tool more user-friendly for resource monitoring.

Current Behavior Issues:

  • Default behavior shows all nodes including control-plane, which is often not what users want
  • Users can't easily filter out specific taints while keeping others
  • Existing filtering options are limited for practical resource monitoring use cases

Key Improvement:

  • Default behavior changed: Now shows only untainted nodes (workload nodes) instead of all nodes
  • This focuses the view on usable compute resources by default

New Functionality:

  • kubectl-view-allocations - Default: Show only untainted nodes (workload nodes) ⭐ NEW
  • kubectl-view-allocations --ignore-taints - Show all nodes (ignore all taints)
  • kubectl-view-allocations --ignore-taints taint1,taint2 - Show untainted nodes + nodes with specific ignored taints

Use Cases:

  • Monitor only workload nodes by default (most common scenario) ⭐ NEW
  • Include control-plane nodes when needed for cluster overview
  • Include specialized nodes (database, gpu) while maintaining readability
  • Better resource allocation visibility with flexible filtering

Benefits:

  • More intuitive default behavior focused on compute resources
  • Flexible taint filtering without semantic conflicts with --selector
  • Comprehensive unit test coverage ensures reliability
  • Maintains backward compatibility with existing functionality

The implementation includes comprehensive unit tests and maintains backward compatibility with existing functionality.

lwabish and others added 7 commits December 12, 2025 17:12
- Add --exclude-taints CLI parameter to filter nodes by taints
- Support comma-separated taint patterns
- Add should_exclude_node_by_taint() function for taint matching
- Update collect_from_nodes() to apply taint filtering
- Support 'any' keyword to exclude all nodes with taints
- Update documentation with usage examples

🤖 Generated with [Claude Code](https://claude.ai/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Change --exclude-taints to accept no values for excluding all nodes with any taints
- Remove 'any' special keyword to avoid conflicts with real taint names
- Update CLI argument to use num_args = 0.. for optional values
- Improve help text to clarify new behavior
- Update documentation with new usage examples
- Now supports filtering taints named 'any' without conflicts

🤖 Generated with [Claude Code](https://claude.ai/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
…taints

- Change exclude_taints parameter from Vec<String> to Option<Vec<String>>
- Fix logic to properly distinguish between: unused flag, flag without values, and flag with specific values
- When --exclude-taints is used without values, now correctly excludes all nodes with any taints
- Update should_exclude_node_by_taint() function to handle Option type correctly
- Update collect_from_nodes() function signature to match new parameter type

This resolves the issue where --exclude-taints (without values) was not filtering out nodes with taints.

🤖 Generated with [Claude Code](https://claude.ai/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Add 9 new test cases covering all taint filtering scenarios
- Test parameter states: unused flag, flag without values, flag with specific values
- Test filtering by taint key, key-value pairs, and multiple patterns
- Include real-world examples: control-plane taints, dedicated database nodes
- Cover edge cases: key-only taints, empty keys, taints named 'any'
- Add test helper functions for creating test nodes and taints
- All 16 tests pass successfully with full coverage

Test scenarios:
- should_exclude_node_by_taint_no_flag
- should_exclude_node_by_taint_flag_without_values
- should_exclude_node_by_taint_specific_key
- should_exclude_node_by_taint_key_value_pair
- should_exclude_node_by_taint_multiple_patterns
- should_exclude_node_by_taint_real_world_examples
- should_exclude_node_by_taint_edge_cases
- should_exclude_node_by_taint_any_taint_name

🤖 Generated with [Claude Code](https://claude.ai/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Replace --exclude-taints with --include-taints parameter
- Change default behavior to only show nodes without taints
- Update function name from should_exclude_node_by_taint to should_include_node_by_taint
- Modify filtering logic to include nodes matching specified taint patterns
- When --include-taints is not specified, only untainted nodes are displayed
- Update all 9 test cases to reflect new behavior and expectations
- Add test cases to verify default behavior (only untainted nodes)
- Support multiple taint patterns with comma-separated list

Behavior changes:
- Default: Show only untainted nodes
- --include-taints key: Show nodes with specific taint key
- --include-taints key=value: Show nodes with specific taint key-value pair
- --include-taints pattern1,pattern2: Show nodes matching any pattern

This makes the tool more user-friendly by defaulting to showing only usable nodes.

🤖 Generated with [Claude Code](https://claude.ai/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
…emantics

- Rename parameter from --include-taints to --ignore-taints for clearer semantics
- Update logic to include nodes without taints + nodes with ignored taints (exclude others)
- Fix three-state behavior:
  * No flag: only show nodes without taints
  * --ignore-taints (no values): show all nodes (ignore all taints)
  * --ignore-taints taint1,taint2: show untainted nodes + nodes with specified taints
- Update function signature and all 9 test cases to match new behavior
- This resolves semantic conflict with --selector and provides more intuitive filtering

Behavior changes:
- Default: Only untainted nodes (workload nodes)
- --ignore-taints: All nodes (including control-plane)
- --ignore-taints pattern: Untainted + nodes with ignored taints

Examples:
- kubectl-view-allocations # Show only workload nodes
- kubectl-view-allocations --ignore-taints # Show all nodes
- kubectl-view-allocations --ignore-taints node-role.kubernetes.io/control-plane # Show workload + control-plane nodes

🤖 Generated with [Claude Code](https://claude.ai/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
…avior

- Replace all --exclude-taints examples with --ignore-taints
- Update examples to show three-state behavior (no flag/no values/with values)
- Add common use cases section with practical examples
- Clarify that default behavior shows only workload nodes (no taints)
- Explain semantic differences from --selector parameter
- Include real-world scenarios like workload + control-plane combinations

Documentation now matches the implemented behavior:
- Default: Show only untainted nodes (workload nodes)
- --ignore-taints: Show all nodes
- --ignore-taints taint1,taint2: Show untainted + nodes with ignored taints

🤖 Generated with [Claude Code](https://claude.ai/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@davidB

davidB commented Dec 16, 2025

Copy link
Copy Markdown
Owner

Good idea, thanks for the PR.

Can you also update the README?

@lwabish

lwabish commented Dec 25, 2025

Copy link
Copy Markdown
Contributor Author

Good idea, thanks for the PR.

Can you also update the README?

Sure I will. I've been using this modified version locally to see if there is any bug. I will check the ci and undraft this pr later when I am ready. Thanks!

@lwabish
lwabish marked this pull request as ready for review January 30, 2026 10:04
@lwabish

lwabish commented Jan 30, 2026

Copy link
Copy Markdown
Contributor Author

@davidB Hi, readme updated, PTAL, thanks

@davidB
davidB merged commit 2699d19 into davidB:master Feb 2, 2026
3 checks passed
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