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

fix: SSH Tunnel creation with dynamic form #24196

Merged
merged 17 commits into from
Jul 3, 2023
Merged

Conversation

hughhhh
Copy link
Member

@hughhhh hughhhh commented May 23, 2023

SUMMARY

Fixing issue with SSH tunnel creation with dynamic forms. Main issue was the ssh toggle would lose state, and validate_parameters endpoints would fail immediately since no tunnel is created on every onBlur event

To fix it I refactored the toggle state to the reducer, and stop validation on any ssh tunnel requests to connect to a DB

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

TESTING INSTRUCTIONS

ADDITIONAL INFORMATION

  • Has associated issue:
  • Required feature flags:
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
    • Migration is atomic, supports rollback & is backwards-compatible
    • Confirm DB migration upgrade and downgrade tested
    • Runtime estimates and downtime expectations provided
  • Introduces new feature or API
  • Removes existing feature or API

@codecov
Copy link

codecov bot commented May 23, 2023

Codecov Report

Merging #24196 (0bb9c6f) into master (d5f88c1) will increase coverage by 0.04%.
The diff coverage is 71.68%.

❗ Current head 0bb9c6f differs from pull request most recent head 5fb76e7. Consider uploading reports for the commit 5fb76e7 to get more accurate results

@@            Coverage Diff             @@
##           master   #24196      +/-   ##
==========================================
+ Coverage   69.03%   69.07%   +0.04%     
==========================================
  Files        1901     1906       +5     
  Lines       74002    74123     +121     
  Branches     8116     8158      +42     
==========================================
+ Hits        51086    51204     +118     
+ Misses      20805    20797       -8     
- Partials     2111     2122      +11     
Flag Coverage Δ
hive 53.92% <67.20%> (-0.01%) ⬇️
javascript 55.78% <61.53%> (+0.13%) ⬆️
mysql 79.40% <88.00%> (-0.03%) ⬇️
postgres 79.48% <88.00%> (-0.03%) ⬇️
presto 53.82% <64.80%> (-0.02%) ⬇️
python 83.48% <92.80%> (-0.01%) ⬇️
sqlite 78.04% <83.20%> (+0.03%) ⬆️
unit 54.69% <68.80%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...ackages/superset-ui-chart-controls/src/fixtures.ts 100.00% <ø> (ø)
...d/packages/superset-ui-chart-controls/src/types.ts 100.00% <ø> (ø)
.../packages/superset-ui-core/src/chart/types/Base.ts 100.00% <ø> (ø)
...ges/superset-ui-core/src/query/types/Datasource.ts 100.00% <ø> (ø)
...ackages/superset-ui-core/src/query/types/Metric.ts 100.00% <ø> (ø)
...rts/src/BigNumber/BigNumberTotal/transformProps.ts 0.00% <0.00%> (ø)
.../plugins/plugin-chart-echarts/src/BoxPlot/index.ts 50.00% <ø> (ø)
...d/plugins/plugin-chart-echarts/src/Funnel/index.ts 50.00% <ø> (ø)
...nd/plugins/plugin-chart-echarts/src/Gauge/index.ts 50.00% <ø> (ø)
...nd/plugins/plugin-chart-echarts/src/Graph/index.ts 50.00% <ø> (ø)
... and 122 more

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

const errors = await getValidation(dbToUpdate, true);
if ((validationErrors && !isEmpty(validationErrors)) || errors) {
// only do validation for non ssh tunnel connections
console.log(dbToUpdate);

Choose a reason for hiding this comment

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

leftover

@hughhhh hughhhh force-pushed the ssh-dynamic branch 3 times, most recently from a27ed0a to fdde2f8 Compare June 21, 2023 16:08
const errors = await getValidation(dbToUpdate, true);
if ((validationErrors && !isEmpty(validationErrors)) || errors) {
// only do validation for non ssh tunnel connections
if (!dbToUpdate?.ssh_tunnel) {
Copy link
Member

Choose a reason for hiding this comment

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

@hughhhh why can't we run the validation for SSH tunnel connections, assuming the user has provided that info?

I think the logic should be: if the user has enabled SSH, we don't perform any validation until SSH credentials are entered.

Copy link
Member Author

Choose a reason for hiding this comment

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

for the initial implementation, we were okay with doing validation on just connect. Right now users are not able to connect at all via dynamic forms.

I'm open to this fix but that's going to take longer to implement vs. fixing the issue at hand.

Let me know what you think

changeMethods,
db,
}: FieldPropTypes) =>
true ? (
Copy link
Member

Choose a reason for hiding this comment

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

Why the ternary operator here if the condition is always true?

@@ -753,6 +753,11 @@ export function useDatabaseValidation() {
.catch(e => {
if (typeof e.json === 'function') {
return e.json().then(({ errors = [] }: JsonObject) => {
if (database?.parameters?.ssh) {
Copy link
Member

Choose a reason for hiding this comment

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

I don't think this belongs here... if we don't want to show validation errors for some reason, then we shouldn't be running the validation API calls.

Copy link
Member

@betodealmeida betodealmeida left a comment

Choose a reason for hiding this comment

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

Awesome!

@hughhhh hughhhh merged commit 226c7f8 into apache:master Jul 3, 2023
@hughhhh hughhhh deleted the ssh-dynamic branch July 3, 2023 03:48
@michael-s-molina michael-s-molina added the v3.0 Label added by the release manager to track PRs to be included in the 3.0 branch label Jul 5, 2023
sadpandajoe pushed a commit to preset-io/superset that referenced this pull request Jul 5, 2023
@sadpandajoe
Copy link
Member

🏷️ preset:2023.27

michael-s-molina pushed a commit that referenced this pull request Jul 26, 2023
eschutho pushed a commit that referenced this pull request Oct 20, 2023
eschutho pushed a commit that referenced this pull request Oct 20, 2023
eschutho pushed a commit that referenced this pull request Oct 20, 2023
@mistercrunch mistercrunch added 🍒 2.1.2 🍒 2.1.3 🍒 3.0.0 🍒 3.0.1 🍒 3.0.2 🍒 3.0.3 🍒 3.0.4 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 3.1.0 labels Mar 8, 2024
vinothkumar66 pushed a commit to vinothkumar66/superset that referenced this pull request Nov 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2.1.2 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels size/L v2.1 v3.0 Label added by the release manager to track PRs to be included in the 3.0 branch 🍒 2.1.2 🍒 2.1.3 🍒 3.0.0 🍒 3.0.1 🍒 3.0.2 🍒 3.0.3 🍒 3.0.4 🚢 3.1.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants