Repository navigation
Description
Description
We have observed cases where UpdateContainerResources on the containerd-shim for a specific pod gets hung up. In our case we have a number of job pods being created around the same time and kubelet was setting cpuset on an init container (istio-proxy).
When this occurs rather than just impacting/delaying initialization of that particular pod we see that all calls to containerd get stuck on a lock in the cri store.
Would it be possible to only take the write lock on the store when actually updating the state of the store rather than blocking on the containerd shim update?
Unfortunately we can't see where the shim is blocked as pprof is not supported in containerd shim in 1.7.
Steps to reproduce the issue
We repro this consistently in an AKS cluster running ~60 pods per node with istio native sidecars enabled which adds an extra init container. We don't have a repro outside of our main test environment at the moment.
Describe the results you received and expected
Stack of UpdateContainerResources:
goroutine 44180 [select, 5 minutes]:
[github.com/containerd/ttrpc.(*Client).dispatch(0xc00451f5f0](http://github.com/containerd/ttrpc.(*Client).dispatch(0xc00451f5f0), {0x55d9c9c4fdc8, 0xc004a50120}, 0xc000101000?, 0xc007ccfe60?)
[github.com/containerd/[email protected]/client.go:545](http://github.com/containerd/[email protected]/client.go:545) +0x1ac
[github.com/containerd/ttrpc.defaultClientInterceptor({0x55d9c9c4fdc8](http://github.com/containerd/ttrpc.defaultClientInterceptor(%7B0x55d9c9c4fdc8)?, 0xc004a50120?}, 0x55d9caa00b60?, 0xc005f9d500?, 0x55d9c9ad1ae0?, 0xc003716270?)
[github.com/containerd/[email protected]/interceptor.go:56](http://github.com/containerd/[email protected]/interceptor.go:56) +0x22
[github.com/containerd/ttrpc.(*Client).Call(0xc00451f5f0](http://github.com/containerd/ttrpc.(*Client).Call(0xc00451f5f0), {0x55d9c9c4fdc8, 0xc004a50120}, {0x55d9c9543467, 0x17}, {0x55d9c9521f75, 0x6}, {0x55d9c9b02660?, 0xc001a55400?}, {0x55d9c9a64d00, ...})
[github.com/containerd/[email protected]/client.go:173](http://github.com/containerd/[email protected]/client.go:173) +0x343
[github.com/containerd/containerd/api/runtime/task/v2.(*taskClient).Update(0xc00388e790](http://github.com/containerd/containerd/api/runtime/task/v2.(*taskClient).Update(0xc00388e790), {0x55d9c9c4fdc8, 0xc004a50120}, 0xc001992000?)
[github.com/containerd/containerd/[email protected]/runtime/task/v2/shim_ttrpc.pb.go:265](http://github.com/containerd/containerd/[email protected]/runtime/task/v2/shim_ttrpc.pb.go:265) +0x92
[github.com/containerd/containerd/runtime/v2.(*shimTask).Update(0xc001588a20](http://github.com/containerd/containerd/runtime/v2.(*shimTask).Update(0xc001588a20), {0x55d9c9c4fdc8, 0xc004a50120}, 0xc001a552c0, 0x0)
[github.com/containerd/containerd/runtime/v2/shim.go:686](http://github.com/containerd/containerd/runtime/v2/shim.go:686) +0xc5
[github.com/containerd/containerd/services/tasks.(*local).Update(0x55d9c9c42c98](http://github.com/containerd/containerd/services/tasks.(*local).Update(0x55d9c9c42c98)?, {0x55d9c9c4fdc8, 0xc004a50120}, 0xc001a55270, {0x0?, 0xc003716420?, 0x55d9c829e245?})
[github.com/containerd/containerd/services/tasks/local.go:630](http://github.com/containerd/containerd/services/tasks/local.go:630) +0x59
[github.com/containerd/containerd.(*task).Update(0xc007f5f600](http://github.com/containerd/containerd.(*task).Update(0xc007f5f600), {0x55d9c9c4fdc8, 0xc004a50120}, {0xc00388e788, 0x1, 0x0?})
[github.com/containerd/containerd/task.go:563](http://github.com/containerd/containerd/task.go:563) +0x192
[github.com/containerd/containerd/pkg/cri/server.(*criService).updateContainerResources(_](http://github.com/containerd/containerd/pkg/cri/server.(*criService).updateContainerResources(_), {_, _}, {{{0xc00236b940, 0x40}, {0xc000ee2e40, 0x5e}, {0xc005ecfa00, 0x40}, 0xc000d95b30, ...}, ...}, ...)
[github.com/containerd/containerd/pkg/cri/server/container_update_resources.go:133](http://github.com/containerd/containerd/pkg/cri/server/container_update_resources.go:133) +0x65f
[github.com/containerd/containerd/pkg/cri/server.(*criService).UpdateContainerResources.func1({0x7169d](http://github.com/containerd/containerd/pkg/cri/server.(*criService).UpdateContainerResources.func1(%7B0x7169d), 0x17ea2ed12592f587, 0x17ea2ed12a8d9965, 0x0, 0x0, {0x0, 0x0}, {0x0, 0x0}, 0x0, ...})
[github.com/containerd/containerd/pkg/cri/server/container_update_resources.go:63](http://github.com/containerd/containerd/pkg/cri/server/container_update_resources.go:63) +0xfb
[github.com/containerd/containerd/pkg/cri/store/container.(*statusStorage).UpdateSync(0xc004000c00](http://github.com/containerd/containerd/pkg/cri/store/container.(*statusStorage).UpdateSync(0xc004000c00), 0xc004a50150) --> Takes lock
[github.com/containerd/containerd/pkg/cri/store/container/status.go:265](http://github.com/containerd/containerd/pkg/cri/store/container/status.go:265) +0x136
[github.com/containerd/containerd/pkg/cri/server.(*criService).UpdateContainerResources(0xc0003aaa00](http://github.com/containerd/containerd/pkg/cri/server.(*criService).UpdateContainerResources(0xc0003aaa00), {0x55d9c9c4fdc8?, 0xc004a50120}, 0xc003c0ff20)
[github.com/containerd/containerd/pkg/cri/server/container_update_resources.go:62](http://github.com/containerd/containerd/pkg/cri/server/container_update_resources.go:62) +0x4f0
[github.com/containerd/containerd/pkg/cri/instrument.(*instrumentedService).UpdateContainerResources(0xc0004fcd70](http://github.com/containerd/containerd/pkg/cri/instrument.(*instrumentedService).UpdateContainerResources(0xc0004fcd70), {0x55d9c9c4fdc8?, 0xc003c0fef0}, 0xc003c0ff20)
[github.com/containerd/containerd/pkg/cri/instrument/instrumented_service.go:935](http://github.com/containerd/containerd/pkg/cri/instrument/instrumented_service.go:935) +0x258
[k8s.io/cri-api/pkg/apis/runtime/v1._RuntimeService_UpdateContainerResources_Handler.func1({0x55d9c9c4fdc8](http://k8s.io/cri-api/pkg/apis/runtime/v1._RuntimeService_UpdateContainerResources_Handler.func1(%7B0x55d9c9c4fdc8), 0xc003c0fef0}, {0x55d9c9bb6d80?, 0xc003c0ff20})
[k8s.io/[email protected]/pkg/apis/runtime/v1/api.pb.go:10953](http://k8s.io/[email protected]/pkg/apis/runtime/v1/api.pb.go:10953) +0x75
[github.com/containerd/containerd/services/server.unaryNamespaceInterceptor({0x55d9c9c4fdc8](http://github.com/containerd/containerd/services/server.unaryNamespaceInterceptor(%7B0x55d9c9c4fdc8), 0xc003c0fef0}, {0x55d9c9bb6d80, 0xc003c0ff20}, 0xc0004a0388?, 0xc0052590b0)
[github.com/containerd/containerd/services/server/namespace.go:31](http://github.com/containerd/containerd/services/server/namespace.go:31) +0x65
[github.com/containerd/containerd/services/server.New.ChainUnaryServer.func6.1.1({0x55d9c9c4fdc8](http://github.com/containerd/containerd/services/server.New.ChainUnaryServer.func6.1.1(%7B0x55d9c9c4fdc8)?, 0xc003c0fef0?}, {0x55d9c9bb6d80?, 0xc003c0ff20?})
[github.com/grpc-ecosystem/[email protected]/chain.go:25](http://github.com/grpc-ecosystem/[email protected]/chain.go:25) +0x37
[github.com/grpc-ecosystem/go-grpc-prometheus.init.(*ServerMetrics).UnaryServerInterceptor.func3({0x55d9c9c4fdc8](http://github.com/grpc-ecosystem/go-grpc-prometheus.init.(*ServerMetrics).UnaryServerInterceptor.func3(%7B0x55d9c9c4fdc8), 0xc003c0fef0}, {0x55d9c9bb6d80, 0xc003c0ff20}, 0x55d9c9a259c0?, 0xc001cc6fe0)
[github.com/grpc-ecosystem/[email protected]/server_metrics.go:107](http://github.com/grpc-ecosystem/[email protected]/server_metrics.go:107) +0x83
[github.com/containerd/containerd/services/server.New.ChainUnaryServer.func6.1.1({0x55d9c9c4fdc8](http://github.com/containerd/containerd/services/server.New.ChainUnaryServer.func6.1.1(%7B0x55d9c9c4fdc8)?, 0xc003c0fef0?}, {0x55d9c9bb6d80?, 0xc003c0ff20?})
[github.com/grpc-ecosystem/[email protected]/chain.go:25](http://github.com/grpc-ecosystem/[email protected]/chain.go:25) +0x37
[github.com/containerd/containerd/services/server.New.ChainUnaryServer.func6({0x55d9c9c4fdc8](http://github.com/containerd/containerd/services/server.New.ChainUnaryServer.func6(%7B0x55d9c9c4fdc8), 0xc003c0fef0}, {0x55d9c9bb6d80, 0xc003c0ff20}, 0xc0074bb9f8?, 0x55d9c99acc40?)
[github.com/grpc-ecosystem/[email protected]/chain.go:34](http://github.com/grpc-ecosystem/[email protected]/chain.go:34) +0xb5
[k8s.io/cri-api/pkg/apis/runtime/v1._RuntimeService_UpdateContainerResources_Handler({0x55d9c9bf6ea0](http://k8s.io/cri-api/pkg/apis/runtime/v1._RuntimeService_UpdateContainerResources_Handler(%7B0x55d9c9bf6ea0)?, 0xc0004fcd70}, {0x55d9c9c4fdc8, 0xc003c0fef0}, 0xc005257300, 0xc000115380)
[k8s.io/[email protected]/pkg/apis/runtime/v1/api.pb.go:10955](http://k8s.io/[email protected]/pkg/apis/runtime/v1/api.pb.go:10955) +0x135
[google.golang.org/grpc.(*Server).processUnaryRPC(0xc000268000](http://google.golang.org/grpc.(*Server).processUnaryRPC(0xc000268000), {0x55d9c9c4fdc8, 0xc003c0fe00}, {0x55d9c9c58ce0, 0xc0014e6820}, 0xc0004a2120, 0xc0008ac090, 0x55d9ca978380, 0x0)
[google.golang.org/[email protected]/server.go:1343](http://google.golang.org/[email protected]/server.go:1343) +0xe03
[google.golang.org/grpc.(*Server).handleStream(0xc000268000](http://google.golang.org/grpc.(*Server).handleStream(0xc000268000), {0x55d9c9c58ce0, 0xc0014e6820}, 0xc0004a2120)
[google.golang.org/[email protected]/server.go:1737](http://google.golang.org/[email protected]/server.go:1737) +0xc4c
[google.golang.org/grpc.(*Server).serveStreams.func1.1()](http://google.golang.org/grpc.(*Server).serveStreams.func1.1())
[google.golang.org/[email protected]/server.go:986](http://google.golang.org/[email protected]/server.go:986) +0x86
created by [google.golang.org/grpc.(*Server).serveStreams.func1](http://google.golang.org/grpc.(*Server).serveStreams.func1) in goroutine 268
[google.golang.org/[email protected]/server.go:997](http://google.golang.org/[email protected]/server.go:997) +0x145
Example stack of operation blocked on read
goroutine 45150 [sync.RWMutex.RLock, 1 minutes]:
sync.runtime_SemacquireRWMutexR(0x0?, 0x27?, 0x17ea2e62b2b63d22?)
runtime/sema.go:82 +0x25
sync.(*RWMutex).RLock(...)
sync/rwmutex.go:71
[github.com/containerd/containerd/pkg/cri/store/container.(*statusStorage).Get(0xc004000c00)](http://github.com/containerd/containerd/pkg/cri/store/container.(*statusStorage).Get(0xc004000c00)) --> Needs Read Lock
[github.com/containerd/containerd/pkg/cri/store/container/status.go:205](http://github.com/containerd/containerd/pkg/cri/store/container/status.go:205) +0x7f
[github.com/containerd/containerd/pkg/cri/server.toCRIContainer({{{0xc00236b940](http://github.com/containerd/containerd/pkg/cri/server.toCRIContainer(%7B%7B%7B0xc00236b940), 0x40}, {0xc000ee2e40, 0x5e}, {0xc005ecfa00, 0x40}, 0xc000d95b30, {0xc0049e3860, 0x47}, {0xc001730a80, ...}, ...}, ...})
[github.com/containerd/containerd/pkg/cri/server/container_list.go:47](http://github.com/containerd/containerd/pkg/cri/server/container_list.go:47) +0x33
[github.com/containerd/containerd/pkg/cri/server.(*criService).ListContainers(0xc0003aaa00](http://github.com/containerd/containerd/pkg/cri/server.(*criService).ListContainers(0xc0003aaa00), {0xc004d009c0?, 0x55d9c9521e0d?}, 0xc001d1a3e0)
[github.com/containerd/containerd/pkg/cri/server/container_list.go:36](http://github.com/containerd/containerd/pkg/cri/server/container_list.go:36) +0x13b
[github.com/containerd/containerd/pkg/cri/instrument.(*instrumentedService).ListContainers(0xc0004fcd70](http://github.com/containerd/containerd/pkg/cri/instrument.(*instrumentedService).ListContainers(0xc0004fcd70), {0x55d9c9c4fdc8?, 0xc004d009c0}, 0xc001d1a3e0)
[github.com/containerd/containerd/pkg/cri/instrument/instrumented_service.go:561](http://github.com/containerd/containerd/pkg/cri/instrument/instrumented_service.go:561) +0x1ba
[k8s.io/cri-api/pkg/apis/runtime/v1._RuntimeService_ListContainers_Handler.func1({0x55d9c9c4fdc8](http://k8s.io/cri-api/pkg/apis/runtime/v1._RuntimeService_ListContainers_Handler.func1(%7B0x55d9c9c4fdc8), 0xc004d009c0}, {0x55d9c9b889c0?, 0xc001d1a3e0})
[k8s.io/[email protected]/pkg/apis/runtime/v1/api.pb.go:10917](http://k8s.io/[email protected]/pkg/apis/runtime/v1/api.pb.go:10917) +0x72
[github.com/containerd/containerd/services/server.unaryNamespaceInterceptor({0x55d9c9c4fdc8](http://github.com/containerd/containerd/services/server.unaryNamespaceInterceptor(%7B0x55d9c9c4fdc8), 0xc004d009c0}, {0x55d9c9b889c0, 0xc001d1a3e0}, 0xc0004a0388?, 0xc005d5cdb0)
[github.com/containerd/containerd/services/server/namespace.go:31](http://github.com/containerd/containerd/services/server/namespace.go:31) +0x65
[github.com/containerd/containerd/services/server.New.ChainUnaryServer.func6.1.1({0x55d9c9c4fdc8](http://github.com/containerd/containerd/services/server.New.ChainUnaryServer.func6.1.1(%7B0x55d9c9c4fdc8)?, 0xc004d009c0?}, {0x55d9c9b889c0?, 0xc001d1a3e0?})
[github.com/grpc-ecosystem/[email protected]/chain.go:25](http://github.com/grpc-ecosystem/[email protected]/chain.go:25) +0x37
[github.com/grpc-ecosystem/go-grpc-prometheus.init.(*ServerMetrics).UnaryServerInterceptor.func3({0x55d9c9c4fdc8](http://github.com/grpc-ecosystem/go-grpc-prometheus.init.(*ServerMetrics).UnaryServerInterceptor.func3(%7B0x55d9c9c4fdc8), 0xc004d009c0}, {0x55d9c9b889c0, 0xc001d1a3e0}, 0x55d9c9a259c0?, 0xc00296c1c0)
[github.com/grpc-ecosystem/[email protected]/server_metrics.go:107](http://github.com/grpc-ecosystem/[email protected]/server_metrics.go:107) +0x83
[github.com/containerd/containerd/services/server.New.ChainUnaryServer.func6.1.1({0x55d9c9c4fdc8](http://github.com/containerd/containerd/services/server.New.ChainUnaryServer.func6.1.1(%7B0x55d9c9c4fdc8)?, 0xc004d009c0?}, {0x55d9c9b889c0?, 0xc001d1a3e0?})
[github.com/grpc-ecosystem/[email protected]/chain.go:25](http://github.com/grpc-ecosystem/[email protected]/chain.go:25) +0x37
[github.com/containerd/containerd/services/server.New.ChainUnaryServer.func6({0x55d9c9c4fdc8](http://github.com/containerd/containerd/services/server.New.ChainUnaryServer.func6(%7B0x55d9c9c4fdc8), 0xc004d009c0}, {0x55d9c9b889c0, 0xc001d1a3e0}, 0xc0050339f8?, 0x55d9c99acc40?)
[github.com/grpc-ecosystem/[email protected]/chain.go:34](http://github.com/grpc-ecosystem/[email protected]/chain.go:34) +0xb5
[k8s.io/cri-api/pkg/apis/runtime/v1._RuntimeService_ListContainers_Handler({0x55d9c9bf6ea0](http://k8s.io/cri-api/pkg/apis/runtime/v1._RuntimeService_ListContainers_Handler(%7B0x55d9c9bf6ea0)?, 0xc0004fcd70}, {0x55d9c9c4fdc8, 0xc004d009c0}, 0xc002fde780, 0xc000115380)
[k8s.io/[email protected]/pkg/apis/runtime/v1/api.pb.go:10919](http://k8s.io/[email protected]/pkg/apis/runtime/v1/api.pb.go:10919) +0x135
[google.golang.org/grpc.(*Server).processUnaryRPC(0xc000268000](http://google.golang.org/grpc.(*Server).processUnaryRPC(0xc000268000), {0x55d9c9c4fdc8, 0xc0060d7500}, {0x55d9c9c58ce0, 0xc0014e6820}, 0xc000863c20, 0xc0008ac090, 0x55d9ca978350, 0x0)
[google.golang.org/[email protected]/server.go:1343](http://google.golang.org/[email protected]/server.go:1343) +0xe03
[google.golang.org/grpc.(*Server).handleStream(0xc000268000](http://google.golang.org/grpc.(*Server).handleStream(0xc000268000), {0x55d9c9c58ce0, 0xc0014e6820}, 0xc000863c20)
[google.golang.org/[email protected]/server.go:1737](http://google.golang.org/[email protected]/server.go:1737) +0xc4c
[google.golang.org/grpc.(*Server).serveStreams.func1.1()](http://google.golang.org/grpc.(*Server).serveStreams.func1.1())
[google.golang.org/[email protected]/server.go:986](http://google.golang.org/[email protected]/server.go:986) +0x86
created by [google.golang.org/grpc.(*Server).serveStreams.func1](http://google.golang.org/grpc.(*Server).serveStreams.func1) in goroutine 268
[google.golang.org/[email protected]/server.go:997](http://google.golang.org/[email protected]/server.go:997) +0x145
Logs:
22:08:03 istio proxy container is created:
time="2024-08-09T22:08:03.237147009Z" level=info msg="CreateContainer within sandbox "e5f71bb6a3052eb44a5acbd057e3f966b4f47b51f214ee9a51ed676cca654b13" for &ContainerMetadata{Name:istio-proxy,Attempt:0,} returns container id "758ee10927090b8a2805aec5bd873df566ca461912a3bb10bed540d9e4d23295""
22:08:05 update container resources request starts for an istio proxy container:
time="2024-08-09T22:08:05.281629682Z" level=info msg="UpdateContainerResources for "758ee10927090b8a2805aec5bd873df566ca461912a3bb10bed540d9e4d23295" with Linux: &LinuxContainerResources{CpuPeriod:0,CpuQuota:0,CpuShares:0,MemoryLimitInBytes:0,OomScoreAdj:0,CpusetCpus:0-31,CpusetMems:,HugepageLimits:[]*HugepageLimit{},Unified:map[string]string{},MemorySwapLimitInBytes:0,} / Windows: nil"
This acquires the lock in the stack above and blocks all other requests we start to see errors like:
time="2024-08-09T22:08:07.292595509Z" level=error msg="get state for 2b3e865a69c19bb27031b393060c3a880fa3742f198f6db081a1a3de22c1ae02" error="context deadline exceeded: unknown"
time="2024-08-09T22:08:22.402835688Z" level=error msg="get state for 47826c0e900b692b2c3f5430cba6d7e6448072fb9c4ad85eb43822e94329e888" error="context deadline exceeded: unknown"
time="2024-08-09T22:08:37.515421657Z" level=error msg="get state for 1ab5f1ab4f0f4e42930b641df778b93aaa877671c475a4a50900632260f223dd" error="context deadline exceeded: unknown"
22:23:05 (15 minutes later) the request times out and the node becomes healthy again:
time="2024-08-09T22:23:05.282976810Z" level=error msg="UpdateContainerResources for "758ee10927090b8a2805aec5bd873df566ca461912a3bb10bed540d9e4d23295" failed" error="failed to update resources: failed to update resources: context deadline exceeded: unknown"
E0809 22:23:05.282397 3620 cpu_manager.go:476] "ReconcileState: failed to update container" err="rpc error: code = DeadlineExceeded desc = context deadline exceeded" pod="[POD]" containerName="istio-proxy" containerID="758ee10927090b8a2805aec5bd873df566ca461912a3bb10bed540d9e4d23295" cpuSet="0-31"
What version of containerd are you using?
1.7.20
Any other relevant information
We have reproduced this on both kernel 5.4 and 5.15 on AKS clusters running their latest node images
All installed versions here:
https://raw.githubusercontent.com/Azure/AgentBaker/master/vhdbuilder/release-notes/AKSUbuntu/gen2/2004fipscontainerd/202407.29.0.txt
Show configuration if it is related to CRI plugin.
No response
Metadata
Metadata
Assignees
Type
Projects
- StatusShow more project fieldsDone
Activity
SergeyKanzhelev commentedon Aug 12, 2024
/cc
SergeyKanzhelev commentedon Aug 12, 2024
is it easy enough to repro to collect kubelet and containerd logs? Mostly to understand calls sequence.
ben-childs-docusign commentedon Aug 12, 2024
export(2).csv
Attached logs from the most recent case:
timeline:
istio native sidecar init container is created (this is an init container with restartpolicy = always)
Kubelet calls update container resources to configure cpuset
At this point all calls hang
Node gets marked as not ready
Kubelet seems to force restart containerd which resolves the issue
ben-childs-docusign commentedon Aug 12, 2024
Checking back through our logs I found another case of this not related to istio native sidecars, in this case it was a pod with 7 containers where 1 one of the container hung while updating cpuset and this then blocked for 15 minutes. So I'm guessing that istio native sidecars just runs into this case more frequently somehow.
SergeyKanzhelev commentedon Aug 12, 2024
I see some NRI plugins configured. Any details on this? There was a deadlock in NRI: containerd/nri#79
ben-childs-docusign commentedon Aug 12, 2024
We are just using the default AKS configs let me dump that for you.
For reference we did notice the 2 containerd deadlock fixes and logged a ticket with AKS to upgrade containerd with a build that has the fix:
Azure/AKS#4426
We are now running with containerd 1.7.20 which has all the fixes afaict.
SergeyKanzhelev commentedon Aug 12, 2024
I cannot tell which NRI plugins are registered as those are external processes connecting to the socket. It is also interesting if any of them were registered just before the issue happened.
Also, do you observe this issue around the startup? Or after kubelet and containerd was running for a while already?
Since it's not caused by sidecars, I have less input to this issue. I was thinking on how sidecar can change the calls order, but based on information so far, this is not the case.
ben-childs-docusign commentedon Aug 12, 2024
We see the issue even on nodes that have been alive for some time. One thing to note is that it is pretty clear that the UpdateContainerResources call takes a lock that blocks many other requests from completing during the call to the container shim.
https://github.com/containerd/containerd/blob/release/1.7/pkg/cri/store/container/status.go#L263 << this takes the lock
and blocks any get:
https://github.com/containerd/containerd/blob/release/1.7/pkg/cri/store/container/status.go#L205C4-L205C9
I wonder if we could somehow decouple the update call to the shim with the update to the internal state of the containerd runtime. This way we could only take the write lock during the actual update of the data structure rather than waiting for the shim to respond.
Unfortunately it is difficult to diagnose the underlying hang in containerd shim since we don't have pprof there, anecdotally it seems like it happens even without istio native sidecars but with much lower frequency. There must be some underlying race/deadlock in updating the cgroup cpuset setting I'm guessing.
ben-childs-docusign commentedon Aug 12, 2024
BTW from what I can tell the NRI plugins are disabled?
Also the stacks that I'm seeing show the hangup in the call to the shim process which should come after any NRI plugins at least based on my reading of this doc:
https://github.com/containerd/containerd/blob/main/docs/NRI.md#containerd-nri-integration
dosubot commentedon Dec 16, 2024
Hi, @ben-childs-docusign. I'm Dosu, and I'm helping the containerd team manage their backlog. I'm marking this issue as stale.
Issue Summary:
UpdateContainerResourcescall in containerd-shim hangs, blocking other requests.Next Steps:
Thank you for your understanding and contribution!