Skip to content

Commit

Permalink
[SNOW-943964] Fix GCP downscope token issue (#1539)
Browse files Browse the repository at this point in the history
* [SNOW-943964] Fix GCP downscope token issue

* [DoNotMerge][SNOW-943964] Hot Fix for GCS connectivity issues

* additional logs

* Formatting issues
  • Loading branch information
sfc-gh-skumbham committed Oct 26, 2023
1 parent 4453b41 commit 8720b4c
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 7 deletions.
4 changes: 0 additions & 4 deletions FIPS/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -811,10 +811,6 @@
<shadedPattern>${shadeBase}.google.iam</shadedPattern>
</relocation>
<relocation>
<pattern>storage</pattern>
<shadedPattern>${shadeBase}.storage</shadedPattern>
</relocation>
<relocation>
<pattern>io.opencensus</pattern>
<shadedPattern>${shadeBase}.opencensus</shadedPattern>
</relocation>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,15 +99,17 @@ public SFBaseStatement getSFStatement() {

protected void initialize(SnowflakeConnectString conStr, String appID, String appVersion)
throws SQLException {
logger.debug(
"Trying to establish session, JDBC driver version: {}", SnowflakeDriver.implementVersion);
TelemetryService.getInstance().updateContext(conStr);

try {
// pass the parameters to sfSession
initSessionProperties(conStr, appID, appVersion);
setClientConfig();
initLogger();
logger.debug(
"Trying to establish session, JDBC driver version: {} : {}",
SnowflakeDriver.getImplementationTitle(),
SnowflakeDriver.implementVersion);
if (!skipOpen) {
sfSession.open();
}
Expand Down
10 changes: 10 additions & 0 deletions src/main/java/net/snowflake/client/jdbc/SnowflakeDriver.java
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,16 @@ public static String getDisableArrowResultFormatMessage() {
return disableArrowResultFormatMessage;
}

/**
* Utility method to verify if the standard or fips snowflake-jdbc driver is being used.
*
* @return
*/
public static String getImplementationTitle() {
Package pkg = Package.getPackage("net.snowflake.client.jdbc");
return pkg.getImplementationTitle();
}

/**
* Checks whether a given url is in a valid format.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,8 @@ public void shutdown() {
public StorageObjectSummaryCollection listObjects(String remoteStorageLocation, String prefix)
throws StorageProviderException {
try {
logger.debug(
"Listing objects in the bucket {} with prefix {}", remoteStorageLocation, prefix);
Page<Blob> blobs = this.gcsClient.list(remoteStorageLocation, BlobListOption.prefix(prefix));
return new StorageObjectSummaryCollection(blobs);
} catch (Exception e) {
Expand Down Expand Up @@ -633,7 +635,7 @@ public void upload(
}

if (!Strings.isNullOrEmpty(presignedUrl)) {
logger.debug("Starting upload", false);
logger.debug("Starting upload with downscope token", false);
uploadWithPresignedUrl(
session.getNetworkTimeoutInMilli(),
session.getAuthTimeout(),
Expand Down Expand Up @@ -720,6 +722,7 @@ private void uploadWithDownScopedToken(
String contentEncoding,
Map<String, String> metadata,
InputStream content) {
logger.debug("Uploading file {} to bucket {}", destFileName, remoteStorageLocation);
BlobId blobId = BlobId.of(remoteStorageLocation, destFileName);
BlobInfo blobInfo =
BlobInfo.newBuilder(blobId)
Expand Down

0 comments on commit 8720b4c

Please sign in to comment.