19 - GCP App Engine:轉移Container Registry -> Artifact Registry
GAE更新專案deploy ERROR,原因是GCP默默(x)把Container Registry(App Engine背後運作的元件)給deprecated掉了,所以我們要手動把它轉移到Artifact Registry(新版替代品)上
19 - GCP App Engine:轉移Container Registry -> Artifact Registry
GAE更新專案deploy ERROR,原因是GCP默默(x)把Container Registry(App Engine背後運作的元件)給deprecated掉了,所以我們要手動把它轉移到Artifact Registry(新版替代品)上

1 / 錯誤
跟上次一樣的 mvn clean package appengine:deploy
但是出現的不是跟上次一樣的BUILD SUCCESS而是FAILURE 📛
[INFO] GCLOUD: ERROR: (gcloud.app.deploy) Error Response: [9] Cloud build [編號] status: FAILURE
[INFO] GCLOUD: An unexpected error occurred. Refer to build logs: https://console.cloud.google.com/cloud-build/builds;region=asia-northeast1/[編號]?project=[編號]
[INFO] GCLOUD: Full build logs: https://console.cloud.google.com/cloud-build/builds;region=asia-northeast1/[編號]?project=[編號]
[INFO] - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
[INFO] BUILD FAILURE
[INFO] - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
[INFO] Total time: 01:00 min
[INFO] Finished at: 2023–12–19T15:04:30+08:00
[INFO] - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
[ERROR] Failed to execute goal com.google.cloud.tools:appengine-maven-plugin:2.5.1:deploy (default-cli) on project app-engine: App Engine application deployment failed: com.google.cloud.tools.appengine.operations.cloudsdk.process.ProcessHandlerException: com.google.cloud.tools.appengine.AppEngineException: Non zero exit: 1 -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal com.google.cloud.tools:appengine-maven-plugin:2.5.1:deploy (default-cli) on project app-engine: App Engine application deployment failed
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
把上面的 Full build logs 網址複製到瀏覽器開啟
會得到新的detail log
FETCHSOURCE
BUILD
Starting Step #0 - "fetch"
Step #0 - "fetch": Pulling image: asia.gcr.io/gae-runtimes/utilities/gcs-fetcher:base_20231112_18_04_RC00
Step #0 - "fetch": base_20231112_18_04_RC00: Pulling from gae-runtimes/utilities/gcs-fetcher
Step #0 - "fetch": Digest: sha256:[值]
Step #0 - "fetch": Status: Downloaded newer image for asia.gcr.io/gae-runtimes/utilities/gcs-fetcher:base_20231112_18_04_RC00
Step #0 - "fetch": asia.gcr.io/gae-runtimes/utilities/gcs-fetcher:base_20231112_18_04_RC00
Step #0 - "fetch": Fetching manifest gs://staging.[專案].appspot.com/ae/[編號]/manifest.json.
Step #0 - "fetch": Processing 3 files.
Step #0 - "fetch": ******************************************************
Step #0 - "fetch": Status: SUCCESS
Step #0 - "fetch": Started: 2023–12–20T01:08:42Z
Step #0 - "fetch": Completed: 2023–12–20T01:08:43Z
Step #0 - "fetch": Requested workers: 200
Step #0 - "fetch": Actual workers: 3
Step #0 - "fetch": Total files: 3
Step #0 - "fetch": Total retries: 0
Step #0 - "fetch": GCS timeouts: 0
Step #0 - "fetch": MiB downloaded: 77.70 MiB
Step #0 - "fetch": MiB/s throughput: 154.02 MiB/s
Step #0 - "fetch": Time for manifest: 68.45 ms
Step #0 - "fetch": Total time: 0.58 s
Step #0 - "fetch": ******************************************************
Finished Step #0 - "fetch"
Starting Step #1 - "pre-buildpack"
Step #1 - "pre-buildpack": Pulling image: asia.gcr.io/gae-runtimes/buildpacks/google-gae-18/java/builder:java_20231211_RC00
Step #1 - "pre-buildpack": java_20231211_RC00: Pulling from gae-runtimes/buildpacks/google-gae-18/java/builder
( 中略 )
Step #1 - "pre-buildpack": Checking if image asia.gcr.io/[專案]/app-engine-tmp/build-cache/default/ttl-7d:latest exists
Step #1 - "pre-buildpack": Image asia.gcr.io/[專案]/app-engine-tmp/build-cache/default/ttl-7d:latest does not exist
Step #1 - "pre-buildpack": WARNING: Failed to reuse previous cache image; will not affect current build: image asia.gcr.io/[專案]/app-engine-tmp/build-cache/default/ttl-7d:latest does not exist
Finished Step #1 - "pre-buildpack"
Starting Step #2 - "build"
Step #2 - "build": Already have image (with digest): asia.gcr.io/gae-runtimes/buildpacks/google-gae-18/java/builder:java_20231211_RC00
Step #2 - "build": ===> ANALYZING
Step #2 - "build": ERROR: failed to initialize analyzer: getting previous image: getting config file for image "asia.gcr.io/[專案]/app-engine-tmp/app/default/ttl-18h:latest": GET https://storage.googleapis.com/asia.artifacts.[專案].appspot.com/containers/images/sha256:[值]?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.[專案].appspot.com/containers/images/sha256:[值]</Details></Error>
Finished Step #2 - "build"
ERROR
ERROR: build step 2 "asia.gcr.io/gae-runtimes/buildpacks/google-gae-18/java/builder:java_20231211_RC00" failed: step exited with non-zero status: 1
2 / 原因
-- 因為這次google都找不到類似問題跟解法只好自己想辦法查 --
ERROR發生點是找不到asia.gcr.io裡的資料
-> 去查詢gcr.io是什麼,結果是GCP的Artifact Registry
-> 再查詢Artifact Registry跟APP engine的關係,找到他們的共同關係人Container Registry
-> 開啟GCP控制台,到Container Registry,驚奇地(?!)發現他被deprecated了

