diff --git a/cmd/cloudflared/tunnel/subcommand_context.go b/cmd/cloudflared/tunnel/subcommand_context.go index d7a8a9d9..01537d90 100644 --- a/cmd/cloudflared/tunnel/subcommand_context.go +++ b/cmd/cloudflared/tunnel/subcommand_context.go @@ -223,12 +223,7 @@ func (sc *subcommandContext) delete(tunnelIDs []uuid.UUID) error { if !tunnel.DeletedAt.IsZero() { return fmt.Errorf("Tunnel %s has already been deleted", tunnel.ID) } - // Check if tunnel has existing connections and if force flag is set, cleanup connections - if len(tunnel.Connections) > 0 { - if !forceFlagSet { - return fmt.Errorf("You can not delete tunnel %s because it has active connections. To see connections run the 'list' command. If you believe the tunnel is not active, you can use a -f / --force flag with this command.", id) - } - + if forceFlagSet { if err := client.CleanupConnections(tunnel.ID); err != nil { return errors.Wrapf(err, "Error cleaning up connections for tunnel %s", tunnel.ID) } diff --git a/cmd/cloudflared/tunnel/subcommands.go b/cmd/cloudflared/tunnel/subcommands.go index eb57b9d4..b18c7137 100644 --- a/cmd/cloudflared/tunnel/subcommands.go +++ b/cmd/cloudflared/tunnel/subcommands.go @@ -102,7 +102,8 @@ var ( forceDeleteFlag = &cli.BoolFlag{ Name: "force", Aliases: []string{"f"}, - Usage: "Allows you to delete a tunnel, even if it has active connections.", + Usage: "Cleans up any stale connections before the tunnel is deleted. cloudflared will not " + + "delete a tunnel with connections without this flag.", EnvVars: []string{"TUNNEL_RUN_FORCE_OVERWRITE"}, } selectProtocolFlag = altsrc.NewStringFlag(&cli.StringFlag{