-
Couldn't load subscription status.
- Fork 135
Open
Description
I have been trying to create a pod-network-partition experiment by following the steps mentioned in https://litmuschaos.github.io/litmus/experiments/categories/pods/pod-network-partition/ and by working on the template present in chaoshub.
There are a couple of issues that I have been facing. I have been going through the codebase and found that:
- The experiment itself creates a NetworkPolicy targeting the pods using POD_SELECTOR and NAMESPACE_SELECTOR environment variables
- But the experiment cannot be run without TARGETS environment variable. Without it, the experiment receives the following error:
time="2025-06-11T07:40:56Z" level=info msg="[PreReq]: Getting the ENV for the pod-network-partition experiment"
panic: runtime error: index out of range [0] with length 0
This is due to
| return app[0].Namespace, app[0].Kind, app[0].Labels[0] |
| experimentDetails.AppNS, experimentDetails.AppKind, experimentDetails.AppLabel = getAppDetails() |
- Even after setting the TARGETS variable as per format:
kind:namespace:labelKey=labelValuethis fails (Note that formatkind:namespace:pod1Name,pod2Namealso fails since this causes the AppDetails.Labels field to be null which throws nil pointer exception in getAppDetails function execution) chaos fails to get injected as it is unable to determine the target pods even if all the correct details are provided. - This is due to the fact that in https://github.com/litmuschaos/litmus-go/blob/07de11eeee8e919b930e738f316a1e490aba3b18/chaoslib/litmus/pod-network-partition/lib/pod-network-partition.go#L57C5-L57C14 , empty string as target pods is being passed into GetPodList (probably due to the fact that in this experiment chaos is not directly injected into the pods but a networkpolicy is created to implement the effect) which eventually results in execution of calling GetTargetPodsWhenTargetPodsENVNotSet function.
litmus-go/pkg/utils/common/pods.go
Line 168 in 07de11e
podList, err := GetTargetPodsWhenTargetPodsENVNotSet(podAffPerc, clients, chaosDetails) - In GetTargetPodsWhenTargetPodsENVNotSet(), if we have set the kind to
pod, the first switch case is executed atand since we have passed only labels for AppDetails and not pod names, we receive errorlitmus-go/pkg/utils/common/pods.go
Line 276 in 07de11e
case "pod": ErrorTypeTargetSelection
I am happy to submit a PR for this fix.
bharadwajrembar and tuda-suda
Metadata
Metadata
Assignees
Labels
No labels