Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(ssh): Allow users to set TUNNEL_TIMEOUT from config #24202

Merged
merged 6 commits into from
May 24, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions superset/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -515,6 +515,7 @@ class D3Format(TypedDict, total=False):
# ----------------------------------------------------------------------
SSH_TUNNEL_MANAGER_CLASS = "superset.extensions.ssh.SSHManager"
SSH_TUNNEL_LOCAL_BIND_ADDRESS = "127.0.0.1"
SSH_TUNNEL_TIMEOUT = 1.0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe SSH_TUNNEL_TIMEOUT_SECS?


# Feature flags may also be set via 'SUPERSET_FEATURE_' prefixed environment vars.
DEFAULT_FEATURE_FLAGS.update(
Expand Down
3 changes: 2 additions & 1 deletion superset/extensions/ssh.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

from flask import Flask
from paramiko import RSAKey
from sshtunnel import open_tunnel, SSHTunnelForwarder
from sshtunnel import open_tunnel, SSHTunnelForwarder, TUNNEL_TIMEOUT

from superset.databases.utils import make_url_safe

Expand All @@ -34,6 +34,7 @@ class SSHManager:
def __init__(self, app: Flask) -> None:
super().__init__()
self.local_bind_address = app.config["SSH_TUNNEL_LOCAL_BIND_ADDRESS"]
TUNNEL_TIMEOUT = app.config["SSH_TUNNEL_TIMEOUT"]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this set the TUNNEL_TIMEOUT constant back to sshtunel? or we still need to invoke sshtunel. TUNNEL_TIMEOUT = "value"
can we add a test for this?


def build_sqla_url( # pylint: disable=no-self-use
self, sqlalchemy_url: str, server: SSHTunnelForwarder
Expand Down