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

Add validations to DatadogMonitorSpec #1694

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

shuheiktgw
Copy link
Collaborator

@shuheiktgw shuheiktgw commented Feb 14, 2025

What does this PR do?

This is the next iteration of this PR. I realized that we don’t actually need fancy CEL validations for most basic validations. So I updated the PR to use the simple CRD validations.

Motivation

Currently, the Datadog Operator does not implement validating webhooks and validates inputs during reconciliation. I assume this is to simplify the operator setup, but from a user experience perspective, it’s not ideal since users can only discover issues after applying their manifests.

Additional Notes

Minimum Agent Versions

N/A

Describe your test plan

I've tested it locally using a Kind cluster with Kubernetes 1.32.

$ cat monitor.yaml
apiVersion: datadoghq.com/v1alpha1
kind: DatadogMonitor
metadata:
  name: datadog-monitor-test
spec:
  # query: ""
  type: "some alert"
  name: ""
  # message: "We are running out of disk space!"
  tags:
    - "test:datadog"

$ k apply -f monitor.yaml
The DatadogMonitor "datadog-monitor-test" is invalid:
* spec.name: Invalid value: "": spec.name in body should be at least 1 chars long
* spec.type: Unsupported value: "some alert": supported values: "metric alert", "query alert", "service check", "event alert", "log alert", "process alert", "rum alert", "trace-analytics alert", "slo alert", "event-v2 alert", "audit alert", "composite"
* spec.message: Required value
* spec.query: Required value

Checklist

  • PR has at least one valid label: bug, enhancement, refactoring, documentation, tooling, and/or dependencies
  • PR has a milestone or the qa/skip-qa label

@shuheiktgw shuheiktgw requested a review from a team as a code owner February 14, 2025 09:02
@shuheiktgw shuheiktgw added this to the v1.14.0 milestone Feb 14, 2025
@shuheiktgw shuheiktgw added the enhancement New feature or request label Feb 14, 2025
@codecov-commenter
Copy link

codecov-commenter commented Feb 14, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 49.49%. Comparing base (53c0d8c) to head (568adb3).
Report is 1 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #1694   +/-   ##
=======================================
  Coverage   49.49%   49.49%           
=======================================
  Files         218      218           
  Lines       21244    21244           
=======================================
  Hits        10515    10515           
  Misses      10182    10182           
  Partials      547      547           
Flag Coverage Δ
unittests 49.49% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 53c0d8c...568adb3. Read the comment docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants