mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-10 13:42:02 +00:00
Merge pull request #8641 from smarterclayton/gracefully_delete_pods
Gracefully delete pods from the Kubelet
This commit is contained in:
@@ -446,20 +446,24 @@ func expectNoError(err error, explain ...interface{}) {
|
||||
ExpectWithOffset(1, err).NotTo(HaveOccurred(), explain...)
|
||||
}
|
||||
|
||||
// Stops everything from filePath from namespace ns and checks if everything maching selectors from the given namespace is correctly stopped.
|
||||
// Stops everything from filePath from namespace ns and checks if everything matching selectors from the given namespace is correctly stopped.
|
||||
func cleanup(filePath string, ns string, selectors ...string) {
|
||||
By("using stop to clean up resources")
|
||||
By("using delete to clean up resources")
|
||||
var nsArg string
|
||||
if ns != "" {
|
||||
nsArg = fmt.Sprintf("--namespace=%s", ns)
|
||||
}
|
||||
runKubectl("stop", "-f", filePath, nsArg)
|
||||
runKubectl("stop", "--grace-period=0", "-f", filePath, nsArg)
|
||||
|
||||
for _, selector := range selectors {
|
||||
resources := runKubectl("get", "pods,rc,se", "-l", selector, "--no-headers", nsArg)
|
||||
resources := runKubectl("get", "rc,se", "-l", selector, "--no-headers", nsArg)
|
||||
if resources != "" {
|
||||
Failf("Resources left running after stop:\n%s", resources)
|
||||
}
|
||||
pods := runKubectl("get", "pods", "-l", selector, nsArg, "-t", "{{ range .items }}{{ if not .metadata.deletionTimestamp }}{{ .metadata.name }}{{ \"\\n\" }}{{ end }}{{ end }}")
|
||||
if pods != "" {
|
||||
Failf("Pods left unterminated after stop:\n%s", pods)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user