mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-01-05 15:37:24 +00:00
Stop 'drain' deleting pods with local storage.
Unless forced with --delete-local-data. Also a refactoring of the kubectl drain logic that selects/rejects pods and produces error/warning messages.
This commit is contained in:
@@ -325,6 +325,24 @@ func TestDrain(t *testing.T) {
|
||||
},
|
||||
}
|
||||
|
||||
emptydir_pod := api.Pod{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: "bar",
|
||||
Namespace: "default",
|
||||
CreationTimestamp: unversioned.Time{Time: time.Now()},
|
||||
Labels: labels,
|
||||
},
|
||||
Spec: api.PodSpec{
|
||||
NodeName: "node",
|
||||
Volumes: []api.Volume{
|
||||
{
|
||||
Name: "scratch",
|
||||
VolumeSource: api.VolumeSource{EmptyDir: &api.EmptyDirVolumeSource{Medium: ""}},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
tests := []struct {
|
||||
description string
|
||||
node *api.Node
|
||||
@@ -406,6 +424,24 @@ func TestDrain(t *testing.T) {
|
||||
expectFatal: false,
|
||||
expectDelete: true,
|
||||
},
|
||||
{
|
||||
description: "pod with EmptyDir",
|
||||
node: node,
|
||||
expected: cordoned_node,
|
||||
pods: []api.Pod{emptydir_pod},
|
||||
args: []string{"node", "--force"},
|
||||
expectFatal: true,
|
||||
expectDelete: false,
|
||||
},
|
||||
{
|
||||
description: "pod with EmptyDir and --delete-local-data",
|
||||
node: node,
|
||||
expected: cordoned_node,
|
||||
pods: []api.Pod{emptydir_pod},
|
||||
args: []string{"node", "--force", "--delete-local-data=true"},
|
||||
expectFatal: false,
|
||||
expectDelete: true,
|
||||
},
|
||||
{
|
||||
description: "empty node",
|
||||
node: node,
|
||||
|
||||
Reference in New Issue
Block a user