public async Task StartChaosResources(V1Pod pod) { var chaos = await ChaosClient.ListNamespacedAsync(pod.Namespace()); var tasks = chaos.Items .Where(cr => ShouldStartChaos(cr, pod)) .Select(async cr => { string plural = ""; foreach (string pluralName in Enum.GetNames(typeof(GenericChaosClient.ChaosResourcePlurals))) { if (pluralName.Contains(cr.Kind.ToLower())) { plural = pluralName; break; } } await Client.PatchNamespacedCustomObjectWithHttpMessagesAsync( PodChaosResumePatchBody, ChaosClient.Group, ChaosClient.Version, pod.Namespace(), plural, cr.Metadata.Name); using (LogContext.PushProperty("chaosResource", $"{cr.Kind}/{cr.Metadata.Name}")) { Logger.Information($"Started chaos for pod."); } }); await Task.WhenAll(tasks); }
public async Task StartChaosResources(V1Pod pod) { var chaos = await ChaosClient.ListNamespacedAsync(pod.Namespace()); var tasks = chaos.Items .Where(cr => ShouldStartChaos(cr, pod)) .Select(async cr => { await Client.PatchNamespacedCustomObjectWithHttpMessagesAsync( PodChaosResumePatchBody, ChaosClient.Group, ChaosClient.Version, pod.Namespace(), cr.Kind.ToLower(), cr.Metadata.Name); using (LogContext.PushProperty("chaosResource", $"{cr.Kind}/{cr.Metadata.Name}")) { Logger.Information($"Started chaos for pod."); } }); await Task.WhenAll(tasks); }