Skip to content

Commit 2830363

Browse files
committed
[Fix] Operator: DNS handling fixed
Recent changes/refactoring caused an issue due to misplaced slice append causing only 1 subdomain entry to be handled by domain resources. This change fixes the issue.
1 parent e5aae23 commit 2830363

File tree

4 files changed

+12
-8
lines changed

4 files changed

+12
-8
lines changed

internal/controller/dns-manager.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,11 @@ func getDnsInfo[T v1alpha1.DomainEntity](c *Controller, dom T) (resolvedDNSInfo
171171
tpl := template.New("dnsTemplate").Funcs(sprig.FuncMap())
172172

173173
resolvedDNSInfo = []*dnsInfo{}
174+
checkAndAppendDNSInfo := func(dnsInfo *dnsInfo) {
175+
if dnsInfo != nil {
176+
resolvedDNSInfo = append(resolvedDNSInfo, dnsInfo)
177+
}
178+
}
174179

175180
for _, dnsTemplate := range dnsTemplates {
176181
var parsedDnsInfo *dnsInfo
@@ -180,6 +185,8 @@ func getDnsInfo[T v1alpha1.DomainEntity](c *Controller, dom T) (resolvedDNSInfo
180185
if err != nil {
181186
return nil, err
182187
}
188+
checkAndAppendDNSInfo(parsedDnsInfo)
189+
continue
183190
}
184191
for subDomain, appId := range subdomainInfo {
185192
domVars["subDomain"] = subDomain
@@ -188,9 +195,7 @@ func getDnsInfo[T v1alpha1.DomainEntity](c *Controller, dom T) (resolvedDNSInfo
188195
return nil, err
189196
}
190197
parsedDnsInfo.appId = appId
191-
}
192-
if parsedDnsInfo != nil {
193-
resolvedDNSInfo = append(resolvedDNSInfo, parsedDnsInfo)
198+
checkAndAppendDNSInfo(parsedDnsInfo)
194199
}
195200
}
196201

internal/controller/reconcile_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ const (
4545
globalAccountId = "global-id-test"
4646
primaryDomain = "app.sme.sap.com"
4747
secondaryDomain = "sec.sme.sap.com"
48-
dnsTarget = "public-ingress.some.cluster.sap"
4948
defaultVersion = "0.0.1"
5049
)
5150

internal/controller/testdata/domain/domain-with-customDNS-services.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,10 @@ metadata:
3636
annotations:
3737
dns.gardener.cloud/class: garden
3838
sme.sap.com/owner-identifier: Domain.default.test-cap-01-primary
39-
sme.sap.com/resource-hash: b2cd5723c32ec9f60aba01365d37f1382d4c78e1e3b427c8b97aad742a613af3
39+
sme.sap.com/resource-hash: 8d75feef05a17c4d0ac51fa33c1439065af397aefd5ba43c2defb44254ec4598
4040
generateName: test-cap-01-primary-
4141
labels:
42-
sme.sap.com/btp-app-identifier-hash: "f20cc8aeb2003b3abc33f749a16bd53544b6bab2"
42+
sme.sap.com/btp-app-identifier-hash: ""
4343
sme.sap.com/owner-generation: "0"
4444
sme.sap.com/owner-identifier-hash: f3b9e769089130d9d80dc05b68fb1564beb8cccc
4545
sme.sap.com/dns-name-hash: 7f91a70a773eaf2e8e9c78020ddadf7f66119300

internal/controller/testdata/domain/domain-with-customDNS-tenant.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,10 @@ metadata:
3636
annotations:
3737
dns.gardener.cloud/class: garden
3838
sme.sap.com/owner-identifier: Domain.default.test-cap-01-primary
39-
sme.sap.com/resource-hash: b2cd5723c32ec9f60aba01365d37f1382d4c78e1e3b427c8b97aad742a613af3
39+
sme.sap.com/resource-hash: 8d75feef05a17c4d0ac51fa33c1439065af397aefd5ba43c2defb44254ec4598
4040
generateName: test-cap-01-primary-
4141
labels:
42-
sme.sap.com/btp-app-identifier-hash: "f20cc8aeb2003b3abc33f749a16bd53544b6bab2"
42+
sme.sap.com/btp-app-identifier-hash: ""
4343
sme.sap.com/owner-generation: "0"
4444
sme.sap.com/owner-identifier-hash: f3b9e769089130d9d80dc05b68fb1564beb8cccc
4545
sme.sap.com/dns-name-hash: 7f91a70a773eaf2e8e9c78020ddadf7f66119300

0 commit comments

Comments
 (0)