到目前为止,我在 Ktor 项目上使用 Java 8 运行时,并且该项目的部署没有出现任何问题,但现在当我迁移到 Java 11 运行时时,我遇到了问题。
我使用 appengine-web.xml 和 web.xml 来指定描述,但由于我正在迁移,所以我创建了一个如下所示的 app.yaml 文件:
app.yaml ->
runtime: java11
entrypoint: 'ProjectName-1.0-SNAPSHOT.jar'
instance_class: F1
automatic_scaling:
max_pending_latency: 500ms
min_idle_instances: 1
max_idle_instances: 1
max_concurrent_requests: 80
min_instances: 1
max_instances: 1
target_cpu_utilization: 0.95
target_throughput_utilization: 0.95
我已更新 JAVA_HOME 变量以指向 Java 11 安装目录。 我已经更新了我的 build.gradle (groovy) 以包含以下内容:
build.gradle ->
sourceCompatibility = 11
targetCompatibility = 11
这是运行“gcloud app deploy”命令后谷歌云控制台上的错误日志:
Starting Step #2 - "build"
Step #2 - "build": Already have image (with digest): asia.gcr.io/gae-runtimes/buildpacks/google-gae-18/java/builder:java_20231016_RC00
Step #2 - "build": ===> ANALYZING
Step #2 - "build": ERROR: failed to initialize analyzer: getting previous image: getting config file for image "asia.gcr.io/projectName/app-engine-tmp/app/default/ttl-18h:latest": GET https://storage.googleapis.com/asia.artifacts.prjectname.appspot.com/containers/images/sha256:{theHashCodeHere}?access_token=REDACTED: unexpected status code 404 Not Found: <?xml version='1.0' encoding='UTF-8'?><Error><Code>NoSuchKey</Code><Message>The specified key does not exist.</Message><Details>No such object: asia.artifacts.projectname.appspot.com/containers/images/sha256:{theHashCodeHere}</Details></Error>
Finished Step #2 - "build"
ERROR
ERROR: build step 2 "asia.gcr.io/gae-runtimes/buildpacks/google-gae-18/java/builder:java_20231016_RC00" failed: step exited with non-zero status: 1
出现此行为的原因可能是
App Engine’s
基础设施内的暂时性问题导致部署过程中出现竞争状况,试图获取默认存储这些图像的 GCS bucket
中可能尚不存在的图像。
另一种可能是图像的一部分,或者存储这些图像的存储桶可能已被删除。
我相信这个问题可能是由
GAE’s architecture
内的暂时性问题引起的。
可能的解决方案可能是:
几个小时后重试此操作,可能会成功部署。
使用
gcloud app deploy
命令和 --no-cache
标志有助于立即解决问题。这是因为 --no-cache
标志允许部署过程中的 build step
不使用缓存的图像,并且可能会解决受影响的 App Engine
实例的构建操作中发生的冲突。