TUN-3819: Remove client-side check that deleted tunnels have no connections

This commit is contained in:
Adam Chalmers 2021-02-11 15:22:51 -06:00
parent 89b738f8fa
commit ded9dec4f0
2 changed files with 3 additions and 7 deletions

View File

@ -223,12 +223,7 @@ func (sc *subcommandContext) delete(tunnelIDs []uuid.UUID) error {
if !tunnel.DeletedAt.IsZero() { if !tunnel.DeletedAt.IsZero() {
return fmt.Errorf("Tunnel %s has already been deleted", tunnel.ID) 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 forceFlagSet {
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 err := client.CleanupConnections(tunnel.ID); err != nil { if err := client.CleanupConnections(tunnel.ID); err != nil {
return errors.Wrapf(err, "Error cleaning up connections for tunnel %s", tunnel.ID) return errors.Wrapf(err, "Error cleaning up connections for tunnel %s", tunnel.ID)
} }

View File

@ -102,7 +102,8 @@ var (
forceDeleteFlag = &cli.BoolFlag{ forceDeleteFlag = &cli.BoolFlag{
Name: "force", Name: "force",
Aliases: []string{"f"}, 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"}, EnvVars: []string{"TUNNEL_RUN_FORCE_OVERWRITE"},
} }
selectProtocolFlag = altsrc.NewStringFlag(&cli.StringFlag{ selectProtocolFlag = altsrc.NewStringFlag(&cli.StringFlag{