fix(lambda): return X-Amz-Log-Result for buffered Invoke with LogType=Tail#1931
Merged
Conversation
…=Tail A synchronous Invoke with LogType=Tail must return the base64 of the last 4 KiB of the invocation's logs in X-Amz-Log-Result (the SDK's LogResult). The buffered RequestResponse path never set it — only the streaming eventstream path carried the field, and even there it was always empty. So test harnesses and the AWS CLI's --log-type Tail got nothing. Adds a per-instance log-capture hook to the runtime backend trait (instance_logs): the docker/podman backend tails `docker logs`, the k8s backend fetches the Pod's logs via the kube API. invoke_inner optionally captures the instance's log tail while the slot is still held; the buffered handler, when LogType=Tail, base64s the last 4 KiB into X-Amz-Log-Result. E2E (Docker-gated): a function prints a marker to stdout; invoking with LogType=Tail returns a LogResult that decodes to contain it.
The new invoke_with_log_type_tail_returns_log_result test runs a python3.12 function, so the e2e partition coverage check requires it to be enumerated in a lambda_invoke partition. Add it to the python runtime-family filter (matching test_invoke_warm_start and the other non-runtime python tests).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary (1.20)
A synchronous
InvokewithLogType=Tailmust return the base64 of the last 4 KiB of the invocation's logs inX-Amz-Log-Result(the SDK'sLogResult). The bufferedRequestResponsepath never set it — only the streaming eventstream path carried the field, and even there it was always empty. Soaws lambda invoke --log-type Tailand test harnesses got nothing.Adds a per-instance log-capture hook to the runtime backend trait (
instance_logs): the docker/podman backend tailsdocker logs, the k8s backend fetches the Pod's logs via the kube API.invoke_inneroptionally captures the instance's log tail while the slot is still held; the buffered handler, whenLogType=Tail, base64s the last 4 KiB intoX-Amz-Log-Result. The other ~22invokecallers are unchanged (they go through the no-capture wrapper).Non-code surface
No new API surface — fills in a documented response header. No SDK/docs/metadata change applies (checked).
Test plan
invoke_with_log_type_tail_returns_log_result: a function prints a marker;InvokewithLogType=Tailreturns aLogResultdecoding to contain it.cargo test -p fakecloud-lambda --lib(207) passes; clippy clean.Summary by cubic
Fixes buffered Lambda Invoke so
X-Amz-Log-Resultis returned forLogType=Tail, base64-encoding the last 4 KiB of the function logs. Works for both Docker and Kubernetes backends via per-instance log capture.X-Amz-Log-Resultfor synchronousInvokewithLogType=Tail(last 4 KiB, base64).instance_logsbackend hook; Docker tailsdocker logs, K8s reads Pod logs via the kube API.Written for commit b2e9b6c. Summary will update on new commits.