Skip to content

Add property-based filtering capabilities and skipCount functionality to injection rules.#3903

Merged
hickeng merged 5 commits intovmware:mainfrom
hickeng:topic/fault-injection-filters
Dec 3, 2025
Merged

Add property-based filtering capabilities and skipCount functionality to injection rules.#3903
hickeng merged 5 commits intovmware:mainfrom
hickeng:topic/fault-injection-filters

Conversation

@hickeng
Copy link
Copy Markdown
Contributor

@hickeng hickeng commented Nov 16, 2025

Summary

Adds two enhancements to the fault injection rules:

  1. Property Filter Support - inclusion and exclusion callback filters, with
    convenience functions for expressing AND or OR matches using property.Match syntax
  2. Skip Count Functionality - skip the first N matches before injecting faults

Details

  • Property filters are evaluated after ObjectName matching but before probability checks
  • Skip count works in the same way as maxCount, and is reset together with it
  • Skip and max counts are incremented only if the rule makes it through the filters

Eg.

rule := &FaultInjectionRule{
    MethodName: "PowerOnVM_Task",
    InclusionPropertyFilter: FaultFilterAll(
        "config.name == DC0*",
        "runtime.powerState == poweredOff"
    ),
    ExclusionPropertyFilter: FaultFilterAny("config.name == *-test"),
    SkipCount: 2, // Skip first 2 matches
    MaxCount: 3,  // Then inject 3 times
    Probability: 1.0,
    Enabled: true,

Testing

Added passing unit tests for all new functionality

Signed-off-by: George Hicken <george.hicken@broadcom.com>
@hickeng hickeng requested review from akutz and dougm November 16, 2025 20:45
@hickeng hickeng force-pushed the topic/fault-injection-filters branch 2 times, most recently from a955eaa to 24c77ff Compare November 18, 2025 05:03
This allows us a lot more flexibility in filtering and,
with the convenience functions, almost as concise
an expression using strings.

Using property.Match makes us consistent with other
areas of the code.

Signed-off-by: George Hicken <george.hicken@broadcom.com>
@hickeng hickeng force-pushed the topic/fault-injection-filters branch from 24c77ff to a3236e0 Compare November 18, 2025 13:31
@hickeng hickeng requested a review from dougm November 18, 2025 13:37
dougm
dougm previously approved these changes Nov 18, 2025
Copy link
Copy Markdown
Member

@dougm dougm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I might have more feedback but don't want to block, I can follow up with that if I get a chance to try this out.

Update the fault injection tests to use the filter function pattern.
Require camelCase paths to be consistent with other propertyPath uses.

Signed-off-by: George Hicken <george.hicken@broadcom.com>
Signed-off-by: George Hicken <george.hicken@broadcom.com>
@hickeng hickeng force-pushed the topic/fault-injection-filters branch from 38a18ca to ffd2627 Compare December 2, 2025 02:37
dougm
dougm previously approved these changes Dec 2, 2025
Copy link
Copy Markdown
Member

@dougm dougm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@hickeng hickeng requested a review from dougm December 2, 2025 02:53
Given we're passing in the moref we don't
need to extract the name until we get to checking
it.

Signed-off-by: George Hicken <george.hicken@broadcom.com>
@hickeng hickeng merged commit 0aec2ab into vmware:main Dec 3, 2025
11 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