#1732

[Improvement]: Tunnel hostname setup always uses the server's one ingress credential, and the zone error does not say which

OpenMichaelOgunjimiopened 22d ago

Existing issue

  • I have searched the existing issues and found no duplicate.

Current behavior

Each server can have one Cloudflare ingress connection (uniqueIndex("ingress_connection_server").on(t.serverId) in packages/db/src/schema/ingress-connection.ts). Every tunnel hostname on that server is set up with that connection's credential: ingress/service.ts builds new CloudflareIngress(await token(c.organizationId, c.credentialId), c.accountId), and CloudflareIngress.zone() looks the zone up with that token.

If a project's domain is in a different Cloudflare zone than the one the connection's token can manage, hostname setup fails with:

This credential cannot manage the hostname's DNS zone in the selected Cloudflare account. Check its Zone Read and DNS Edit permissions.

Two things make this hard to diagnose:

  • The message does not say which credential was used, or which zone it looked for.
  • The domain dialog let me pick a different Cloudflare credential, but hostname setup still used the server's connection credential, so the failure looked as if my choice had been ignored.

I could not add a second ingress connection to the same server, so the only fix was to widen the existing token to cover the other zone.

Proposed improvement

  1. Name the credential and the hostname or zone in the error, for example: "The ingress credential for this server () cannot manage ."
  2. When the credential picked in the domain dialog differs from the server's ingress connection credential, say so there, or do not offer the choice when it has no effect.
  3. Longer term, allow more than one ingress connection per server, or a per-hostname credential, so domains in different zones or accounts can share a server. Fine to treat this part as a separate feature request.

Benefits

  • Anyone with domains in more than one Cloudflare zone or account (agencies, client domains that will move to another account later) can see what to fix without reading the source.
  • Removes the impression that a selected credential is silently ignored.
  • Items 1 and 2 are small; item 3 is the real fix and can be discussed separately.

Additional context

Seen on the desktop app with a server added over SSH and Cloudflare Tunnel ingress. I checked the behaviour against main at 367afdec9.

Activity

2
MichaelOgunjimi15d ago

Rechecked against v1.0.1: nothing here has changed. The error is still the generic "This credential cannot manage the hostname's DNS zone..." (packages/platform/src/engine/modules/ingress/cloudflare.ts:290), and ingress_connection_server is still a unique index on server_id.

Items 1 and 2 (name the credential and the zone in the error, and make the domain dialog's credential choice honest) are small and I'm happy to send a PR for them. Is the wording in the issue the right direction, or would you rather it say something different? I'll leave item 3 (more than one ingress connection per server) for you to decide separately.

MichaelOgunjimi7d ago

Item 1 is done in #1837 (merged): the zone error now names the ingress credential and the hostname it looked for, e.g. "The ingress credential for this server () cannot manage the DNS zone for . Check that its token has Zone Read and DNS Edit on that zone."

That leaves item 2, the domain dialog's credential choice, which still has no effect on tunnel hostname setup. Which direction would you prefer?

  1. Keep the picker and show a note in the dialog when the chosen credential differs from the server's ingress connection credential, saying the connection's credential is the one used.
  2. Stop offering the picker for hostnames that go through a tunnel, since the choice is ignored there.

I'll send a small PR for whichever you pick. Item 3 (more than one ingress connection per server) stays with you to decide separately.