Skip to content

Commit

Permalink
Merge branch 'kubernetes:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
Ruhi-Khan authored Mar 22, 2024
2 parents b884100 + 95a6f2e commit c8393f6
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 115 deletions.
39 changes: 0 additions & 39 deletions test/e2e_node/node_shutdown_linux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import (
"fmt"
"os"
"os/exec"
"path/filepath"
"regexp"
"strconv"
"time"
Expand Down Expand Up @@ -652,44 +651,6 @@ func getNodeReadyStatus(ctx context.Context, f *framework.Framework) bool {
return isNodeReady(&nodeList.Items[0])
}

func systemctlDaemonReload() error {
cmd := "systemctl daemon-reload"
_, err := runCommand("sh", "-c", cmd)
return err
}

var (
dbusConfPath = "/etc/systemd/system/dbus.service.d/k8s-graceful-node-shutdown-e2e.conf"
dbusConf = `
[Unit]
RefuseManualStart=no
RefuseManualStop=no
[Service]
KillMode=control-group
ExecStop=
`
)

func overlayDbusConfig() error {
err := os.MkdirAll(filepath.Dir(dbusConfPath), 0755)
if err != nil {
return err
}
err = os.WriteFile(dbusConfPath, []byte(dbusConf), 0644)
if err != nil {
return err
}
return systemctlDaemonReload()
}

func restoreDbusConfig() error {
err := os.Remove(dbusConfPath)
if err != nil {
return err
}
return systemctlDaemonReload()
}

const (
// https://github.com/kubernetes/kubernetes/blob/1dd781ddcad454cc381806fbc6bd5eba8fa368d7/pkg/kubelet/nodeshutdown/nodeshutdown_manager_linux.go#L43-L44
podShutdownReason = "Terminated"
Expand Down
22 changes: 11 additions & 11 deletions test/e2e_node/podresources_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -447,12 +447,12 @@ func podresourcesListTests(ctx context.Context, f *framework.Framework, cli kube
cntName: "cnt-00",
resourceName: sd.resourceName,
resourceAmount: 1,
cpuRequest: 2000,
cpuRequest: 1000,
},
{
podName: "pod-02",
cntName: "cnt-00",
cpuRequest: 2000,
cpuRequest: 1000,
},
{
podName: "pod-03",
Expand All @@ -471,12 +471,12 @@ func podresourcesListTests(ctx context.Context, f *framework.Framework, cli kube
{
podName: "pod-01",
cntName: "cnt-00",
cpuRequest: 2000,
cpuRequest: 1000,
},
{
podName: "pod-02",
cntName: "cnt-00",
cpuRequest: 2000,
cpuRequest: 1000,
},
{
podName: "pod-03",
Expand All @@ -503,12 +503,12 @@ func podresourcesListTests(ctx context.Context, f *framework.Framework, cli kube
cntName: "cnt-00",
resourceName: sd.resourceName,
resourceAmount: 1,
cpuRequest: 2000,
cpuRequest: 1000,
},
{
podName: "pod-02",
cntName: "cnt-00",
cpuRequest: 2000,
cpuRequest: 1000,
},
}
} else {
Expand All @@ -520,12 +520,12 @@ func podresourcesListTests(ctx context.Context, f *framework.Framework, cli kube
{
podName: "pod-01",
cntName: "cnt-00",
cpuRequest: 2000,
cpuRequest: 1000,
},
{
podName: "pod-02",
cntName: "cnt-00",
cpuRequest: 2000,
cpuRequest: 1000,
},
}
}
Expand Down Expand Up @@ -791,7 +791,7 @@ func podresourcesGetTests(ctx context.Context, f *framework.Framework, cli kubel
{
podName: "pod-01",
cntName: "cnt-00",
cpuRequest: 2000,
cpuRequest: 1000,
},
}
tpd.createPodsForTest(ctx, f, expected)
Expand All @@ -812,15 +812,15 @@ func podresourcesGetTests(ctx context.Context, f *framework.Framework, cli kubel
{
podName: "pod-01",
cntName: "cnt-00",
cpuRequest: 2000,
cpuRequest: 1000,
initContainers: []initContainerDesc{
{
cntName: "init-00",
cpuRequest: 1000,
},
{
cntName: "restartable-init-01",
cpuRequest: 2000,
cpuRequest: 1000,
restartPolicy: &containerRestartPolicyAlways,
},
},
Expand Down
55 changes: 0 additions & 55 deletions test/e2e_node/restart_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,61 +147,6 @@ var _ = SIGDescribe("Restart", framework.WithSerial(), framework.WithSlow(), fra
})
})
})

