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

update observability policy API to have minimum one target ref #2802

Closed
wants to merge 1 commit into from

Conversation

salonichf5
Copy link
Contributor

Proposed changes

Write a clear and concise description that helps reviewers understand the purpose and impact of your changes. Use the
following format:

Problem: User wants ObservabilityPolicy CRD should require a minimum of 1 TargetRef.

Solution: Add validation to have minimum one target ref for the ObservabilityPolicy CRDs.

Testing:

Tested manually using the example. Installed observabilityPolicy with on branch main, a target ref and ensuring everything works as expected.

Tested with specifying no target refs

kubectl apply -f - <<EOF
apiVersion: gateway.nginx.org/v1alpha1
kind: ObservabilityPolicy
metadata:
  name: coffee
spec:
  targetRefs: []
  tracing:
    strategy: ratio
    ratio: 75
    spanAttributes:
    - key: coffee-key
      value: coffee-value
EOF
The ObservabilityPolicy "coffee" is invalid:
* spec.targetRefs: Invalid value: 0: spec.targetRefs in body should have at least 1 items
* spec.targetRefs: Invalid value: "array": TargetRef Kind must be: HTTPRoute or GRPCRoute

Please focus on (optional): If you any specific areas where you would like reviewers to focus their attention or provide
specific feedback, add them here.

Closes #2524

Checklist

Before creating a PR, run through this checklist and mark each as complete.

  • I have read the CONTRIBUTING doc
  • I have added tests that prove my fix is effective or that my feature works
  • I have checked that all unit tests pass after adding my changes
  • I have updated necessary documentation
  • I have rebased my branch onto main
  • I will ensure my PR is targeting the main branch and pulling from my branch from my own fork

Release notes

If this PR introduces a change that affects users and needs to be mentioned in the release notes,
please add a brief note that summarizes the change.

ObservabilityPolicy API requires minimum one target ref specified when creating a policy.

@salonichf5 salonichf5 requested a review from a team as a code owner November 21, 2024 23:05
@github-actions github-actions bot added the bug Something isn't working label Nov 21, 2024
@salonichf5 salonichf5 closed this Nov 21, 2024
@sjberman sjberman deleted the bug/observability-ref branch November 22, 2024 20:45
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
Status: Done
Development

Successfully merging this pull request may close these issues.

Add validation to ObservabilityPolicy to require TargetRefs
1 participant