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 SNOW-683245 and format the file #1188

Merged
merged 3 commits into from
Nov 15, 2022

Conversation

sfc-gh-igarish
Copy link
Collaborator

@sfc-gh-igarish sfc-gh-igarish commented Nov 9, 2022

Overview

SNOW-683245: Bug fix in JDBC for GET command when GCS_USE_DOWNSCOPED_CREDENTIAL in GS is true

When code was added not to use presigned url and use GCS API to download the file, it was using GCS GUNZIP stuff. In pre-signed URL logic the driver download the file as is i.e. in GZIP format. So added same logic when use the GCS API to get file without decompression i.e. in RAW format of the file. This optimize the data transfer on the wire.

Sent the new JDBC Jar to Timothy as he has setup already. He confirm the change works fine.

External contributors - please answer these questions before submitting a pull request. Thanks!

Please answer these questions before submitting your pull requests. Thanks!

  1. What GitHub issue is this PR addressing? Make sure that there is an accompanying issue to your PR.

    Fixes #NNNN

  2. Fill out the following pre-review checklist:

    • I am adding a new automated test(s) to verify correctness of my new code
    • I am adding new logging messages
    • I am modifying authorization mechanisms
    • I am adding new credentials
    • I am modifying OCSP code
    • I am adding a new dependency
  3. Please describe how your code solves the related issue.

    Please write a short description of how your code change solves the related issue.

Pre-review checklist

  • This change has passed precommit
  • I have reviewed code coverage report for my PR in (Sonarqube)

@@ -296,7 +296,8 @@ public void download(
}

logger.debug("Starting download without presigned URL", false);
blob.downloadTo(localFile.toPath());
blob.downloadTo(
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is there test coverage for this? Or are there any existing tests that this would affect?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We change the way we access GCS. So existing tests will do.

Copy link
Contributor

@sfc-gh-wshangguan sfc-gh-wshangguan Nov 10, 2022

Choose a reason for hiding this comment

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

So this is not a behavior change? Does JDBC do the decompression somewhere else previously? @sfc-gh-igarish

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 behavior change. In the same method below it does decompression. So download file as is and then decompress locally.Same logic as pre-signed url.

Copy link
Collaborator

@sfc-gh-tyuan sfc-gh-tyuan left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks, Ilesh!

@sfc-gh-hchaturvedi
Copy link
Collaborator

Can we add a test to ensure that the driver is successfully able to unzip the file to protect against future regressions?

@sfc-gh-igarish
Copy link
Collaborator Author

Can we add a test to ensure that the driver is successfully able to unzip the file to protect against future regressions?

Do we have a test for GCS with pre-signed URL and GET? If yes, then it will cover. Up to now we won't get this error because this feature was not enable in GS. So I think, it's not a regression.

@sfc-gh-igarish
Copy link
Collaborator Author

Can we add a test to ensure that the driver is successfully able to unzip the file to protect against future regressions?

Do we have a test for GCS with pre-signed URL and GET? If yes, then it will cover. Up to now we won't get this error because this feature was not enable in GS. So I think, it's not a regression.
we already has test case in SnowflakeDriverIT.java file: testPutGetLargeFileGCSDownscopedCredential with GCS_USE_DOWNSCOPED_CREDENTIAL=true

@@ -18,13 +18,13 @@ public void testParseAccountName() throws SnowflakeSQLException {
cstring.getParameters().get(SFSessionProperty.ACCOUNT.getPropertyKey().toUpperCase()),
is("abc"));

// Hostname should remain unchanged by default.
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this a new bug in our 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.

This is not part of my PR. Today again when I tried to do git push, if failed. So I did "git pull origin my_branch" and it got other commits in this PR. Before doing pull, I tried "git rebase" but still git push was failing.

*
* @throws Throwable
*/
@Test
@Ignore
@ConditionalIgnoreRule.ConditionalIgnore(condition = RunningOnGithubAction.class)
Copy link
Contributor

Choose a reason for hiding this comment

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

Just to double check that this is what we want. run it on Jenkins but not on github

Copy link
Collaborator Author

@sfc-gh-igarish sfc-gh-igarish Nov 12, 2022

Choose a reason for hiding this comment

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

Yes. All GCS tests are configure that way.

@sfc-gh-igarish sfc-gh-igarish force-pushed the igarish-SNOW-683245-GCS-DOWNSCOPE-TOKEN branch from afe997f to 8a00b7f Compare November 12, 2022 08:24
@sonarqubemergegate
Copy link

SonarQube Quality Gate

Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

Copy link
Collaborator

@sfc-gh-hchaturvedi sfc-gh-hchaturvedi left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@sfc-gh-wshangguan sfc-gh-wshangguan left a comment

Choose a reason for hiding this comment

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

LGTM!

@sfc-gh-igarish sfc-gh-igarish merged commit d369ef5 into master Nov 15, 2022
@sfc-gh-igarish sfc-gh-igarish deleted the igarish-SNOW-683245-GCS-DOWNSCOPE-TOKEN branch November 15, 2022 03:57
@github-actions github-actions bot locked and limited conversation to collaborators Nov 15, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants