in shardingsphere-operator/pkg/controllers/chaos_controller.go [150:189]
func (r *ChaosReconciler) updateChaosCondition(ctx context.Context, chaos *v1alpha1.Chaos) error {
namespacedName := types.NamespacedName{
Namespace: chaos.Namespace,
Name: chaos.Name,
}
if chaos.Spec.EmbedChaos.PodChaos != nil {
switch chaos.Spec.EmbedChaos.PodChaos.Action {
case v1alpha1.CPUStress:
fallthrough
case v1alpha1.MemoryStress:
sc, err := r.Chaos.GetStressChaosByNamespacedName(ctx, namespacedName)
if err != nil {
return err
}
chaos.Status.ChaosCondition = chaosmesh.ConvertChaosStatus(ctx, chaos, sc)
case v1alpha1.PodFailure:
fallthrough
case v1alpha1.PodKill:
fallthrough
case v1alpha1.ContainerKill:
pc, err := r.Chaos.GetPodChaosByNamespacedName(ctx, namespacedName)
if err != nil {
return err
}
chaos.Status.ChaosCondition = chaosmesh.ConvertChaosStatus(ctx, chaos, pc)
}
}
if chaos.Spec.EmbedChaos.NetworkChaos != nil {
nc, err := r.Chaos.GetNetworkChaosByNamespacedName(ctx, namespacedName)
if err != nil {
return err
}
chaos.Status.ChaosCondition = chaosmesh.ConvertChaosStatus(ctx, chaos, nc)
}
return nil
}