public bool ShouldStartChaos(GenericChaosResource chaos, V1Pod pod) { if (chaos.Spec.GetTestInstance() != pod.TestInstance()) { return(false); } return(chaos.IsPaused()); }
public bool ShouldStartChaos(GenericChaosResource chaos, V1Pod pod) { if (chaos.Spec.Selector.LabelSelectors?.TestInstance != pod.TestInstance()) { return(false); } return(chaos.IsPaused()); }
public bool ShouldStartPodChaos(WatchEventType type, V1Pod pod) { if (!string.IsNullOrEmpty(Namespace) && Namespace != pod.Namespace()) { return(false); } if ((type != WatchEventType.Added && type != WatchEventType.Modified) || pod.Status.Phase != "Running") { return(false); } var autoStart = ""; pod.Metadata.Annotations?.TryGetValue("stress/chaos.autoStart", out autoStart); if (autoStart == "false") { return(false); } if (!pod.Metadata.Labels.TryGetValue("chaos", out var chaos) || chaos != "true") { return(false); } if (String.IsNullOrEmpty(pod.TestInstance())) { Logger.Information($"Pod has 'chaos' label but missing or empty {GenericChaosResource.TestInstanceLabelKey} label."); return(false); } var started = ""; pod.Metadata.Annotations?.TryGetValue("stress/chaos.started", out started); if (started == "true") { Logger.Information($"Pod is in chaos.started state."); return(false); } return(true); }