建置除錯
使用疑難排解提示來瞭解如何對 IBM Cloud® Code Engine 建置及執行您的建置進行疑難排解。
不論您是在主控台或 CLI 中執行建置,請使用 CLI 來疑難排解您的建置問題。
- 執行
ibmcloud ce buildrun get --name BUILDRUN_NAME指令,以顯示建置執行的詳細資料。 - 檢閱指令輸出中的
Reason。
當您建置的行為不符合預期時,查看日誌和系統事件可以提供資訊來協助您對問題進行除錯。
要考量的建置限制
每個專案可以擁有的建置配置數目上限為 100。 在您需要移除或清除舊專案之前,每個專案的建置執行總數限制為 100 個。
如需包括記憶體和 CPU 之建置限制的相關資訊,請參閱 Code Engine。
使用 CLI,您可以使用 ibmcloud ce project get 指令來顯示限制及現行使用情形的相關資訊。 例如:
ibmcloud ce project create --name myproject
輸出範例
Getting project 'myproject'...
OK
Name: myproject
ID: abcdabcd-abcd-abcd-abcd-f1de4aab5d5d
Status: active
Enabled: true
Application Private Visibility Supported: true
Selected: true
Region: us-south
Resource Group: default
Service Binding Service ID: ServiceId-1234abcd-abcd-abcd-1111-1a2b3c4d5e6f
Age: 52d
Created: Tue, 28 Sep 2021 05:12:16 -0500
Updated: Tue, 28 Sep 2021 05:12:19 -0500
Quotas:
Category Used Limit
App revisions 2 120
Apps 1 40
Build runs 1 100
Builds 2 100
Configmaps 2 100
CPU 0 128
Ephemeral storage 0 512G
Functions 0 20
Instances (active) 0 250
Instances (total) 0 2500
Job runs 13 100
Jobs 2 100
Memory 0 512G
Secrets 6 100
Subscriptions (cron) 0 100
Subscriptions (IBM Cloud Object Storage) 0 100
Subscriptions (Kafka) 0 100
取得我的建置的日誌
當您執行建置時,日誌有助於疑難排解問題。 您可以使用 CLI 或主控台來檢視建置的日誌。
從主控台取得我的建置的日誌
您可以從主控台顯示特定建置執行實例的日誌。
- 移至 Code Engine 儀表板。
- 選取專案 (或 建立一個)。
- 從專案頁面中,按一下 映像檔建置。
- 從 映像檔建置 標籤中,按一下映像檔建置的名稱,以開啟所定義建置的建置頁面,或 建立建置。
- 從您所定義建置的建置頁面中,按一下 建置執行 區段中的建置執行實例名稱。 您可能需要按一下 提交建置,以建立建置執行。
- 從建置執行實例頁面中,您可以檢視建置日誌資訊。 展開特定的建置步驟,以取得詳細記載資訊。
如需相關資訊,請參閱 從主控台檢視建置日誌。
使用 CLI 取得我的建置的日誌
使用 ibmcloud ce buildrun logs 指令來顯示建置執行的相關日誌。 請使用這個指令,根據建置執行的名稱來顯示建置執行所有實例的日誌。
如果要檢視 mybuildrun 建置執行的所有實例的日誌,請使用 --name 選項指定建置執行的名稱; 例如,
ibmcloud ce buildrun logs --name mybuildrun
輸出範例
Getting build run 'mybuildrun'...
Getting instances of build run 'mybuildrun'...
Getting logs for build run 'mybuildrun'...
OK
mybuildrun-bvzbg-pod-tppvg/step-source-default:
2021/09/21 09:39:08 Info: ssh (/usr/bin/ssh): OpenSSH_8.0p1, OpenSSL 1.1.1g FIPS 21 Apr 2020
2021/09/21 09:39:08 Info: git (/usr/bin/git): git version 2.27.0
2021/09/21 09:39:08 Info: git-lfs (/usr/bin/git-lfs): git-lfs/2.11.0 (GitHub; linux amd64; go 1.14.4)
2021/09/21 09:39:08 /usr/bin/git clone --quiet --no-tags --branch main --depth 1 --single-branch -- https://github.com/IBM/CodeEngine /workspace/source
2021/09/21 09:39:09 /usr/bin/git -C /workspace/source submodule update --init --recursive --depth 1
2021/09/21 09:39:10 /usr/bin/git -C /workspace/source rev-parse --abbrev-ref HEAD
2021/09/21 09:39:10 Successfully loaded https://github.com/IBM/CodeEngine (main) into /workspace/source
2021/09/21 09:39:10 /usr/bin/git -C /workspace/source rev-parse --verify HEAD
mybuildrun-bvzbg-pod-tppvg/step-build-and-push:
INFO[0000] Retrieving image manifest golang:alpine
INFO[0000] Retrieving image golang:alpine from registry index.docker.io
INFO[0001] Retrieving image manifest alpine
INFO[0001] Retrieving image alpine from registry index.docker.io
INFO[0003] Built cross stage deps: map[0:[/codeengine]]
INFO[0003] Retrieving image manifest golang:alpine
INFO[0003] Returning cached image manifest
INFO[0003] Executing 0 build triggers
INFO[0003] Unpacking rootfs as cmd COPY ./helloworld /helloworld requires it.
INFO[0009] COPY ./helloworld /helloworld
INFO[0009] Taking snapshot of files...
INFO[0009] COPY codeengine.go /
INFO[0009] Taking snapshot of files...
INFO[0009] RUN go build -o /codeengine /codeengine.go
INFO[0009] Taking snapshot of full filesystem...
INFO[0017] cmd: /bin/sh
INFO[0017] args: [-c go build -o /codeengine /codeengine.go]
INFO[0017] Running: [/bin/sh -c go build -o /codeengine /codeengine.go]
INFO[0018] Taking snapshot of full filesystem...
INFO[0018] Saving file codeengine for later use
INFO[0018] Deleting filesystem...
INFO[0019] Retrieving image manifest alpine
INFO[0019] Returning cached image manifest
INFO[0019] Executing 0 build triggers
INFO[0019] Unpacking rootfs as cmd COPY --from=0 /codeengine /codeengine requires it.
INFO[0019] COPY --from=0 /codeengine /codeengine
INFO[0019] Taking snapshot of files...
INFO[0019] CMD /codeengine
INFO[0019] Pushing image to us.icr.io/acme-namespace/codeengine-sample
INFO[0023] Pushed image to 1 destinations
取得我的建置的系統事件資訊
當您執行建置時,系統事件資訊有助於疑難排解問題。 您可以使用 CLI 來檢視建置的系統事件資訊。
-
使用
ibmcloud ce buildrun list指令來列出專案中的所有建置執行; 例如,ibmcloud ce buildrun list -
使用
ibmcloud ce buildrun get指令來取得建置執行的詳細資料,例如:ibmcloud ce buildrun get --name mybuildrun輸出範例
Getting build run 'mybuildrun'... Run 'ibmcloud ce buildrun events -n mybuildrun' to get the system events of the build run. Run 'ibmcloud ce buildrun logs -f -n mybuildrun' to follow the logs of the build run. OK Name: mybuilddrun [...] Created: 2021-06-01T11:43:24-04:00 Summary: Succeeded Status: Succeeded Reason: All Steps have completed executing Image: us.icr.io/mynamespace/codeengine-codeengine-200如果您想要更精細的建置執行詳細資料,請在
buildrun get指令中使用--o yaml選項; 例如ibmcloud ce buildrun get --name myapp --o yaml。 此選項有助於在 CLI 中顯示建置執行的更詳細資訊。 -
顯示建置運行的系統事件。 使用
ibmcloud ce buildrun events指令; 例如,ibmcloud ce buildrun events --name mybuildrun輸出範例
Getting build run 'mybuildrun'... Getting instances of build run 'mybuildrun'... Getting events for build run 'mybuildrun'... OK mybuildrun-bvzbg-pod-tppvg: Type Reason Age Source Messages Normal Scheduled 4m43s default-scheduler Successfully assigned 62ckpsxlh7x/mybuildrun-bvzbg-pod-tppvg to 10.242.0.17 Normal Pulled 4m42s kubelet, 10.242.0.17 Container image "icr.io/obs/codeengine/tekton-pipeline/entrypoint-bff0a22da108bc2f16c818c97641a296:v0.23.0-rc6@sha256:43dd56a6c7c10f80300a861615f6f8d91c026deba744f81553a4e536b301b322" already present on machine Normal Created 4m42s kubelet, 10.242.0.17 Created container place-tools Normal Started 4m41s kubelet, 10.242.0.17 Started container place-tools Normal Pulled 4m40s kubelet, 10.242.0.17 Container image "icr.io/obs/codeengine/git:v0.8.100" already present on machine Normal Created 4m40s kubelet, 10.242.0.17 Created container step-source-default Normal Started 4m40s kubelet, 10.242.0.17 Started container step-source-default Normal Pulled 4m40s kubelet, 10.242.0.17 Container image "icr.io/obs/codeengine/buildkit/builder:v0.9.0-rc.19" already present on machine Normal Created 4m40s kubelet, 10.242.0.17 Created container step-build-and-push Normal Started 4m40s kubelet, 10.242.0.17 Started container step-build-and-push事件只會在系統中儲存一小時。