Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DataDog provider should allow dealing with no data points returned #1548

Closed
jessesuen opened this issue Sep 27, 2021 · 5 comments
Closed

DataDog provider should allow dealing with no data points returned #1548

jessesuen opened this issue Sep 27, 2021 · 5 comments
Assignees
Labels
bug Something isn't working

Comments

@jessesuen
Copy link
Member

jessesuen commented Sep 27, 2021

Summary

When there are no data points in a DataDog query, we automatically return error: Datadog returned no value with no ability to change this behavior. However, some users may want to consider this scenario a success. The code which prevents users from deciding how to handle this is here:

if len(res.Series) < 1 || len(res.Series[0].Pointlist) < 1 {
return "", v1alpha1.AnalysisPhaseError, fmt.Errorf("Datadog returned no value: %s", string(bodyBytes))
}
series := res.Series[0]
datapoint := series.Pointlist[len(series.Pointlist)-1]
if len(datapoint) < 1 {
return "", v1alpha1.AnalysisPhaseError, fmt.Errorf("Datadog returned no value: %s", string(bodyBytes))
}

The above logic does not allow a query to return with no datapoints because we error if the array length is 0.

One possible solution, is to modify this code and allow the result to return as nil without marking the measurement as error. Then, users could decide how to deal with this by writing an expression like:

successCondition: result == nil || result <= 0.05

A caveat is that I forget if expr library allows for polymorphic values where result may be a float or nil and compared using built-in operators. But if it doesn't, we could always add a convenience function, IsNil() to allow users to deal with it.

successCondition: IsNil(result) || result <= 0.05

Diagnostics

What version of Argo Rollouts are you running? v1.1.0-rc1


Message from the maintainers:

Impacted by this bug? Give it a 👍. We prioritize the issues with the most 👍.

@jessesuen jessesuen added the bug Something isn't working label Sep 27, 2021
@jessesuen
Copy link
Member Author

@rms1000watt
Copy link
Contributor

@jessesuen Thank you for making this issue. I'll take a look at it.

@jessesuen
Copy link
Member Author

I think to fix this:

  1. Instead of doing this:
return "", v1alpha1.AnalysisPhaseError, fmt.Errorf("Datadog returned no value: %s", string(bodyBytes))

we instead call EvaluateResult the result and give value of nil. e.g.:

evaluate.EvaluateResult(nil, metric, p.logCtx)
  1. If expr does not allow polymorphic comparison using built-in operators (i.e. successCondition: result == nil || result <= 0.05), then we could introduce an isNil() convenience method.

@rms1000watt
Copy link
Contributor

rms1000watt commented Sep 28, 2021

I think the first option is not feasible.

There's 2 cases:
- datadog returned no values, and people want that to error out
- datadog returned no values, and people don't want that to error out, so they add a success/failure condition

If we force evaluate.EvaluateResult(nil, metric, p.logCtx) on every empty result, we'd have effectively broken backwards compatibility since it doesn't error out any more.

I mean, maybe that's OK? But I at least want to talk through that situation.


Yeah, this has to break backwards compatibility for the solution to work one way or another.. still thinking it through. Trying not to change the plumbing in the datadog provider, but rather provide extra hooks for the Developer when writing success/failure conditions.


If I were to follow the first option, it would break. I cannot pass in nil since it's untyped. If I were to assign a type and have a nil pointer, then the success/failure condition would break because of the type mismatch *float64 and float64

I'm adding more logic to preprocess if pointers are provided to the evaluation

rms1000watt added a commit to rms1000watt/argo-rollouts that referenced this issue Sep 28, 2021
rms1000watt added a commit to rms1000watt/argo-rollouts that referenced this issue Sep 28, 2021
rms1000watt added a commit to rms1000watt/argo-rollouts that referenced this issue Sep 28, 2021
rms1000watt added a commit to rms1000watt/argo-rollouts that referenced this issue Sep 28, 2021
rms1000watt added a commit to rms1000watt/argo-rollouts that referenced this issue Sep 29, 2021
rms1000watt added a commit to rms1000watt/argo-rollouts that referenced this issue Sep 29, 2021
rms1000watt added a commit to rms1000watt/argo-rollouts that referenced this issue Sep 29, 2021
rms1000watt added a commit to rms1000watt/argo-rollouts that referenced this issue Sep 29, 2021
rms1000watt added a commit to rms1000watt/argo-rollouts that referenced this issue Sep 29, 2021
@rms1000watt
Copy link
Contributor

@jessesuen Ready for review: #1551 👍 🙏

rms1000watt added a commit to rms1000watt/argo-rollouts that referenced this issue Sep 29, 2021
rms1000watt added a commit to rms1000watt/argo-rollouts that referenced this issue Sep 29, 2021
rms1000watt added a commit to rms1000watt/argo-rollouts that referenced this issue Sep 29, 2021
rms1000watt added a commit to rms1000watt/argo-rollouts that referenced this issue Oct 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants