DataDog / datadog-operator

Kubernetes Operator for Datadog Resources
Apache License 2.0
303 stars 105 forks source link

[CECO-2][DatadogMonitor] Configure force sync period #1404

Closed tbavelier closed 1 month ago

tbavelier commented 2 months ago

What does this PR do?

Motivation

Describe your test plan

  1. Deploy this version of the operator with the env var DD_MONITOR_FORCE_SYNC_PERIOD set to 5
  2. Deploy an example monitor, e.g. kubectl apply -f examples/datadogmonitor/metric-monitor-imagepullbackoff.yaml
  3. After a minute or so, in the Datadog UI, edit the monitor query, e.g. changing the threshold to 2 and the 10 minutes to 5 minutes instead (creating a drift from the DatadogMonitor)
  4. Ensure the monitor is reverted back to the DatadogMonitor query within 5 minutes at most from your modification : you can identify this by looking at the monitor audit trail in the UI or in kubernetes by reviewing the Monitor Last Force Sync Time in the DatadogMonitor (within Status) or the associated events image
  5. Modify DD_MONITOR_FORCE_SYNC_PERIOD to a non integer value, e.g. "0,5" and assess the presence of the operator log complaining the value is invalid:
    {"level":"ERROR","ts":"2024-09-11T12:44:03.864Z","logger":"controllers.DatadogMonitor","msg":"Invalid value for monitor force sync period. Defaulting to 60 minutes.","datadogmonitor":{"name":"pods-imagepullbackoff","namespace":"system"},"error":"strconv.Atoi: parsing \"0,5\": invalid syntax"}

Checklist

codecov-commenter commented 2 months ago

Codecov Report

Attention: Patch coverage is 54.54545% with 5 lines in your changes missing coverage. Please review.

Project coverage is 49.01%. Comparing base (7fe7979) to head (6a54ec4).

Files with missing lines Patch % Lines
internal/controller/datadogmonitor/controller.go 54.54% 4 Missing and 1 partial :warning:
Additional details and impacted files [![Impacted file tree graph](https://app.codecov.io/gh/DataDog/datadog-operator/pull/1404/graphs/tree.svg?width=650&height=150&src=pr&token=b1U0O5wQwj&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=DataDog)](https://app.codecov.io/gh/DataDog/datadog-operator/pull/1404?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=DataDog) ```diff @@ Coverage Diff @@ ## main #1404 +/- ## ========================================== - Coverage 49.01% 49.01% -0.01% ========================================== Files 223 223 Lines 19501 19508 +7 ========================================== + Hits 9559 9562 +3 - Misses 9453 9456 +3 - Partials 489 490 +1 ``` | [Flag](https://app.codecov.io/gh/DataDog/datadog-operator/pull/1404/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=DataDog) | Coverage Δ | | |---|---|---| | [unittests](https://app.codecov.io/gh/DataDog/datadog-operator/pull/1404/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=DataDog) | `49.01% <54.54%> (-0.01%)` | :arrow_down: | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=DataDog#carryforward-flags-in-the-pull-request-comment) to find out more. | [Files with missing lines](https://app.codecov.io/gh/DataDog/datadog-operator/pull/1404?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=DataDog) | Coverage Δ | | |---|---|---| | [internal/controller/datadogmonitor/controller.go](https://app.codecov.io/gh/DataDog/datadog-operator/pull/1404?src=pr&el=tree&filepath=internal%2Fcontroller%2Fdatadogmonitor%2Fcontroller.go&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=DataDog#diff-aW50ZXJuYWwvY29udHJvbGxlci9kYXRhZG9nbW9uaXRvci9jb250cm9sbGVyLmdv) | `48.04% <54.54%> (-0.15%)` | :arrow_down: | ------ [Continue to review full report in Codecov by Sentry](https://app.codecov.io/gh/DataDog/datadog-operator/pull/1404?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=DataDog). > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=DataDog) > `Δ = absolute (impact)`, `ø = not affected`, `? = missing data` > Powered by [Codecov](https://app.codecov.io/gh/DataDog/datadog-operator/pull/1404?dropdown=coverage&src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=DataDog). Last update [7fe7979...6a54ec4](https://app.codecov.io/gh/DataDog/datadog-operator/pull/1404?dropdown=coverage&src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=DataDog). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=DataDog).
tbavelier commented 1 month ago

/merge

dd-devflow[bot] commented 1 month ago

:steam_locomotive: MergeQueue: pull request added to the queue

The median merge time in main is 14m.

Use /merge -c to cancel this operation!

dd-devflow[bot] commented 1 month ago

:rotating_light: MergeQueue: This merge request is in error

Gitlab pipeline didn't start on its own and we were unable to create it... Please retry.

If you need support, contact us on Slack #devflow with those details!

tbavelier commented 1 month ago

/merge

dd-devflow[bot] commented 1 month ago

:steam_locomotive: MergeQueue: pull request added to the queue

The median merge time in main is 14m.

Use /merge -c to cancel this operation!

dd-devflow[bot] commented 1 month ago

:rotating_light: MergeQueue: This merge request is in error

Gitlab pipeline didn't start on its own and we were unable to create it... Please retry.

If you need support, contact us on Slack #devflow with those details!