好到這邊感覺找到原因了
APP engine背後的運作原理是他會自動把我們上傳的code做成docker image,放在Container Registry(舊版)
然後現在Container Registry被消滅惹(#),GCP叫我們要把他轉移到Artifact Registry(新版)去
如果是新建的APP engine會自動使用Artifact Registry(新版),但像我們這種舊版原本用Container Registry的專案不會自動轉,也沒有任何通知,要自己剛好上console剛好看到之後,自己手動轉移……
3 / 解法
透過以上關鍵字可以查到 GCP的migration教學 洋洋灑灑一大篇,還要下載工具、指令超級複雜,要做的事超級多, -- 而且實際跟著做之後發現他給的語法不能用什麼的 -- 讓跌跌撞撞繞完遠路的me來節省你的時間,重點只有一個--
不.要.打.指.令
- 開啟GCP控制台,到
Container Registry(可以直接在搜尋框搜尋)

- 按下
試試 ARTIFACT REGISTRY按鈕

- 跳到
Artifact Registry,按下建立 GCR.IO REPOSITORY按鈕
![這張我沒截到圖,是抓 [陳佳和] 大大的圖來加框的,來源:hackmd.io/@Momentary/r1BQAbrji](https://miro.medium.com/v2/resize:fit:1307/1*S3MUSpt69B2uok1IWMcvVg.png)
這張我沒截到圖,是抓 [陳佳和] 大大的圖來加框的,來源:hackmd.io/@Momentary/r1BQAbrji
- 等他建立好之後,會變成這樣

這時候是要按 轉送到 ARTIFACT REGISTRY ,但他不能按,滑鼠移到上面會顯示權限不足
- 到
IAM與管理(一樣可從搜尋框搜尋)

- 找到現在登入console的帳號,按下最右邊的
編輯主體 (筆)

- 按下
新增其他角色按鈕,新增Artifact Registry 管理員和Storage 管理員兩個角色後,按下儲存按鈕

- 回到
Artifact Registry,這時候轉送到 ARTIFACT REGISTRY按鈕會亮起,就可以按他

- 按完等他處理,處理完會變成這樣,就完成了!!!

- 回到PROJECT code,重新
mvn clean package appengine:deploy

成功!!! (感人QQQ)🥺
5 / 抱怨
雖然公雲有不用自己管硬體的優點,但相對地變成是當雲端服務變更的時候,我們程式工程師要自己去修改來適應他的變更,那其實也沒有比較方便 而且可怕的是他會說他幫你把後端像黑盒子包起來一樣不用去管,但如果你真的照他的話不去管,就會像我這次一樣陷入困境 😵
簡單舉個例像這種情況,表面上我用的是APP engine服務,我只要會寫code,會用plugin上傳更新就可以 但如果遇到GCP他自己後端組件改了也不會通知我,只會讓我直接就更新失敗,求救無門 🆘 然後由於我沒去研究他黑盒子裡用了什麼組件,也不會知道他是因為deploy組件被deprecated,不會知道需要自己手動去做一系列的移轉 (活生生血淋淋的例子)
推公雲的說詞都是「把伺服器交給雲端代管,工程師可以專注在功能面上」 曾以為是多麼美好的幻想 ,現在看來就真的只是幻想而已 實際上是把「架設管理伺服器」的工作換成「設定介接伺服器」而已,並沒有比較輕鬆……他會是他自家獨有的設定,沒什麼資料可以參考, 而且比地端實體設備更麻煩的點是,他會不管你的需求意願自顧自地更新,然後你只能無條件配合 😢
如果今天這是一個架在實體自管伺服器上的服務,只要你不去改,他們就不會變,就能持續運作 (看我前輩那些15歲歲的無框架程式碼,2023還在用純手刻JAVA8跟JBOSS EAP 7,一樣活得頭好壯壯 💪) 但放在GCP的專案,可能你上個月還在開開心心的上傳,這個月突然就更新失敗,而且不會告訴你失敗原因是什麼、要做什麼才能讓他成功,你得自己一層一層抽絲剝繭地去找,可能還得用點通靈能力…… 🧙🪄
測試Google收文用的新文連結:
[embed]24 - GCP:下載Cloud Storage Bucket的文字檔 你的下載不是我的下載medium.com
[embed]22 - Azure證照:AZ-900考試心得 (2024年8月) Microsoft Certified: Azure Fundamentalsmedium.com
[embed]23 - Azure證照:AI-900考試心得 (2025年1月) Microsoft Certified: Azure AI Fundamentalsmedium.com
메타데이터
- post_id
- ea1924065bfe
- slug
- 19-gcp-app-engine-轉移container-registry-artifact-registry-ea1924065bfe
- url
- https://medium.com/@LOTTE17/19-gcp-app-engine-%E8%BD%89%E7%A7%BBcontainer-registry-artifact-registry-ea1924065bfe
- canonical_url
- https://medium.com/@LOTTE17/19-gcp-app-engine-%E8%BD%89%E7%A7%BBcontainer-registry-artifact-registry-ea1924065bfe
- author_url
- https://medium.com/@LOTTE17
- status
- ok
- fetched_at
- 2026-07-24 15:01:39