Ejemplo n.º 1
0
 public bool ShouldStartChaos(GenericChaosResource chaos, V1Pod pod)
 {
     if (chaos.Spec.GetTestInstance() != pod.TestInstance())
     {
         return(false);
     }
     return(chaos.IsPaused());
 }
Ejemplo n.º 2
0
        public bool ShouldStartChaos(GenericChaosResource chaos, V1Pod pod)
        {
            if (chaos.Spec.Selector.LabelSelectors?.TestInstance != pod.TestInstance())
            {
                return(false);
            }

            return(chaos.IsPaused());
        }
Ejemplo n.º 3
0
        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);
        }