Skip to content

Commit 189a166

Browse files
author
Kubernetes Submit Queue
authored
Merge pull request #61482 from filbranden/summary3
Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. Fix summary_test to work when XFS is used under overlay2 and add a check for Delegate=yes missing from docker.service **What this PR does / why we need it**: This fixes the summary_test checks to work in cases where: 1. Docker is using overlay2 for its images with XFS as backing filesystem. 1. The systemd unit for Docker does not include Delegate=yes. The former will break RootFs minimum usage check from summary_test, since it expects _some_ usage even though the upper layer only contains directories that are used as mount points. It turns out the XFS filesystem returns "0" blocks in the stat() result for a directory, so this breaks the test. Fix it by creating a file with some small contents in the test, so that `du` will actually return some usage. **NOTE**: I introduced this step in the loop part of the function. It works, but maybe it's not the best... Let me know if you think we should do some small cleanup here too, I'd be happy to do that. Regarding the latter, when `Delegate=yes` is not included in `docker.service`, then systemd might choose not to create Memory and CPU cgroups (actually, any of the resource cgroups) for the unit when it starts it. It's a bit more complicated than that, because it *does* create them if any sibling units need it, so the behavior is a bit hard to control... In any case, here we're checking on it and accepting that we might get a "nil" from cAdvisor in cases where `Delegate=yes` is missing. Both of these issues can be found on CentOS/RHEL, that's the motivation for the fixes. **Which issue(s) this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close the issue(s) when PR gets merged)*: N/A **Special notes for your reviewer**: /assign dashpole **Release note**: ```release-note NONE ```
2 parents 5ae7bba + b8c39b7 commit 189a166

File tree

1 file changed

+27
-2
lines changed

1 file changed

+27
-2
lines changed

test/e2e_node/summary_test.go

+27-2
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ package e2e_node
1919
import (
2020
"fmt"
2121
"io/ioutil"
22+
"os/exec"
2223
"strings"
2324
"time"
2425

@@ -118,9 +119,33 @@ var _ = framework.KubeDescribe("Summary API", func() {
118119
"PageFaults": bounded(0, 1000000),
119120
"MajorPageFaults": bounded(0, 10),
120121
})
122+
runtimeContExpectations := sysContExpectations().(*gstruct.FieldsMatcher)
123+
if systemdutil.IsRunningSystemd() && framework.TestContext.ContainerRuntime == "docker" {
124+
// Some Linux distributions still ship a docker.service that is missing
125+
// a `Delegate=yes` setting (or equivalent CPUAccounting= and MemoryAccounting=)
126+
// that allows us to monitor the container runtime resource usage through
127+
// the "cpu" and "memory" cgroups.
128+
//
129+
// Make an exception here for those distros, only for Docker, so that they
130+
// can pass the full node e2e tests even in that case.
131+
//
132+
// For newer container runtimes (using CRI) and even distros that still
133+
// ship Docker, we should encourage them to always set `Delegate=yes` in
134+
// order to make monitoring of the runtime possible.
135+
stdout, err := exec.Command("systemctl", "show", "-p", "Delegate", "docker.service").CombinedOutput()
136+
if err == nil && strings.TrimSpace(string(stdout)) == "Delegate=no" {
137+
// Only make these optional if we can successfully confirm that
138+
// Delegate is set to "no" (in other words, unset.) If we fail
139+
// to check that, default to requiring it, which might cause
140+
// false positives, but that should be the safer approach.
141+
By("Making runtime container expectations optional, since systemd was not configured to Delegate=yes the cgroups")
142+
runtimeContExpectations.Fields["Memory"] = Or(BeNil(), runtimeContExpectations.Fields["Memory"])
143+
runtimeContExpectations.Fields["CPU"] = Or(BeNil(), runtimeContExpectations.Fields["CPU"])
144+
}
145+
}
121146
systemContainers := gstruct.Elements{
122147
"kubelet": sysContExpectations(),
123-
"runtime": sysContExpectations(),
148+
"runtime": runtimeContExpectations,
124149
"pods": podsContExpectations,
125150
}
126151
// The Kubelet only manages the 'misc' system container if the host is not running systemd.
@@ -324,7 +349,7 @@ func getSummaryTestPods(f *framework.Framework, numRestarts int32, names ...stri
324349
{
325350
Name: "busybox-container",
326351
Image: busyboxImage,
327-
Command: getRestartingContainerCommand("/test-empty-dir-mnt", 0, numRestarts, "ping -c 1 google.com; echo 'hello world' >> /test-empty-dir-mnt/file;"),
352+
Command: getRestartingContainerCommand("/test-empty-dir-mnt", 0, numRestarts, "echo 'some bytes' >/outside_the_volume.txt; ping -c 1 google.com; echo 'hello world' >> /test-empty-dir-mnt/file;"),
328353
Resources: v1.ResourceRequirements{
329354
Limits: v1.ResourceList{
330355
// Must set memory limit to get MemoryStats.AvailableBytes

0 commit comments

Comments
 (0)