Skip to content

Conversation

@azgabur
Copy link
Contributor

@azgabur azgabur commented Nov 7, 2025

closes #1628
requires Kuadrant/dns-operator#630

Additionally refactors tests to not use hard coded value but imports constant

Copy link
Member

@Boomatang Boomatang left a comment

Choose a reason for hiding this comment

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

We need to address the error handling if the env vars can not be parsed into ints

Comment on lines 23 to 31
func DNSPolicyDefaultTTL() int {
var ttl, _ = env.GetInt("DNS_DEFAULT_TTL", builder.DefaultTTL)
return ttl
}

func DNSPolicyDefaultCnameTTL() int {
var ttl, _ = env.GetInt("DNS_DEFAULT_LB_TTL", builder.DefaultLoadBalancedTTL)
return ttl
}
Copy link
Member

Choose a reason for hiding this comment

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

There is a few things that I am not happy about with this.

I don't like being able to look up environment at stage in the controllers life cycle, but there has being a precedent already set with operator.

I don't like the fact these are public method, but the only call site is within private methods. Where else do you expect the functions to be called.

The biggest issue is the errors being ignored. If the the env vars can't be parsed into an int, we should raising that error. At the very least we should be logging the error. This should be addressed.

Also can you explain the reasoning for writing variable creation in this style? It would not be a common style in the code base if it is done at all.

var ttl, _ = env.GetInt("DNS_DEFAULT_TTL", builder.DefaultTTL)

// Vs.

ttl, _ := env.GetInt("DNS_DEFAULT_TTL", builder.DefaultTTL)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Got inspired from internal/wasm/utils.go in structure of such getter functions, but I am open to suggestions.

I moved the call for these methods to internal/extension/manager.go reconcile method as that one had access to logger. Not very happy about the "bubbling" of the int values trough method calls, but what do you think?

My mistake about the variable definition, I seemed to forget the idiomatic Golang. Fixed.

gatewayapiv1 "sigs.k8s.io/gateway-api/apis/v1"

kuadrantdnsv1alpha1 "github.com/kuadrant/dns-operator/api/v1alpha1"
dnsBuilder "github.com/kuadrant/dns-operator/pkg/builder"
Copy link
Member

Choose a reason for hiding this comment

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

Can we keep this more consistent? in tests/commons.go it is named as kuadrantdnsbuilder and in the internal/controller/dnspolicy_dnsrecords.go it is not named. I am not asking you to change the existing naming, only that you don't introduce a third name.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Renamed to kuadrantdnsbuilder, my mistake I did not notice the common naming

@azgabur azgabur force-pushed the dns_ttl branch 2 times, most recently from f061f0b to b104be2 Compare December 2, 2025 14:15
@codecov
Copy link

codecov bot commented Jan 7, 2026

Codecov Report

❌ Patch coverage is 65.21739% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 74.91%. Comparing base (a76ecec) to head (41a4f2b).
⚠️ Report is 5 commits behind head on main.

Files with missing lines Patch % Lines
internal/controller/dnspolicy_dnsrecords.go 75.00% 2 Missing and 2 partials ⚠️
...nal/controller/effective_dnspolicies_reconciler.go 42.85% 2 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1668      +/-   ##
==========================================
- Coverage   75.06%   74.91%   -0.15%     
==========================================
  Files         120      120              
  Lines       10269    10287      +18     
==========================================
- Hits         7708     7707       -1     
- Misses       2188     2206      +18     
- Partials      373      374       +1     
Flag Coverage Δ
bare-k8s-integration 23.69% <34.78%> (-0.02%) ⬇️
controllers-integration 59.45% <65.21%> (+0.09%) ⬆️
envoygateway-integration 44.35% <34.78%> (-0.03%) ⬇️
gatewayapi-integration 18.96% <0.00%> (+0.02%) ⬆️
istio-integration 48.77% <34.78%> (+<0.01%) ⬆️
unit 22.33% <0.00%> (-0.04%) ⬇️

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

Components Coverage Δ
api (u) 85.88% <ø> (ø)
internal (u) 76.67% <65.21%> (-0.17%) ⬇️
pkg (u) 31.00% <ø> (ø)
Files with missing lines Coverage Δ
internal/controller/dnspolicy_dnsrecords.go 89.13% <75.00%> (-3.37%) ⬇️
...nal/controller/effective_dnspolicies_reconciler.go 74.12% <42.85%> (-1.26%) ⬇️

... and 13 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@azgabur
Copy link
Contributor Author

azgabur commented Jan 12, 2026

Not sure how to pass the "Validate release data" test, I even rebased the branch on main trying solving it.

Also not sure how to pass the coverage as all of my uncovered statements are logging statements which are not being tested I think. Let me know if I am wrong.

Could I get some guidance @Boomatang ? thanks

@azgabur azgabur marked this pull request as ready for review January 14, 2026 11:11
@azgabur azgabur requested a review from a team as a code owner January 14, 2026 11:11
@philbrookes philbrookes moved this to Ready For Review in Kuadrant Jan 19, 2026
@Boomatang
Copy link
Member

To get the validate release data it seems like you need to run make bundle and make helm-build. They should generate the changes that are missing causing the check to fail.

@azgabur azgabur force-pushed the dns_ttl branch 2 times, most recently from 7886135 to fad206d Compare January 19, 2026 23:10
@azgabur
Copy link
Contributor Author

azgabur commented Jan 20, 2026

Thanks, that worked 👍

Boomatang
Boomatang previously approved these changes Jan 20, 2026
Copy link
Member

@Boomatang Boomatang left a comment

Choose a reason for hiding this comment

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

Changes look good to me.

@azgabur azgabur added this pull request to the merge queue Jan 21, 2026
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jan 21, 2026
@azgabur azgabur added this pull request to the merge queue Jan 21, 2026
Signed-off-by: Alex Zgabur <azgabur@redhat.com>
Signed-off-by: Alex Zgabur <azgabur@redhat.com>
Signed-off-by: Alex Zgabur <azgabur@redhat.com>
@azgabur azgabur removed this pull request from the merge queue due to a manual request Jan 21, 2026
@azgabur azgabur added this pull request to the merge queue Jan 21, 2026
Merged via the queue into main with commit a4526a7 Jan 21, 2026
54 of 57 checks passed
@azgabur azgabur deleted the dns_ttl branch January 21, 2026 13:03
@github-project-automation github-project-automation bot moved this from Ready For Review to Done in Kuadrant Jan 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Allow setting default TTL for DNSRecords created by DnsPolicy

3 participants