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

SNOW-1820372: (from 947) when proxy is set in Connection, driver does send traffic through the proxy to S3, but not to Azure blob / GCS bucket (only Snowflake). Works with proxy envvar (GCP) #982

Open
wants to merge 50 commits into
base: master
Choose a base branch
from

Conversation

sfc-gh-ext-simba-jy
Copy link
Collaborator

Description

Please explain the changes you made here.

Checklist

  • Format code according to the existing code style (run npm run lint:check -- CHANGED_FILES and fix problems in changed code)
  • Create tests which fail without the change (if possible)
  • Make all tests (unit and integration) pass (npm run test:unit and npm run test:integration)
  • Extend the types in index.d.ts file (if necessary)
  • Extend the README / documentation and ensure is properly displayed (if necessary)
  • Provide JIRA issue id (if possible) or GitHub issue id in commit message

Copy link

codecov bot commented Dec 7, 2024

Codecov Report

Attention: Patch coverage is 85.39326% with 13 lines in your changes missing coverage. Please review.

Project coverage is 88.99%. Comparing base (d7eed90) to head (51b0702).

Files with missing lines Patch % Lines
lib/file_transfer_agent/gcs_util.js 79.62% 11 Missing ⚠️
lib/proxy_util.js 90.90% 1 Missing ⚠️
lib/services/sf.js 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #982      +/-   ##
==========================================
+ Coverage   88.91%   88.99%   +0.08%     
==========================================
  Files          72       72              
  Lines        6944     7006      +62     
==========================================
+ Hits         6174     6235      +61     
- Misses        770      771       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@sfc-gh-ext-simba-jy sfc-gh-ext-simba-jy changed the title Snow 1820372 SNOW-1820372: (from 947) when proxy is set in Connection, driver does send traffic through the proxy to S3, but not to Azure blob / GCS bucket (only Snowflake). Works with proxy envvar (GCP) Dec 10, 2024
@sfc-gh-ext-simba-jy sfc-gh-ext-simba-jy marked this pull request as ready for review December 10, 2024 17:52
@sfc-gh-ext-simba-jy sfc-gh-ext-simba-jy requested a review from a team as a code owner December 10, 2024 17:52
index.d.ts Outdated Show resolved Hide resolved
lib/proxy_util.js Outdated Show resolved Hide resolved
lib/file_transfer_agent/gcs_util.js Outdated Show resolved Hide resolved
lib/file_transfer_agent/gcs_util.js Outdated Show resolved Hide resolved
lib/file_transfer_agent/gcs_util.js Outdated Show resolved Hide resolved
index.d.ts Outdated Show resolved Hide resolved
lib/file_transfer_agent/gcs_util.js Show resolved Hide resolved
lib/file_transfer_agent/gcs_util.js Show resolved Hide resolved
lib/file_transfer_agent/gcs_util.js Show resolved Hide resolved
lib/file_transfer_agent/gcs_util.js Show resolved Hide resolved
lib/proxy_util.js Outdated Show resolved Hide resolved
lib/util.js Outdated
@@ -740,6 +740,10 @@ exports.getEnvVar = function (variable) {
return process.env[variable.toLowerCase()] || process.env[variable.toUpperCase()];
};

exports.restoreEnvVar = function (envVar, value) {
Copy link
Collaborator

@sfc-gh-pmotacki sfc-gh-pmotacki Dec 20, 2024

Choose a reason for hiding this comment

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

Do we still need this method and its test?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

No, we do not need it anymore. I removed it. Thank you!

isProxyEnabled = true;
const proxyAgent = getProxyAgent(proxy, new URL(connectionConfig.accessUrl), endPoint || `storage.${stageInfo.region.toLowerCase()}.rep.googleapis.com` );
axios = require('axios').create({
proxy: false,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is it correct to set here proxy = false?

Copy link
Collaborator Author

@sfc-gh-ext-simba-jy sfc-gh-ext-simba-jy Dec 20, 2024

Choose a reason for hiding this comment

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

Yes, we need to set proxy: false if we want to use https-proxy-agent in Axios. If not, the driver will face the 'too many direction' error. The same implementation is here: https://github.com/snowflakedb/snowflake-connector-nodejs/blob/master/lib/http/base.js#L289

client = { gcsToken: gcsToken, gcsClient: storage };
} else {
client = null;
}

if (typeof httpClient === 'undefined') {
axios = require('axios');
Copy link
Collaborator

Choose a reason for hiding this comment

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

The line could be a part of if ... else when we confirm whether the proxy is set or not.

if (proxy || Util.getEnvVar('http_proxy')) {
...
} else { 
     axios = require('axios');
}

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done.

client = { gcsToken: gcsToken, gcsClient: storage };
} else {
client = null;
}

if (typeof httpClient === 'undefined') {
Copy link
Collaborator

Choose a reason for hiding this comment

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

The code of setting up axios could be extracted to the separated method.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants