Skip to content

Commit 80ca8ff

Browse files
committed
fix: update the cgroups for Talos core services
There was a bit of a mess here which worked fine until we bumped runc/containerd, and the problem shows up in Talos-in-Kubernetes tests. Use consistently `runner.WithCgroupPath`, as it handles cgroup nesting for cases when Talos runs in a container. Assign each service its own unique cgroup. Signed-off-by: Andrey Smirnov <andrey.smirnov@siderolabs.com>
1 parent fe317f1 commit 80ca8ff

File tree

7 files changed

+16
-2
lines changed

7 files changed

+16
-2
lines changed

internal/app/machined/pkg/runtime/v1alpha1/v1alpha1_sequencer_tasks.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,8 @@ func CreateSystemCgroups(runtime.Sequence, any) (runtime.TaskExecutionFunc, stri
170170
return fmt.Errorf("error initializing cgroups root path: %w", err)
171171
}
172172

173+
logger.Printf("using cgroups root: %s", cgroup.Root())
174+
173175
groups := []struct {
174176
name string
175177
resources *cgroup2.Resources

internal/app/machined/pkg/system/services/apid.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,7 @@ func (o *APID) Runner(r runtime.Runtime) (runner.Runner, error) {
192192
runner.WithLoggingManager(r.Logging()),
193193
runner.WithContainerdAddress(constants.SystemContainerdAddress),
194194
runner.WithEnv(env),
195+
runner.WithCgroupPath(constants.CgroupApid),
195196
runner.WithOCISpecOpts(
196197
oci.WithDroppedCapabilities(cap.Known()),
197198
oci.WithHostNamespace(specs.NetworkNamespace),

internal/app/machined/pkg/system/services/etcd.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,7 @@ func (e *Etcd) Runner(r runtime.Runtime) (runner.Runner, error) {
218218
runner.WithNamespace(constants.SystemContainerdNamespace),
219219
runner.WithContainerImage(e.imgRef),
220220
runner.WithEnv(env),
221+
runner.WithCgroupPath(constants.CgroupEtcd),
221222
runner.WithOCISpecOpts(
222223
oci.WithDroppedCapabilities(cap.Known()),
223224
oci.WithHostNamespace(specs.NetworkNamespace),

internal/app/machined/pkg/system/services/extension.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,6 @@ func (svc *Extension) getOCIOptions(envVars []string, mounts []specs.Mount) []oc
113113
ociOpts := []oci.SpecOpts{
114114
oci.WithRootFSPath(filepath.Join(constants.ExtensionServiceRootfsPath, svc.Spec.Name)),
115115
containerd.WithRootfsPropagation(svc.Spec.Container.Security.RootfsPropagation),
116-
oci.WithCgroup(filepath.Join(constants.CgroupExtensions, svc.Spec.Name)),
117116
oci.WithMounts(mounts),
118117
oci.WithHostNamespace(specs.NetworkNamespace),
119118
oci.WithSelinuxLabel(""),
@@ -216,6 +215,7 @@ func (svc *Extension) Runner(r runtime.Runtime) (runner.Runner, error) {
216215
runner.WithContainerdAddress(constants.SystemContainerdAddress),
217216
runner.WithEnv(environment.Get(r.Config())),
218217
runner.WithOCISpecOpts(ociSpecOpts...),
218+
runner.WithCgroupPath(filepath.Join(constants.CgroupExtensions, svc.Spec.Name)),
219219
runner.WithOOMScoreAdj(-600),
220220
),
221221
restart.WithType(restartType),

internal/app/machined/pkg/system/services/kubelet.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,9 +157,9 @@ func (k *Kubelet) Runner(r runtime.Runtime) (runner.Runner, error) {
157157
runner.WithNamespace(constants.SystemContainerdNamespace),
158158
runner.WithContainerImage(k.imgRef),
159159
runner.WithEnv(environment.Get(r.Config())),
160+
runner.WithCgroupPath(constants.CgroupKubelet),
160161
runner.WithOCISpecOpts(
161162
containerd.WithRootfsPropagation("shared"),
162-
oci.WithCgroup(constants.CgroupKubelet),
163163
oci.WithMounts(mounts),
164164
oci.WithHostNamespace(specs.NetworkNamespace),
165165
oci.WithHostNamespace(specs.PIDNamespace),

internal/app/machined/pkg/system/services/trustd.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ func (t *Trustd) Runner(r runtime.Runtime) (runner.Runner, error) {
155155
runner.WithLoggingManager(r.Logging()),
156156
runner.WithContainerdAddress(constants.SystemContainerdAddress),
157157
runner.WithEnv(env),
158+
runner.WithCgroupPath(constants.CgroupTrustd),
158159
runner.WithOCISpecOpts(
159160
containerd.WithMemoryLimit(int64(1000000*512)),
160161
oci.WithDroppedCapabilities(cap.Known()),

pkg/machinery/constants/constants.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -666,6 +666,12 @@ const (
666666
// CgroupSystemRuntime is the cgroup name for containerd runtime processes.
667667
CgroupSystemRuntime = CgroupSystem + "/runtime"
668668

669+
// CgroupApid is the cgroup name for apid runtime processes.
670+
CgroupApid = CgroupSystem + "/apid"
671+
672+
// CgroupTrustd is the cgroup name for trustd runtime processes.
673+
CgroupTrustd = CgroupSystem + "/trustd"
674+
669675
// CgroupUdevd is the cgroup name for udevd runtime processes.
670676
CgroupUdevd = CgroupSystem + "/udevd"
671677

@@ -681,6 +687,9 @@ const (
681687
// CgroupPodRuntimeReservedMemory is the hard memory protection for the cri runtime processes.
682688
CgroupPodRuntimeReservedMemory = 128 * 1024 * 1024
683689

690+
// CgroupEtcd is the cgroup name for etcd process.
691+
CgroupEtcd = "/podruntime/etcd"
692+
684693
// CgroupKubelet is the cgroup name for kubelet process.
685694
CgroupKubelet = "/podruntime/kubelet"
686695

0 commit comments

Comments
 (0)