Skip to content

Conversation

@XploY04
Copy link

@XploY04 XploY04 commented Nov 11, 2025

What this PR does / why we need it:

This PR implements the prerequisite changes in chaos-operator to support label intersection mode for precise pod targeting in chaos experiments. This is required for the litmus-go PR #777 which adds the actual intersection logic for pod selection.

Changes Made:

  • Added LabelMatchMode field to ApplicationParams struct (for appinfo-based targeting)
  • Added LabelMatchMode field to Workload struct (for workload-based targeting)
  • Updated getTargets() function to append the label match mode (union/intersection) as a 4th parameter to the TARGETS environment variable
  • Regenerated CRDs with controller-gen v0.16.5 to include the new labelMatchMode field in the OpenAPI schema
  • Upgraded controller-tools from v0.9.0 to v0.16.5 for Go 1.25.1 compatibility
  • Added modern Kubebuilder v3+ config structure (config/crd/bases/)

TARGETS Environment Variable Format:

TARGETS="kind:namespace:[labels]:labelMatchMode"
  • labelMatchMode defaults to union (OR logic - matches ANY label)
  • Can be set to intersection (AND logic - matches ALL labels)
  • Fully backward compatible (defaults to union if not specified)

Example:

# For AppInfo targeting
spec:
  appinfo:
    appns: "default"
    applabel: "app=web,tier=frontend"
    appkind: "deployment"
    labelMatchMode: "intersection"  # Gets pods with app=web AND tier=frontend

# For Workloads targeting
spec:
  selectors:
    workloads:
      - kind: "deployment"
        namespace: "default"
        labels: "role=primary,cluster=prod"
        labelMatchMode: "intersection"  # Gets pods with role=primary AND cluster=prod

Which issue this PR fixes: fixes litmuschaos/litmus-go#774

Special notes for your reviewer:

  • This PR is a prerequisite for litmus-go PR #777
  • The chaos-runner in litmus-go will parse the 4th parameter from TARGETS env variable
  • New CRDs are generated in config/crd/bases/ (modern Kubebuilder structure) while keeping deploy/crds/ for backward compatibility
  • No breaking changes - all existing ChaosEngines will continue to work with default union behavior

Checklist:

  • Fixes Experiments for CloudNativePG project litmus-go#774
  • Labelled this PR & related issue with documentation tag
  • PR messages has document related information
  • Labelled this PR & related issue with breaking-changes tag - Not applicable (backward compatible)
  • PR messages has breaking changes related information - Not applicable
  • Labelled this PR & related issue with requires-upgrade tag - Not applicable (optional field with default)
  • PR messages has upgrade related information - Not applicable
  • Commit has unit tests - Covered in litmus-go PR #777
  • Commit has integration tests - Will be covered in E2E tests

Related PRs:

@XploY04 XploY04 marked this pull request as draft November 11, 2025 17:51
…pport

- Generated by controller-gen v0.16.5
- Includes CRDs with labelMatchMode field in OpenAPI schema
- Follows Kubebuilder v3+ project layout

Signed-off-by: XploY04 <[email protected]>
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.

Experiments for CloudNativePG project

1 participant