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 dnspolicy crd validations #578

Merged
merged 2 commits into from
Apr 26, 2024

Conversation

mikenairn
Copy link
Member

@mikenairn mikenairn commented Apr 25, 2024

closes #554

fix: DNSPolicy CRD required validations

The validations to ensure required fields were marked as required were incorrect.
Any fields that are not explicitly marked with +optional and do not have omitempty are considered required.

Update loadbalanced routingStrategy CRD validation

Update the CRD validations to make the "loadBalancing" field required if the routingStrategy is "loadbalanced" and make the "defaultWeight" and "defaultGeo" fields mandatory within the "loadBalancing" section.

Minimum valid specs are now:

Simple:

spec:
  targetRef:
    name: prod-web
    group: gateway.networking.k8s.io
    kind: Gateway
  routingStrategy: simple

LoadBalanced:

spec:
  targetRef:
    name: prod-web
    group: gateway.networking.k8s.io
    kind: Gateway
  routingStrategy: loadbalanced
  loadBalancing:
    geo:
      defaultGeo: foo
    weighted:
      defaultWeight: 100

@mikenairn mikenairn requested a review from a team as a code owner April 25, 2024 12:50
@mikenairn mikenairn force-pushed the fix_dnspolicy_crd_validations branch from fdf7805 to 4d59725 Compare April 25, 2024 14:23
The validations to ensure required fields were marked as required were
incorrect.

Any fields that are not explicitly marked with `+optional` and do not
have `omitempty` are considered required.
@mikenairn mikenairn force-pushed the fix_dnspolicy_crd_validations branch from 4d59725 to c29d990 Compare April 25, 2024 17:02
@@ -208,7 +208,6 @@ func (dh *dnsHelper) getLoadBalancedEndpoints(mcgTarget *multicluster.GatewayTar
}

var endpoint *externaldns.Endpoint
var defaultEndpoint *externaldns.Endpoint
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@makslion fyi, i removed this as it's not needed any longer. Also added some more relevant comments below.

@mikenairn mikenairn force-pushed the fix_dnspolicy_crd_validations branch from c29d990 to 0c0a4f0 Compare April 25, 2024 18:12
Update the CRD validations to make the "loadBalancing" field required if
the routingStrategy is "loadbalanced" and make the "defaultWeight" and
"defaultGeo" fields mandatory within the "loadBalancing" section.

Minimum valid specs are now:

Simple:
```
spec:
  targetRef:
    name: prod-web
    group: gateway.networking.k8s.io
    kind: Gateway
  routingStrategy: simple
```

LoadBalanced:
```
spec:
  targetRef:
    name: prod-web
    group: gateway.networking.k8s.io
    kind: Gateway
  routingStrategy: loadbalanced
  loadBalancing:
    geo:
      defaultGeo: foo
    weighted:
      defaultWeight: 100
```
@mikenairn mikenairn force-pushed the fix_dnspolicy_crd_validations branch from 0c0a4f0 to 08c7cca Compare April 25, 2024 18:26
@maleck13
Copy link
Collaborator

/lgtm

@mikenairn
Copy link
Member Author

Test are still broken for other reasons, verified the dns tests locally:

./bin/ginkgo --focus "DNSPolicy" --focus "TLSPolicy" --skip "Target status reconciler" -tags integration ./controllers/...
Running Suite: Controller Suite - /home/mnairn/go/src/github.com/kuadrant/kuadrant-operator/controllers
=======================================================================================================
Random Seed: 1714118795

Will run 31 of 147 specs
•••••••••••••••SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS••••••••••••••••SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS

Ran 31 of 147 Specs in 255.786 seconds
SUCCESS! -- 31 Passed | 0 Failed | 0 Pending | 116 Skipped
PASS

Ginkgo ran 1 suite in 4m23.97465344s
Test Suite Passed

@mikenairn mikenairn merged commit b3758bd into Kuadrant:main Apr 26, 2024
12 of 13 checks passed
@mikenairn mikenairn deleted the fix_dnspolicy_crd_validations branch April 26, 2024 08:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

DNSPolicy: defaultGeo should be required in the DNSPolicy spec
3 participants