Skip to content

Commit

Permalink
improve log message
Browse files Browse the repository at this point in the history
  • Loading branch information
majetideepak committed Sep 25, 2024
1 parent 990b011 commit fc99669
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
21 changes: 13 additions & 8 deletions velox/connectors/hive/storage_adapters/gcs/GCSFileSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -296,15 +296,20 @@ class GCSFileSystem::Impl {
}

auto credFile = hiveConfig_->gcsCredentialsPath();
if (!credFile.empty()) {
std::ifstream jsonFile(credFile);
std::stringstream credsBuffer;
credsBuffer << jsonFile.rdbuf();
auto creds = credsBuffer.str();
auto credentials = gc::MakeServiceAccountCredentials(std::move(creds));
options.set<gc::UnifiedCredentialsOption>(credentials);
if (!credFile.empty() && std::filesystem::exists(credFile)) {
std::ifstream jsonFile(credFile, std::ios::in);
if (!jsonFile.is_open()) {
LOG(WARNING) << "Error opening file " << credFile;
} else {
std::stringstream credsBuffer;
credsBuffer << jsonFile.rdbuf();
auto creds = credsBuffer.str();
auto credentials = gc::MakeServiceAccountCredentials(std::move(creds));
options.set<gc::UnifiedCredentialsOption>(credentials);
}
} else {
LOG(WARNING) << "Config::gcsCredentials is empty";
LOG(WARNING)
<< "Config hive.gcs.json-key-file-path is empty or key file path not found";
}

client_ = std::make_shared<gcs::Client>(options);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,6 @@ TEST_F(GCSFileSystemTest, credentialsConfig) {
std::make_shared<const config::ConfigBase>(std::move(configOverride));

filesystems::GCSFileSystem gcfs(conf);

gcfs.initializeClient();
try {
const std::string gcsFile =
Expand Down

0 comments on commit fc99669

Please sign in to comment.