console: CNAME only at names the deployment serves
Astra R1 P1: a synthesized <app>.<sqid>.<apps-domain> may have no address (no apex route yet, or an empty node under a steered child), so naming it could hand a member a CNAME that resolves nowhere. The target is now only a route the deployment serves under its own name: the claim's route when it is under the apps domain, or on the app page the app's apex when it is a route of that app and account. Everything else keeps today's advice. The catch-all and remote-instance rows go back to their reviewed source, which also clears the record-write census digest.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
6 files changed,
+99
−95
internal/console/apidomains.go+1 −1internal/console/apphost_guidance_test.go+58 −54internal/console/appsettings.go+1 −1internal/console/domaincatchall.go+3 −6internal/console/remoteinstances.go+1 −1internal/console/view.go+35 −32
CI passed — run details
Intent
Human
<paseo-system version="1" kind="agent-message" source-agent-id="8a3d302a-eac7-407c-b61c-f5ccc66b5544" message-id="c7ce3449-7491-40a5-a2a7-0db0e969c4bb"> Agent manager 8a3d302: when cname-app-host is merged, tell me the SHA at once; v0.34.28 is queued behind it. </paseo-system>
Human
<paseo-system version="1" kind="agent-message" source-agent-id="8a3d302a-eac7-407c-b61c-f5ccc66b5544" message-id="1df41b51-8445-4d36-8495-23cfdaa50c5b"> Status check from agent manager 8a3d302: Astra R1 finished at 11:44Z (FINDINGS-R1.md written) and CI on 99766a1e FAILED. Are you blocked? Please handle both: fix the findings, check the CI failure (flake vs real), push, carry on. </paseo-system>
diff --git a/internal/console/apidomains.go b/internal/console/apidomains.go| index 44e991d90..d1bf9e2ca 100644 |
| --- a/internal/console/apidomains.go |
| +++ b/internal/console/apidomains.go |
| @@ -1463,7 +1463,7 @@ func (s *Server) domainItem(ctx context.Context, c domains.Claim, readings map[s |
| item.Guidance, item.Detail = s.configuredRegionalGuidance(ctx, c) |
| item.Records = delegationRecords(c.Host, c.Wildcard, s.delegationZone) |
| case item.DNSStatus != "pointing" && item.DNSStatus != "unresolved": |
| - bound := targets.forApp(c.Host, c.Account, c.App, c.Route) |
| + bound := targets.forApp(c.Host, c.Route) |
| item.Guidance = domainGuidance(c.Host, bound) |
| // The structured form of the SAME advice, emitted under exactly the |
| // same condition so the two can never disagree about whether there is |
diff --git a/internal/console/apphost_guidance_test.go b/internal/console/apphost_guidance_test.go| index 6cdc7e72d..86b5d693f 100644 |
| --- a/internal/console/apphost_guidance_test.go |
| +++ b/internal/console/apphost_guidance_test.go |
| @@ -6,42 +6,35 @@ import ( |
| "net/http" |
| "strings" |
| "testing" |
| - "time" |
| - "github.com/carlosframework/platform/internal/domains" |
| "github.com/carlosframework/platform/internal/registry" |
| "github.com/carlosframework/platform/internal/release" |
| ) |
| -// Which name a custom domain is told to CNAME at. The claim's own route wins |
| -// when it is a name under the apps domain (the exact host serving it: an |
| -// instance's own name, HA or regional or not); otherwise the app's platform |
| -// apex, which reconcile mints for every app with a route. Nothing is named |
| -// when the deployment does not publish app hosts, or when the name asking is |
| -// already one of ours. |
| +// Which name a custom domain is told to CNAME at: the route it aliases, when |
| +// that is a name under the apps domain. Never a name built from spelling |
| +// alone (Astra R1 P1: an unrouted apex may have no address), never a sidecar |
| +// or member name, never anything on a deployment that does not publish app |
| +// hosts, and nothing for a name that is already one of ours. |
| func TestAppHostFor(t *testing.T) { |
| const d = "oncarlos.test" |
| for _, c := range []struct { |
| - name, domain, host, acct, app, route, want string |
| + name, domain, host, route, want string |
| }{ |
| - {"unpublished deployment names nothing", "", "shop.example.com", "bab", "blog", "", ""}, |
| - {"route under the apps domain is the app host", d, "shop.example.com", "bab", "blog", "eu.blog.bab.oncarlos.test", "eu.blog.bab.oncarlos.test"}, |
| - {"route case and trailing dot fold", d, "shop.example.com", "bab", "blog", "EU.Blog.bab.oncarlos.test.", "eu.blog.bab.oncarlos.test"}, |
| - {"first-route claim falls back to the apex", d, "shop.example.com", "bab", "blog", "", "blog.bab.oncarlos.test"}, |
| - {"route that is another custom name falls back to the apex", d, "www.example.com", "bab", "blog", "shop.example.com", "blog.bab.oncarlos.test"}, |
| - {"sidecar member name is never public", d, "shop.example.com", "bab", "blog", "m1.blog.sidecar.internal", "blog.bab.oncarlos.test"}, |
| - {"a wildcard route is never a target", d, "shop.example.com", "bab", "blog", "*.bab.oncarlos.test", "blog.bab.oncarlos.test"}, |
| - {"the apps domain itself is not an app host", d, "shop.example.com", "bab", "blog", "oncarlos.test", "blog.bab.oncarlos.test"}, |
| - {"catch-all head uses the apex", d, "*.example.com", "bab", "teams", "", "teams.bab.oncarlos.test"}, |
| - {"a name already under the apps domain gets nothing", d, "www.bab.oncarlos.test", "bab", "blog", "", ""}, |
| - {"no app, no apex", d, "shop.example.com", "bab", "", "", ""}, |
| - {"no account, no apex", d, "shop.example.com", "", "blog", "", ""}, |
| - {"an unusable app name gives no apex", d, "shop.example.com", "bab", "Not A Label", "", ""}, |
| - {"a route equal to the host is not a target", d, "blog.bab.oncarlos.test", "bab", "blog", "blog.bab.oncarlos.test", ""}, |
| + {"unpublished deployment names nothing", "", "shop.example.com", "eu.bab.oncarlos.test", ""}, |
| + {"route under the apps domain is the app host", d, "shop.example.com", "eu.bab.oncarlos.test", "eu.bab.oncarlos.test"}, |
| + {"route case and trailing dot fold", d, "shop.example.com", "EU.Bab.oncarlos.test.", "eu.bab.oncarlos.test"}, |
| + {"first-route claim names nothing", d, "shop.example.com", "", ""}, |
| + {"route that is another custom name names nothing", d, "www.example.com", "shop.example.com", ""}, |
| + {"sidecar member name is never public", d, "shop.example.com", "m1.blog.bab.sidecar.internal", ""}, |
| + {"a wildcard route is never a target", d, "shop.example.com", "*.bab.oncarlos.test", ""}, |
| + {"the apps domain itself is not an app host", d, "shop.example.com", "oncarlos.test", ""}, |
| + {"a look-alike suffix is not under the apps domain", d, "shop.example.com", "blog.bab.notoncarlos.test", ""}, |
| + {"a name already under the apps domain gets nothing", d, "www.bab.oncarlos.test", "blog.bab.oncarlos.test", ""}, |
| } { |
| t.Run(c.name, func(t *testing.T) { |
| - if got := appHostFor(c.domain, c.host, c.acct, c.app, c.route); got != c.want { |
| - t.Errorf("appHostFor(%q, %q, %q, %q, %q) = %q, want %q", c.domain, c.host, c.acct, c.app, c.route, got, c.want) |
| + if got := appHostFor(c.domain, c.host, c.route); got != c.want { |
| + t.Errorf("appHostFor(%q, %q, %q) = %q, want %q", c.domain, c.host, c.route, got, c.want) |
| } |
| }) |
| } |
| @@ -85,7 +78,7 @@ func TestGuidanceNamesTheAppHost(t *testing.T) { |
| ingress := DNSTargets{EdgeIPs: []string{ingressIP}, ConfiguredIngress: true, AppsDomain: "oncarlos.test"} |
| for name, base := range map[string]DNSTargets{"steered": steered, "configured ingress": ingress} { |
| t.Run(name, func(t *testing.T) { |
| - bound := base.forApp("shop.example.com", "bab", "blog", "") |
| + bound := base.forApp("shop.example.com", appHost) |
| if bound.AppHost != appHost { |
| t.Fatalf("bound app host = %q", bound.AppHost) |
| } |
| @@ -114,7 +107,7 @@ func TestGuidanceNamesTheAppHost(t *testing.T) { |
| t.Errorf("CNAME records = %+v, want one at %s", cname, appHost) |
| } |
| // The apex keeps today's advice, byte for byte. |
| - apexBound := base.forApp("example.com", "bab", "blog", "") |
| + apexBound := base.forApp("example.com", appHost) |
| unbound := base |
| if got, want := domainGuidance("example.com", apexBound), domainGuidance("example.com", unbound); got != want { |
| t.Errorf("apex guidance changed:\n got %q\n want %q", got, want) |
| @@ -137,7 +130,7 @@ func TestGuidanceUnpublishedDeploymentUnchanged(t *testing.T) { |
| ips := []string{"203.0.113.7"} |
| for _, base := range []DNSTargets{{EdgeIPs: ips}, {}, {EdgeIPs: ips, SteeringHost: "edge.oncarlos.test"}, {EdgeIPs: ips, ConfiguredIngress: true}} { |
| for _, host := range []string{"shop.example.com", "example.com"} { |
| - bound := base.forApp(host, "bab", "blog", "blog.bab.oncarlos.test") |
| + bound := base.forApp(host, "blog.bab.oncarlos.test") |
| if got, want := domainGuidance(host, bound), domainGuidance(host, base); got != want { |
| t.Errorf("%+v %s: guidance %q, want unchanged %q", base, host, got, want) |
| } |
| @@ -174,7 +167,9 @@ func TestDomainSurfacesAgreeOnTheAppHost(t *testing.T) { |
| attachShopClaim(t, fx, sqid, "titogo", "shop.example.com", instHost) |
| attachShopClaim(t, fx, sqid, "titogo", "first.example.com", "") |
| attachShopClaim(t, fx, sqid, "titogo", "example.com", instHost) |
| - want := map[string]string{"shop.example.com": instHost, "first.example.com": apex, "example.com": ""} |
| + // first.example.com has no route yet: no served name to CNAME at, so it |
| + // keeps today's configured-ingress advice. |
| + want := map[string]string{"shop.example.com": instHost, "first.example.com": "", "example.com": ""} |
| code, _, out := rawReq(t, http.MethodGet, domainsURL(fx, "bab", "titogo"), member, "") |
| if code != http.StatusOK { |
| @@ -225,10 +220,14 @@ func TestDomainSurfacesAgreeOnTheAppHost(t *testing.T) { |
| } |
| // The per-host door answers the same. |
| - code, _, out = rawReq(t, http.MethodGet, domainGetURL(fx, "bab", "titogo", "first.example.com"), member, "") |
| - if code != http.StatusOK || !strings.Contains(out, `"cname_target":"`+apex+`"`) { |
| - t.Errorf("per-host door = %d %s, want cname_target %s", code, out, apex) |
| + code, _, out = rawReq(t, http.MethodGet, domainGetURL(fx, "bab", "titogo", "shop.example.com"), member, "") |
| + if code != http.StatusOK || !strings.Contains(out, `"cname_target":"`+instHost+`"`) { |
| + t.Errorf("per-host door = %d %s, want cname_target %s", code, out, instHost) |
| } |
| + if got := want["first.example.com"]; got != "" { |
| + t.Fatal(got) |
| + } |
| + _ = apex |
| // Settings rows for claims with no registry row yet. |
| views := fx.srv.settingsDomains(withReqMemo(ctx), acct, "titogo", nil) |
| @@ -242,30 +241,35 @@ func TestDomainSurfacesAgreeOnTheAppHost(t *testing.T) { |
| } |
| } |
| - // A registry custom route (the app page's Domains rows) names the apex. |
| - dv := domainView(registry.Route{Host: "www.example.com", App: "titogo", Account: sqid}, fx.srv.dnsTargets(ctx)) |
| - if !strings.HasPrefix(dv.Guidance, "Point a CNAME for www.example.com at "+apex+",") { |
| - t.Errorf("app page guidance = %q", dv.Guidance) |
| - } |
| } |
| -// An instance catch-all's head ("*.<parent>") names the app's apex: no one |
| -// instance's name can stand for every label under it. |
| -func TestCatchallHeadNamesTheAppApex(t *testing.T) { |
| - fx, _ := instanceFixture(t, "code-dom-apphost-catchall") |
| - fx.srv.cfg.AppsDomain = "oncarlos.test" |
| +// The app page's custom routes name the app's platform apex only when that |
| +// apex is itself a route of the same app and account. A spelled-out apex |
| +// with no route behind it is never named (Astra R1 P1): the row keeps |
| +// today's advice. |
| +func TestAppPageNamesTheApexOnlyWhenRouted(t *testing.T) { |
| + fx := newConsoleFixture(t) |
| + fx.srv.cfg.AppsDomain = "carlosapp.dev" |
| + fx.srv.cfg.EdgeIPs = []string{"192.0.2.1"} |
| fx.srv.cfg.RegionIngress = []string{ingressIP} |
| - fx.srv.steeringHost = "edge.oncarlos.test" |
| - ctx := withReqMemo(context.Background()) |
| - acct, err := fx.st.AccountBySqid(release.OpsAccount) |
| - if err != nil || acct == nil { |
| - t.Fatalf("account: %v %v", acct, err) |
| + fx.srv.steeringHost = "edge.carlosapp.dev" |
| + fx.addRoute(t, registry.Route{Host: "www.example.com", Kind: "instance", Status: "ready", App: "kass", Account: release.OpsAccount, DNSStatus: "elsewhere"}) |
| + c := signInPaul(t, fx) |
| + page := func() string { |
| + _, _, body := get(t, c, fx.u("/apps/kass/settings/domains")) |
| + return body |
| + } |
| + if body := page(); strings.Contains(body, "Point a CNAME for www.example.com") || !strings.Contains(body, "Point an A record for www.example.com at 192.0.2.1, "+ingressIP+".") { |
| + t.Fatalf("unrouted apex: want today's ingress advice, got:\n%s", body) |
| + } |
| + // Another app's route at the spelled apex does not count either. |
| + fx.addRoute(t, registry.Route{Host: "kass.bab.carlosapp.dev", Kind: "instance", Status: "ready", App: "other", Platform: true, Account: release.OpsAccount, DNSStatus: "pointing"}) |
| + if body := page(); strings.Contains(body, "Point a CNAME for www.example.com") { |
| + t.Fatalf("named an apex another app holds:\n%s", body) |
| } |
| - c := domains.Claim{Host: "*.example.com", Instances: true, Account: acct.Sqid, App: "titogo"} |
| - items := fx.srv.catchallListItems(ctx, acct, "titogo", c, map[string]bool{}, nil, nil, fx.srv.dnsTargets(ctx), time.Now()) |
| - apex := "titogo." + acct.Sqid + ".oncarlos.test" |
| - if len(items) == 0 || items[0].CNAMETarget != apex || !strings.HasPrefix(items[0].Guidance, "Point a CNAME for *.example.com at "+apex+",") { |
| - t.Fatalf("catch-all head = %+v, want CNAME at %s", items, apex) |
| + fx.addRoute(t, registry.Route{Host: "kass.bab.carlosapp.dev", Kind: "instance", Status: "ready", App: "kass", Platform: true, Account: release.OpsAccount, DNSStatus: "pointing"}) |
| + if body := page(); !strings.Contains(body, "Point a CNAME for www.example.com at kass.bab.carlosapp.dev, your app's own address.") { |
| + t.Fatalf("routed apex not named:\n%s", body) |
| } |
| } |
| @@ -273,11 +277,11 @@ func TestCatchallHeadNamesTheAppApex(t *testing.T) { |
| // address set. |
| func TestAppHostGuidanceWording(t *testing.T) { |
| t.Parallel() |
| - bound := DNSTargets{EdgeIPs: []string{"203.0.113.10", "203.0.113.11"}, ConfiguredIngress: true, AppsDomain: "oncarlos.com"}.forApp("shop.example.com", "k3x", "blog", "") |
| + bound := DNSTargets{EdgeIPs: []string{"203.0.113.10", "203.0.113.11"}, ConfiguredIngress: true, AppsDomain: "oncarlos.com"}.forApp("shop.example.com", "blog.k3x.oncarlos.com") |
| if got, want := domainGuidance("shop.example.com", bound), "Point a CNAME for shop.example.com at blog.k3x.oncarlos.com, your app's own address. Visitors then reach the nearest edge, and the record keeps working if the app moves. An A record for shop.example.com at 203.0.113.10, 203.0.113.11 also works, but it sends visitors to fixed addresses that may change later. Checks run every few minutes."; got != want { |
| t.Errorf("with addresses:\n got %q\n want %q", got, want) |
| } |
| - bare := DNSTargets{SteeringHost: "edge.oncarlos.com", AppsDomain: "oncarlos.com"}.forApp("shop.example.com", "k3x", "blog", "") |
| + bare := DNSTargets{SteeringHost: "edge.oncarlos.com", AppsDomain: "oncarlos.com"}.forApp("shop.example.com", "blog.k3x.oncarlos.com") |
| if got, want := domainGuidance("shop.example.com", bare), "Point a CNAME for shop.example.com at blog.k3x.oncarlos.com, your app's own address. Visitors then reach the nearest edge, and the record keeps working if the app moves. Checks run every few minutes."; got != want { |
| t.Errorf("without addresses:\n got %q\n want %q", got, want) |
| } |
diff --git a/internal/console/appsettings.go b/internal/console/appsettings.go| index 21a5a25b2..1d8366a5a 100644 |
| --- a/internal/console/appsettings.go |
| +++ b/internal/console/appsettings.go |
| @@ -763,7 +763,7 @@ func (s *Server) settingsDomains(ctx context.Context, acct *Account, app string, |
| } |
| continue |
| } |
| - dv := claimDomainView(c.Host, s.dnsTargets(ctx).forApp(c.Host, c.Account, c.App, c.Route)) |
| + dv := claimDomainView(c.Host, s.dnsTargets(ctx).forApp(c.Host, c.Route)) |
| dv.State, dv.Reason, dv.Detail = state(c) |
| if c.Regional() { |
| dv.Guidance, dv.Detail = s.configuredRegionalGuidance(ctx, c) |
diff --git a/internal/console/domaincatchall.go b/internal/console/domaincatchall.go| index 488f2e195..60130c380 100644 |
| --- a/internal/console/domaincatchall.go |
| +++ b/internal/console/domaincatchall.go |
| @@ -349,7 +349,7 @@ func (s *Server) catchallListItems(ctx context.Context, acct *Account, app strin |
| rows := make([]domainListItem, 0, len(derived)) |
| pointing := false |
| for _, d := range derived { |
| - item := s.domainItem(ctx, domains.Claim{Host: d.Host, Route: d.Route, Account: acct.Sqid, App: app}, readings, warm[d.Host], targets, now, false) |
| + item := s.domainItem(ctx, domains.Claim{Host: d.Host, Route: d.Route}, readings, warm[d.Host], targets, now, false) |
| item.Via = c.Host |
| rows = append(rows, item) |
| pointing = pointing || d.Reading.DNSStatus == "pointing" |
| @@ -361,11 +361,8 @@ func (s *Server) catchallListItems(ctx context.Context, acct *Account, app strin |
| if !pointing { |
| // The wildcard record is what makes every label resolve here; the |
| // guidance for "*.<parent>" says exactly that. |
| - // The app's apex: no one instance's name can stand for every label. |
| - bound := targets.forApp(c.Host, acct.Sqid, app, "") |
| - head.Guidance = domainGuidance(c.Host, bound) |
| - head.Records = domainRecords(c.Host, bound, false, "") |
| - head.CNAMETarget = cnameTarget(c.Host, bound) |
| + head.Guidance = domainGuidance(c.Host, targets) |
| + head.Records = domainRecords(c.Host, targets, false, "") |
| } |
| // Whether the catch-all reserves every label, or only its instances' |
| // (catchallInstanceName). Said on every listing, with the record to |
diff --git a/internal/console/remoteinstances.go b/internal/console/remoteinstances.go| index 5bcf3cba5..75b548883 100644 |
| --- a/internal/console/remoteinstances.go |
| +++ b/internal/console/remoteinstances.go |
| @@ -466,7 +466,7 @@ func remoteRoute(rec provision.Record, rep *hostReport, f appFacts, acct string, |
| // domainView's rule: guidance only for a reading that says the |
| // member's record is missing or wrong. No reading is not that. |
| if rd.DNSStatus != "" && rd.DNSStatus != "pointing" && rd.DNSStatus != "unresolved" { |
| - dv.Guidance = domainGuidance(rec.Host, dns.forApp(rec.Host, rec.Account, rec.App, "")) |
| + dv.Guidance = domainGuidance(rec.Host, dns) |
| } |
| } |
| case f.complete() && !fleetPlaced && !f.seen(rec.Host): |
diff --git a/internal/console/view.go b/internal/console/view.go| index 11796f127..74f058dcd 100644 |
| --- a/internal/console/view.go |
| +++ b/internal/console/view.go |
| @@ -186,49 +186,41 @@ type DNSTargets struct { |
| } |
| // forApp binds the row's app host (see appHostFor). Every surface that shows |
| -// a custom domain's guidance binds it from the same claim or route facts, so |
| -// the app page, Settings and the domains door name the same host. |
| -func (t DNSTargets) forApp(host, acct, app, route string) DNSTargets { |
| - t.AppHost = appHostFor(t.AppsDomain, host, acct, app, route) |
| +// a custom domain's guidance binds it from the claim's or route's own facts, |
| +// so the app page, Settings and the domains door name the same host. |
| +func (t DNSTargets) forApp(host, route string) DNSTargets { |
| + t.AppHost = appHostFor(t.AppsDomain, host, route) |
| return t |
| } |
| -// appHostFor is the name under the apps domain a custom domain host should |
| -// CNAME at, or "" when there is none to name: |
| +// appHostFor is the name a custom domain host should CNAME at, or "" when |
| +// there is none to name: route, when it is a name under the apps domain. |
| // |
| -// 1. the claim's route, when it is a name under the apps domain: the exact |
| -// host serving the custom domain. For an instance (HA, in another |
| -// region, or a sidecar's primary) that is the instance's own public |
| -// name; member and sidecar names (*.sidecar.internal) are never under |
| -// the apps domain, so they are never named; |
| -// 2. otherwise the app's platform apex, <app>.<sqid>.<apps-domain>, which |
| -// reconcile mints for every app with a route. |
| -// |
| -// A host that is itself under the apps domain is ours already and is told |
| -// nothing new, and nothing is named on a deployment that does not publish |
| -// app hosts (domain ""). |
| -func appHostFor(domain, host, acct, app, route string) string { |
| - domain = strings.ToLower(strings.TrimSuffix(strings.TrimSpace(domain), ".")) |
| +// route is always a host the deployment SERVES under its own name: a |
| +// domain claim's route (the instance or app the custom name aliases; for an |
| +// HA instance, or one in another region, that is the instance's own public |
| +// name), or on the app page the app's platform apex when it is a route in |
| +// the registry. That is what makes it a safe target: its visitors already |
| +// reach it by that name, so its public DNS is maintained (steering records |
| +// or the apps-domain wildcards). A name merely SPELLED like an apex is never |
| +// named: one that is no route may have no address at all (Astra R1 P1). |
| +// Member and sidecar names (*.sidecar.internal) are never under the apps |
| +// domain, so they are never named. A host that is itself under the apps |
| +// domain is ours already and is told nothing new, and nothing is named on a |
| +// deployment that does not publish app hosts (domain ""). |
| +func appHostFor(domain, host, route string) string { |
| + norm := func(h string) string { return strings.ToLower(strings.TrimSuffix(strings.TrimSpace(h), ".")) } |
| + domain = norm(domain) |
| if domain == "" { |
| return "" |
| } |
| - norm := func(h string) string { return strings.ToLower(strings.TrimSuffix(strings.TrimSpace(h), ".")) } |
| h := norm(host) |
| - ours := func(n string) bool { |
| - return strings.HasSuffix(n, "."+domain) && provision.ValidHostShape(n) |
| - } |
| if h == domain || strings.HasSuffix(h, "."+domain) { |
| return "" |
| } |
| - if r := norm(route); ours(r) && r != h { |
| + if r := norm(route); strings.HasSuffix(r, "."+domain) && provision.ValidHostShape(r) { |
| return r |
| } |
| - if acct == "" || app == "" { |
| - return "" |
| - } |
| - if apex := norm(app) + "." + norm(acct) + "." + domain; ours(apex) { |
| - return apex |
| - } |
| return "" |
| } |
| @@ -344,7 +336,7 @@ func domainView(rt registry.Route, dns DNSTargets) DomainView { |
| // the member's record is missing or wrong, so telling them to (re)point |
| // it would blame them for our outage. |
| if !rt.Platform && rt.DNSStatus != "pointing" && rt.DNSStatus != "unresolved" { |
| - dv.Guidance = domainGuidance(rt.Host, dns.forApp(rt.Host, release.RouteAccount(rt), rt.App, "")) |
| + dv.Guidance = domainGuidance(rt.Host, dns) |
| } |
| return dv |
| } |
| @@ -671,6 +663,17 @@ func assembleViews(ctx context.Context, regPath, acct string, apps []string, dns |
| byApp := map[string][]RouteView{} |
| domainsByApp := map[string][]DomainView{} |
| localHosts := make(map[string]bool, len(routes)) |
| + // A custom route's CNAME target is its app's platform apex, and only when |
| + // the apex is a route here of that same app and account: a name that |
| + // merely spells the apex may have no address (see appHostFor). |
| + apexOf := map[[2]string]string{} |
| + if dns.AppsDomain != "" { |
| + for _, rt := range routes { |
| + if rt.Platform && !rt.Canary && rt.App != "" && rt.Host == rt.App+"."+release.RouteAccount(rt)+"."+dns.AppsDomain { |
| + apexOf[[2]string{release.RouteAccount(rt), rt.App}] = rt.Host |
| + } |
| + } |
| + } |
| for _, rt := range routes { |
| localHosts[rt.Host] = true |
| rtAcct := release.RouteAccount(rt) |
| @@ -710,7 +713,7 @@ func assembleViews(ctx context.Context, regPath, acct string, apps []string, dns |
| rv.Region = regionlabel.ForRoute(rt, remote.home, remote.names) |
| } |
| byApp[rt.App] = append(byApp[rt.App], rv) |
| - domainsByApp[rt.App] = append(domainsByApp[rt.App], domainView(rt, dns)) |
| + domainsByApp[rt.App] = append(domainsByApp[rt.App], domainView(rt, dns.forApp(rt.Host, apexOf[[2]string{rtAcct, rt.App}]))) |
| } |
| now := time.Now() |
| sorted := append([]string(nil), apps...) |