You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Implements consistent hashing for selecting subsets of IPs
based on percentage configuration in network disruptions.
Enables deterministic IP selection across chaos pods.
- Add SelectIPsByPercentage with SHA256-based hashing
- Ensure consistent selection using seed parameter
- Add comprehensive test coverage for edge cases
- Add example demonstrating DNS resolver control
Jira: CHAOSPLT-259
// parse service with format <name>;<namespace>;<port-value>-<port-name>;<port-value>-<port-name>...
706
+
// parse service with format <name>;<namespace>;<port-value>-<port-name>;<port-value>-<port-name>...;<percentage>
677
707
parsedService:=strings.Split(service, ";")
678
708
iflen(parsedService) <2 {
679
-
returnnil, fmt.Errorf("service format is expected to follow '<name>;<namespace>;<port-value>-<port-name>;<port-value>-<port-name>', unexpected format detected: %s", service)
709
+
returnnil, fmt.Errorf("service format is expected to follow '<name>;<namespace>;<port-value>-<port-name>;<port-value>-<port-name>;<percentage>', unexpected format detected: %s", service)
680
710
}
681
711
682
712
ports:= []NetworkDisruptionServicePortSpec{}
683
713
684
-
for_, unparsedPort:=rangeparsedService[2:] {
714
+
varpercentage*int
715
+
716
+
portFields:=parsedService[2:]
717
+
718
+
// Check if the last field is a percentage (plain integer without dash)
719
+
iflen(portFields) >0 {
720
+
lastField:=portFields[len(portFields)-1]
721
+
if!strings.Contains(lastField, "-") {
722
+
// This might be a percentage
723
+
ifpct, err:=strconv.Atoi(lastField); err==nil {
724
+
percentage=&pct
725
+
portFields=portFields[:len(portFields)-1] // Remove percentage from port fields
0 commit comments