ginkgo.Context("Dbus", func() {
ginkgo.It("should continue to run pods after a restart", func(ctx context.Context) {
// Allow dbus to be restarted on ubuntu
err := overlayDbusConfig()
framework.ExpectNoError(err)
defer func() {
err := restoreDbusConfig()
framework.ExpectNoError(err)
}()

preRestartPodCount := 2
ginkgo.By(fmt.Sprintf("creating %d RestartAlways pods on node", preRestartPodCount))
restartAlwaysPods := newTestPods(preRestartPodCount, false, imageutils.GetPauseImageName(), "restart-dbus-test")
createBatchPodWithRateControl(ctx, f, restartAlwaysPods, podCreationInterval)
ginkgo.DeferCleanup(deletePodsSync, f, restartAlwaysPods)

allPods := waitForPodsCondition(ctx, f, preRestartPodCount, startTimeout, testutils.PodRunningReadyOrSucceeded)
if len(allPods) < preRestartPodCount {
framework.Failf("Failed to run sufficient restartAlways pods, got %d but expected %d", len(allPods), preRestartPodCount)
}

ginkgo.By("restarting dbus and systemd", func() {
stdout, err := exec.Command("sudo", "systemctl", "reset-failed", "dbus").CombinedOutput()
framework.ExpectNoError(err, "Failed to reset dbus start-limit with systemctl: %v, %s", err, string(stdout))

stdout, err = exec.Command("sudo", "systemctl", "restart", "dbus").CombinedOutput()
framework.ExpectNoError(err, "Failed to restart dbus with systemctl: %v, %s", err, string(stdout))

stdout, err = exec.Command("sudo", "systemctl", "daemon-reexec").CombinedOutput()
framework.ExpectNoError(err, "Failed to restart systemd with systemctl: %v, %s", err, string(stdout))
})

ginkgo.By("verifying restartAlways pods stay running", func() {
for start := time.Now(); time.Since(start) < startTimeout && ctx.Err() == nil; time.Sleep(10 * time.Second) {
postRestartRunningPods := waitForPodsCondition(ctx, f, preRestartPodCount, recoverTimeout, testutils.PodRunningReadyOrSucceeded)
if len(postRestartRunningPods) < preRestartPodCount {
framework.Failf("fewer pods are running after systemd restart, got %d but expected %d", len(postRestartRunningPods), preRestartPodCount)
}
}
})

ginkgo.By("verifying new pods can be started after a dbus restart")
postRestartPodCount := 2
postRestartPods := newTestPods(postRestartPodCount, false, imageutils.GetPauseImageName(), "restart-dbus-test")
createBatchPodWithRateControl(ctx, f, postRestartPods, podCreationInterval)
ginkgo.DeferCleanup(deletePodsSync, f, postRestartPods)

allPods = waitForPodsCondition(ctx, f, preRestartPodCount+postRestartPodCount, startTimeout, testutils.PodRunningReadyOrSucceeded)
if len(allPods) < preRestartPodCount+postRestartPodCount {
framework.Failf("Failed to run pods after restarting dbus, got %d but expected %d", len(allPods), preRestartPodCount+postRestartPodCount)
}
})
})

ginkgo.Context("Kubelet", func() {
ginkgo.It("should correctly account for terminated pods after restart", func(ctx context.Context) {
node := getLocalNode(ctx, f)
Expand Down
10 changes: 0 additions & 10 deletions test/e2e_node/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -316,16 +316,6 @@ func logKubeletLatencyMetrics(ctx context.Context, metricNames ...string) {
}
}

// runCommand runs the cmd and returns the combined stdout and stderr, or an
// error if the command failed.
func runCommand(cmd ...string) (string, error) {
output, err := exec.Command(cmd[0], cmd[1:]...).CombinedOutput()
if err != nil {
return "", fmt.Errorf("failed to run %q: %s (%s)", strings.Join(cmd, " "), err, output)
}
return string(output), nil
}

// getCRIClient connects CRI and returns CRI runtime service clients and image service client.
func getCRIClient() (internalapi.RuntimeService, internalapi.ImageManagerService, error) {
// connection timeout for CRI service connection
Expand Down

0 comments on commit c8393f6

Please sign in to comment.