Custom Container functions depend on resources that Function Compute reserves on your behalf, including images cached from Alibaba Cloud Container Registry (ACR) to reduce cold start latency. Because image caching happens asynchronously in the background, a function may not be ready to handle invocations immediately after it is created or updated. Function states tell you exactly when a function is ready to invoke.
Function states
Function Compute assigns every Custom Container function one of the following states.
| State | Invocable | Description |
|---|---|---|
| Pending | No | The initial state after a function is created. Function Compute is reserving resources and caching the image. Transitions to Active when the image is ready. |
| Active | Yes | Resource reservation is complete. The function handles invocations normally. |
| Failed | No | Resource preparation or image access encountered an error. See Failed state for recovery steps. |
| Inactive | No | The function was idle long enough for Function Compute to release its cached resources. Redeploy or trigger the function to return it to Pending. If resource preparation succeeds, the function returns to Active; otherwise, it remains Inactive. |
Failed state
A function enters the Failed state in two situations:
Resource preparation failed during creation or update: The function cannot be invoked because an issue occurred during resource preparation.
Original image is no longer accessible: Function Compute caches images to speed up cold starts, but the original image in ACR must remain accessible during invocations. If the image is deleted or the tag is overwritten with a different digest, the function enters the Failed state. Update the function with valid image information and redeploy.
Function Compute records both the tag and the digest of the image version you select when you create or update a function. If that digest is later overwritten in ACR, the function fails to invoke. Make sure image tags are not overwritten after deployment. If overwritten, redeploy the function using the most recent image information.
Update states
While a function update is in progress, the LastUpdateStatus field tracks the update separately from the function's main state.
LastUpdateStatus | Description | Invocation routing |
|---|---|---|
InProgress | Function Compute is preparing resources for the update. | Directed to the pre-update code |
Successful | The update completed. | Directed to the updated code |
Failed | Resource preparation for the update failed. | Directed to the pre-update code |
Check state before invoking
You can call the GetFunction operation to obtain the state and image digest of a function. If you use an SDK or Serverless Devs to create or update a Custom Container function, call the GetFunction operation to verify the function state before invoking.
Newly created functions: confirm the state is
Active. Functions in other states cannot be invoked.Updated functions: confirm
LastUpdateStatusisSuccessful.
State diagrams
The following output shows the s3 info result for a newly created function in the Pending state (Function Compute is reserving resources and caching the image).
s3 info
Steps for [info] of [hello-world-app]
====================
✔ [hello_world] completed (3.68s)
Result for [info] of [hello-world-app]
====================
hello_world:
region: us-east-1
codeChecksum:
codeSize: 0
cpu: 0.5
createdTime: 2023-10-27T06:56:00Z
customContainerConfig:
image: registry.us-east-1.aliyuncs.com/fxxx2/flask_xxx_ask_v001
resolvedImageUri: registry.us-east-1.aliyuncs.com/fc-dxxx_ask@shaxxx9e19867xxx23c4xxx78ffxxx4116cd9xxx9cde7370b43dd889
description: hello world by serverless devs
diskSize: 512
functionArn: acs:fc:us-east-1:143*********149:functions/start-python-xxx:3
functionId: b24c69ed-0xxx-xxx-5ff3f51c4190
functionName: start-pxxx_xilixxx_est3
handler: handler
instanceConcurrency: 1
internetAccess: true
lastModifiedTime: 2023-10-27T06:56:00Z
memorySize: 512
role:
runtime: custom-container
state: Pending
stateReason: The function is being created.
stateReasonCode: Creating
timeout: 60
A complete log of this run can be found in: /home/admin/.s/logs/1027145606The following output shows the s3 info result for a function being updated (LastUpdateStatus: InProgress).
admin ~/workspace/xxx/demo-3 s3 info
Steps for [ixxx-app]
========================
✔ [hello_world] completed (4.97s)
Result for [info] of [hello-world-app]
========================
hello_world:
region: us-east-1
codeChecksum:
codeSize: 0
cpu: 0.5
createdTime: 2023-10-27T05:45:30Z
customContainerConfig:
image: registry.us-east-1.aliyuncs.comxxx k:f k_vxxx
resolvedImageUri: registry.us-east-1.aliyuncs.com/fcxxx k@sha256:f65d0acd5xxx ab9cd923f3afxxx b9exxx 2cdxxx 99d51bbae2fe0ba
description: hello world by serverless devs
diskSize: 512
functionArn: acs:fc:us-east-1:143**********149:functions/start-pxxx xilxxx
functionId: 82597d19xxx f-9581fe2429d7
functionName: start-pythonxxx t1
handler: handler
instanceConcurrency: 1
internetAccess: true
lastModifiedTime: 2023-10-27T06:52:03Z
lastUpdateStatus: InProgress
memorySize: 512
role:
runtime: custom-container
state: Active
timeout: 60
A complete log of this run can be found in: /home/admin/.s/logs/xxx5200The following output shows the s3 info result after a successful update. When lastUpdateStatus is Successful and state is Active, the function update has completed and the function is in the active state.
admin ~/wc xxx mo-3 s3 info
Steps for [info] of [hello-world-app]
====================
✔ [hello_world] completed (1.32s)
Result for [info] of [hello-world-app]
====================
hello_world:
region: us-east-1
codeChecksum:
codeSize: 0
cpu: 0.5
createdTime: 2023-10-27T05:45:30Z
customContainerConfig:
image: registry.us-east-1.aliyuncs.com,xxx/flask:flask_v001
resolvedImageUri: registry.us-east-1.aliyuncs.com,xxx/mo2/flask@sha256:9614366c50xxx4bcxxxxxxxxxxxxxxxx/cae95c74f44
description: hello world by serverless dexxx
diskSize: 512
functionArn: acs:fc:us-east-1:xxx:49:functions/start-pyxxxxxxxx
functionId: 82597d19-2bc0-41c3-92f1-xxx429d7
functionName: start-pyxxx-n-xxxxxx1
handler: handler
instanceConcurrency: 1
internetAccess: true
lastModifiedTime: 2023-10-27T05:56:10Z
lastUpdateStatus: Successful
logConfig:
enableInstanceMetrics: true
enableRequestMetrics: true
logBeginRule: DefaultRegex
logstore: function-log
project: aliyun-fc xxx0908f0a5f
memorySize: 512
role:
runtime: custom-container
state: Active
timeout: 60
A complete log of this run can be found in: /home/admin/.s/logs/xxx