Skip to content

Commit ae460b3

Browse files
nmldieguessssilver
authored andcommitted
TUN-4342: Fix false positive warning about unused hostname property
1 parent bc54a7f commit ae460b3

File tree

4 files changed

+16
-5
lines changed

4 files changed

+16
-5
lines changed

cmd/cloudflared/tunnel/cmd.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ func runAdhocNamedTunnel(sc *subcommandContext, name, credentialsOutputPath stri
181181

182182
if r, ok := routeFromFlag(sc.c); ok {
183183
if res, err := sc.route(tunnel.ID, r); err != nil {
184-
sc.log.Err(err).Msg("failed to create route, please create it manually")
184+
sc.log.Err(err).Str("route", r.String()).Msg("failed to provision routing, please create it manually via Cloudflare dashboard or UI; most likely you already have a conflicting record there")
185185
} else {
186186
sc.log.Info().Msg(res.SuccessSummary())
187187
}

cmd/cloudflared/tunnel/configuration.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -160,10 +160,6 @@ func prepareTunnelConfig(
160160
if err != nil {
161161
log.Err(err).Str(LogFieldHostname, configHostname).Msg("Invalid hostname")
162162
return nil, ingress.Ingress{}, errors.Wrap(err, "Invalid hostname")
163-
} else if hostname != "" && isNamedTunnel {
164-
log.Warn().Msg("The property `hostname` in your configuration is ignored because you configured a Named Tunnel " +
165-
"in the property `tunnel`. Make sure to provision the routing (e.g. via `cloudflared tunnel route`) or else " +
166-
"your origin will not be reachable. You should remove the `hostname` property to avoid this warning.")
167163
}
168164
isFreeTunnel := hostname == ""
169165
clientID := c.String("id")

cmd/cloudflared/tunnel/subcommands.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -595,6 +595,12 @@ func runCommand(c *cli.Context) error {
595595
}
596596
}
597597

598+
if c.String("hostname") != "" {
599+
sc.log.Warn().Msg("The property `hostname` in your configuration is ignored because you configured a Named Tunnel " +
600+
"in the property `tunnel` to run. Make sure to provision the routing (e.g. via `cloudflared tunnel route dns/lb`) or else " +
601+
"your origin will not be reachable. You should remove the `hostname` property to avoid this warning.")
602+
}
603+
598604
return runNamedTunnel(sc, tunnelRef)
599605
}
600606

tunnelstore/client.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ type Route interface {
7272
json.Marshaler
7373
RecordType() string
7474
UnmarshalResult(body io.Reader) (RouteResult, error)
75+
String() string
7576
}
7677

7778
type RouteResult interface {
@@ -116,6 +117,10 @@ func (dr *DNSRoute) RecordType() string {
116117
return "dns"
117118
}
118119

120+
func (dr *DNSRoute) String() string {
121+
return fmt.Sprintf("%s %s", dr.RecordType(), dr.userHostname)
122+
}
123+
119124
func (res *DNSRouteResult) SuccessSummary() string {
120125
var msgFmt string
121126
switch res.CName {
@@ -164,6 +169,10 @@ func (lr *LBRoute) RecordType() string {
164169
return "lb"
165170
}
166171

172+
func (lb *LBRoute) String() string {
173+
return fmt.Sprintf("%s %s %s", lb.RecordType(), lb.lbName, lb.lbPool)
174+
}
175+
167176
func (lr *LBRoute) UnmarshalResult(body io.Reader) (RouteResult, error) {
168177
var result LBRouteResult
169178
err := parseResponse(body, &result)

0 commit comments

Comments
 (0)