我正在使用 Java API 将对象上传到 Google Cloud Storage。当我通过本地系统尝试相同的代码时,它工作正常,我能够上传 66MB 和 90MB 的对象而没有任何问题。
但是,当我在 GKE pod 中将应用程序部署为微服务后尝试相同的操作时,它会停止响应编写器代码上的 90MB 文件,而只会创建一个 0 字节的文件。虽然它适用于 66MB 对象/文件。POD 正在从 PersistentVolume 访问文件
这是我用于将对象写入云存储的代码。
try (Stream<String> lines = Files.lines(Paths.get(localPathFileName))) { //path is from persistentvolume
log.info("read all lines in stream"); //this line prints and after this nothing, no exception
try (WriteChannel writer = storage.writer(blobInfo)) {
lines.forEachOrdered(
line -> {
try {
writer.write(
ByteBuffer.wrap(line.concat("\n").getBytes(Charset.forName("UTF-8"))));
} catch (Exception e) {
log.error(
"Error while writing lines - " + bucketName + "/" + bucketPath + fileName);
e.printStackTrace();
}
});
} catch (Exception ex) {
log.error(
"Error while uploading through writer 2 - "
+ bucketName
+ "/"
+ bucketPath
+ fileName);
ex.printStackTrace();
}
我无法理解这里可能出现的问题。因为相同的代码在我的本地系统上运行良好,但在 pod 上却不行。我检查了内存和 CPU 都远低于上限。
当我尝试创建 90 MB 文件时,它会创建一个 0 字节文件。没有抛出异常或错误,即使我试图在每次迭代和之后捕获它。
有人会对此有任何想法吗?可能是什么问题?