posthog icon indicating copy to clipboard operation
posthog copied to clipboard

feat(data-warehouse): Added SSH tunnelling option for postgres syncs

Open Gilbert09 opened this issue 1 year ago â€ĸ 1 comments

Problem

  • A common use case when connecting to a postgres db is to do so via a ssh tunnel, this stops the postgres db being exposed on the public internet

Changes

  • Added UI to add a ssh tunnel when linking a postgres source
    • Allows for either a username + password or a private key + passphrase to connect
  • Adds backend ability to connect to the postgres db
    • via psycopg2 when getting db schemas on the fly
    • and via alchemy during the DLT postgres source connection
    • Rejigs the import_data temporal activity slightly so that the ssh tunnel is open for the length of the data import
  • SSHTunnelForwarder contexts deal with the opening and closing of the tunnel for us 🙏
image

TODO:

  • One more UI element - textarea for the private key
  • Backend unit tests for SSHTunnel and updating external_data_job tests
  • Security: restricting the port range of the ssh tunnel / postgres db
  • Test using a private key and passphrase locally

Does this work well for both Cloud and self-hosted?

  • Probably?

How did you test this code?

Unit tests and local testing

Gilbert09 avatar May 24 '24 17:05 Gilbert09

Size Change: 0 B

Total Size: 1.03 MB

â„šī¸ View Unchanged
Filename Size
frontend/dist/toolbar.js 1.03 MB

compressed-size-action

github-actions[bot] avatar May 24 '24 17:05 github-actions[bot]

📸 UI snapshots have been updated

2 snapshot changes in total. 0 added, 2 modified, 0 deleted:

  • chromium: 0 added, 2 modified, 0 deleted (diff for shard 1)
  • webkit: 0 added, 0 modified, 0 deleted

Triggered by this commit.

👉 Review this PR's diff of snapshots.

posthog-bot avatar May 28 '24 14:05 posthog-bot

📸 UI snapshots have been updated

2 snapshot changes in total. 0 added, 2 modified, 0 deleted:

  • chromium: 0 added, 2 modified, 0 deleted (diff for shard 1)
  • webkit: 0 added, 0 modified, 0 deleted

Triggered by this commit.

👉 Review this PR's diff of snapshots.

posthog-bot avatar May 28 '24 14:05 posthog-bot

📸 UI snapshots have been updated

1 snapshot changes in total. 0 added, 1 modified, 0 deleted:

  • chromium: 0 added, 1 modified, 0 deleted (diff for shard 2)
  • webkit: 0 added, 0 modified, 0 deleted

Triggered by this commit.

👉 Review this PR's diff of snapshots.

posthog-bot avatar May 29 '24 09:05 posthog-bot

📸 UI snapshots have been updated

2 snapshot changes in total. 0 added, 2 modified, 0 deleted:

  • chromium: 0 added, 2 modified, 0 deleted (diff for shard 2)
  • webkit: 0 added, 0 modified, 0 deleted

Triggered by this commit.

👉 Review this PR's diff of snapshots.

posthog-bot avatar May 29 '24 11:05 posthog-bot

📸 UI snapshots have been updated

1 snapshot changes in total. 0 added, 1 modified, 0 deleted:

  • chromium: 0 added, 1 modified, 0 deleted (diff for shard 2)
  • webkit: 0 added, 0 modified, 0 deleted

Triggered by this commit.

👉 Review this PR's diff of snapshots.

posthog-bot avatar May 29 '24 11:05 posthog-bot

📸 UI snapshots have been updated

1 snapshot changes in total. 0 added, 1 modified, 0 deleted:

  • chromium: 0 added, 1 modified, 0 deleted (diff for shard 2)
  • webkit: 0 added, 0 modified, 0 deleted

Triggered by this commit.

👉 Review this PR's diff of snapshots.

posthog-bot avatar May 29 '24 11:05 posthog-bot

📸 UI snapshots have been updated

1 snapshot changes in total. 0 added, 1 modified, 0 deleted:

  • chromium: 0 added, 1 modified, 0 deleted (diff for shard 2)
  • webkit: 0 added, 0 modified, 0 deleted

Triggered by this commit.

👉 Review this PR's diff of snapshots.

posthog-bot avatar May 29 '24 12:05 posthog-bot

📸 UI snapshots have been updated

1 snapshot changes in total. 0 added, 1 modified, 0 deleted:

  • chromium: 0 added, 1 modified, 0 deleted (diff for shard 2)
  • webkit: 0 added, 0 modified, 0 deleted

Triggered by this commit.

👉 Review this PR's diff of snapshots.

posthog-bot avatar May 29 '24 12:05 posthog-bot

📸 UI snapshots have been updated

1 snapshot changes in total. 0 added, 1 modified, 0 deleted:

  • chromium: 0 added, 1 modified, 0 deleted (diff for shard 2)
  • webkit: 0 added, 0 modified, 0 deleted

Triggered by this commit.

👉 Review this PR's diff of snapshots.

posthog-bot avatar May 29 '24 13:05 posthog-bot

📸 UI snapshots have been updated

1 snapshot changes in total. 0 added, 1 modified, 0 deleted:

  • chromium: 0 added, 1 modified, 0 deleted (diff for shard 2)
  • webkit: 0 added, 0 modified, 0 deleted

Triggered by this commit.

👉 Review this PR's diff of snapshots.

posthog-bot avatar May 29 '24 13:05 posthog-bot

📸 UI snapshots have been updated

1 snapshot changes in total. 0 added, 1 modified, 0 deleted:

  • chromium: 0 added, 1 modified, 0 deleted (diff for shard 2)
  • webkit: 0 added, 0 modified, 0 deleted

Triggered by this commit.

👉 Review this PR's diff of snapshots.

posthog-bot avatar May 29 '24 13:05 posthog-bot

📸 UI snapshots have been updated

1 snapshot changes in total. 0 added, 1 modified, 0 deleted:

  • chromium: 0 added, 1 modified, 0 deleted (diff for shard 2)
  • webkit: 0 added, 0 modified, 0 deleted

Triggered by this commit.

👉 Review this PR's diff of snapshots.

posthog-bot avatar May 29 '24 13:05 posthog-bot

📸 UI snapshots have been updated

2 snapshot changes in total. 0 added, 2 modified, 0 deleted:

  • chromium: 0 added, 2 modified, 0 deleted (diff for shard 2)
  • webkit: 0 added, 0 modified, 0 deleted

Triggered by this commit.

👉 Review this PR's diff of snapshots.

posthog-bot avatar May 29 '24 14:05 posthog-bot

Suspect Issues

This pull request was deployed and Sentry observed the following issues:

  • â€ŧī¸ PipelineStepFailed: Pipeline execution failed at stage extract when processing package 1717667809.3704422 with except... posthog.temporal.data_imports.pipelines.pipelin... View Issue
  • â€ŧī¸ PipelineStepFailed: Pipeline execution failed at stage extract when processing package 1717666575.3995636 with except... posthog.temporal.data_imports.pipelines.pipelin... View Issue
  • â€ŧī¸ PipelineStepFailed: Pipeline execution failed at stage normalize when processing package 1717676644.8231242 with exce... posthog.temporal.data_imports.pipelines.pipelin... View Issue
  • â€ŧī¸ OperationalError: SSL connection has been closed unexpectedly posthog.warehouse.models.external_data_schema i... View Issue
  • â€ŧī¸ Exception: SSHTunnel auth is not valid posthog.warehouse.models.ssh_tunnel in get_tunnel View Issue

Did you find this useful? React with a 👍 or 👎

sentry-io[bot] avatar May 29 '24 19:05 sentry-io[bot]