argoproj / argo-rollouts

Progressive Delivery for Kubernetes
https://argo-rollouts.readthedocs.io/
Apache License 2.0
2.7k stars 847 forks source link

AnalysisTemplate support build-in `now` arg #591

Closed ozooxo closed 4 years ago

ozooxo commented 4 years ago

For some monitoring framework, their API may need to pass fixed epoch time to and from to specify the range of the monitoring data (e.g. Datadog timeseries endpoint). It is very hard to use together with the current Argo Rollout, as we need to pass a static string spec.metrics.provider.web.url (checked into the gitOps repo as an YAML file) and it cannot be changed every time when we are in canary step and recheck the canary test status.

While it can be a feature request to supporting monitoring framework to add an endpoint with args like &to=now&last=3600, they may not want to add it (as it breaks the idempotency of a RESTful API endpoint), or they may only release it far in their future version.

To add the flexibility of the Argo Rollout framework, could we add a build-in argument now (potentially with the epoch time as the return value), and/or an eval used to calculate e.g. from = now - 3600?


Alternatively, as a workaround, not sure if I can do it by project language (Go?) injection inside of the url string. E.g. in shell:

curl -X GET https://api.datadoghq.com/api/v1/query?from="$(expr $(date +%s) - 3600)"&to="$(date +%s)"...

But if I can, that sounds very dangerous, as the logic is very similar to SQL injection.

jessesuen commented 4 years ago

I think we can dup this to https://github.com/argoproj/argo-rollouts/issues/405, where we want to introduce time variables