render: StartFunctionRuntimes leaks already-started Function containers when a later Function fails to start
维护者通常 4 天内回复
评估
调研方向
Start in cmd/crossplane/render/render.go at StartFunctionRuntimes, then inspect the error handling in xr/cmd.go and op/cmd.go. Reproduce with the supplied xr.yaml, composition.yaml, and functions.yaml, and verify that a later startup failure stops earlier runtimes and removes the attached network instead of leaving containers running.
由索引模型根据 Issue 内容生成。
描述
What happened?
When one Function fails to start, every Function started before it is left running and nothing ever stops
it.
StartFunctionRuntimes
starts Functions in order. If Function N fails (for example its image can't be pulled), it returns
nil, err. Functions 1..N-1 are already running, but their RuntimeContexts are dropped with the partial
FunctionAddresses, so no caller can stop them. In xr/cmd.go and op/cmd.go the
defer render.StopFunctionRuntimes(...) comes after the error check, so it is never registered.
Expected: if StartFunctionRuntimes returns an error, any runtime it already started has been stopped
according to its cleanup policy — or the partial result is returned so the caller can stop it.
This affects library consumers as well as the render commands: any caller of StartFunctionRuntimes has
the same gap.
How can we reproduce it?
xr.yaml:
apiVersion: example.org/v1
kind: XThing
metadata:
name: test-xr
spec:
coolField: hello
composition.yaml — any pipeline referencing the three Functions below, e.g.:
apiVersion: apiextensions.crossplane.io/v1
kind: Composition
metadata:
name: xthings.example.org
spec:
compositeTypeRef: {apiVersion: example.org/v1, kind: XThing}
mode: Pipeline
pipeline:
- step: templating
functionRef: {name: function-go-templating}
input:
apiVersion: gotemplating.fn.crossplane.io/v1beta1
kind: GoTemplate
source: Inline
inline:
template: |
apiVersion: nop.crossplane.io/v1alpha1
kind: NopResource
metadata:
annotations: {gotemplating.fn.crossplane.io/composition-resource-name: nop}
spec: {forProvider: {}}
- step: dummy
functionRef: {name: function-dummy}
input: {apiVersion: dummy.fn.crossplane.io/v1beta1, kind: Response, response: {}}
- step: auto-ready
functionRef: {name: function-auto-ready}
functions.yaml — the last Function's tag has no manifest, so its pull fails:
apiVersion: pkg.crossplane.io/v1
kind: Function
metadata: {name: function-go-templating}
spec: {package: xpkg.crossplane.io/crossplane-contrib/function-go-templating:v0.11.0}
---
apiVersion: pkg.crossplane.io/v1
kind: Function
metadata: {name: function-dummy}
spec: {package: xpkg.crossplane.io/crossplane-contrib/function-dummy:v0.4.1}
---
apiVersion: pkg.crossplane.io/v1
kind: Function
metadata: {name: function-auto-ready}
spec: {package: xpkg.crossplane.io/crossplane-contrib/function-auto-ready:v0.1.2}
$ crossplane render xr.yaml composition.yaml functions.yaml
crossplane: error: cannot start function runtimes: cannot start Function "function-auto-ready": cannot pull Docker image "xpkg.crossplane.io/crossplane-contrib/function-auto-ready:v0.1.2": Error response from daemon: manifest unknown
$ docker ps --format '{{.Names}} {{.Image}} {{.Status}}' | grep function-
suspicious_newton xpkg.crossplane.io/crossplane-contrib/function-dummy:v0.4.1 Up 9 seconds
distracted_mestorf xpkg.crossplane.io/crossplane-contrib/function-go-templating:v0.11.0 Up 13 seconds
Both containers use the default cleanup policy (Remove) and stay running indefinitely. The run's
crossplane-render-* network is also left behind, because its removal fails while these containers are
attached and the error is discarded (#398).
Possible fix: on error, stop the runtimes started so far before returning (e.g. build the
FunctionAddresses as you go and call Stop on it in the error path), or return the partial
*FunctionAddresses alongside the error and document that callers must stop it.
What environment did it happen in?
- Crossplane CLI version: built from
main@29316fea54f2ede9d2c039d9c54f0c29cbad4b65 - Platform (e.g., linux/amd64): darwin/arm64, Docker Engine 29.5.3 (Rancher Desktop)
- Crossplane version (if applicable): render engine image
xpkg.crossplane.io/crossplane/crossplane:stable
- 主要语言
- Go
- 星标
- 22
- 派生
- 38
- 平均合并
- 3 天 14 小时
- 30 天内合并 PR
- 46
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
crossplane/cli 的其他 Issue
-
[project/schemas]: enum integers Valid() function is missing values可能已有人在做 @NopeCharon 于 7 天前认领。 未关闭bug
难度 2/5 1-3 小时 新手友好度 82/100
crossplane/cli#445 ·
维护者通常 4 天内回复
-
- In Podman 6.x, the {{.Labels}} template field comes out as a flat string (k=v,k=v) instead of a map, so index .Labels "<key>" can't work.可能已有人在做 @prath47 于 6 天前认领。 未关闭bug
难度 2/5 1-3 小时 新手友好度 72/100
crossplane/cli#432 ·
维护者通常 4 天内回复
-
`credsStore` in docker config causes unit test failures可能已有人在做 @sujeito-operator 于 76 天前认领。 未关闭bug
难度 2/5 1-3 小时 新手友好度 84/100
crossplane/cli#282 ·
维护者通常 4 天内回复
-
`Render` leaks containers from killed runs and has no multi-render lifecycle可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭bug
难度 5/5 一周以上 新手友好度 12/100
crossplane/cli#490 ·
维护者通常 4 天内回复
-
[project/schemas]: go types contains conflicting code if two xrd's in same api-group has integer enum field可能已有人在做 @NopeCharon 于 7 天前认领。 未关闭bug
难度 3/5 1-2 天 新手友好度 72/100
crossplane/cli#444 · 1 条评论 ·
维护者通常 4 天内回复
相似的 Issue
-
area:sampler tech-debt
难度 2/5 1-3 小时 新手友好度 72/100
jmbarzee/temporal-architect#302 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 66/100
riverqueue/river#1576 ·
维护者通常 1 天内回复
-
NFS StorageProvider renders a missing nfsSubDir as "<no value>"可能已有人在做 @ldming 今天认领。 未关闭kind/bug
难度 2/5 1-3 小时 新手友好度 82/100
apecloud/kubeblocks#11067 ·
维护者通常 1 天内回复
-
area:ui bug priority:low
难度 2/5 1-3 小时 新手友好度 62/100
维护者通常 1 天内回复
-
RTX payload type is not found when the RTX fmtp line has rtx-time可能已有人在做 @RaphaelFakhri 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 82/100
维护者通常 1 天内回复