We have a java application running in Kubernetes cluster deployment. We're using Google Cloud Bucket as storage. We were using Java Files.move method to move files from our Persistent Volume Claim (PVC) to the storage bucket:
import java.nio.file.Files;
Files.move(source, target, StandardCopyOption.REPLACE_EXISTING)
But we're getting poor write performance. So we tried exploring Google Cloud Storage API to move files from our PVC to bucket.
try {
log.info("before getService");
Storage storage = StorageOptions.newBuilder()
.setCredentials(GoogleCredentials.create(aToken)).build()
.getService();
// aToken is the access token of the service account
log.info("after getService");
} catch (Exception e) {
log.error("Error while creating storage object - ", e);
}
But only "before getService" is getting logged. And nothing happens after that. No exception is thrown. The process gets stuck in getService()
The same application works on local deployment with Google Storage Bucket, but is not working on Kubernetes deployment.
The problem was due to the api version number in pom.xml (we're using Maven). Making the change to version 1.23.0 in pom.xml solved the problem.
<dependency>
<groupId>com.google.api-client</groupId>
<artifactId>google-api-client</artifactId>
<version>1.23.0</version>
</dependency>
<dependency>
<groupId>com.google.http-client</groupId>
<artifactId>google-http-client</artifactId>
<version>1.23.0</version>
</dependency>
<dependency>
<groupId>com.google.oauth-client</groupId>
<artifactId>google-oauth-client-jetty</artifactId>
<version>1.23.0</version>
</dependency>
For me, updating the version of the Google Storage API fixed the issue. In my Gradle build file, I was using 1.36 and after switching to 1.42, it was working fine.