mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-22 03:11:40 +00:00
Prune should respect namespace
This commit is contained in:
parent
06fc5b7f17
commit
88e2f8e04f
1
hack/testdata/prune/b.yaml
vendored
1
hack/testdata/prune/b.yaml
vendored
@ -2,6 +2,7 @@ apiVersion: v1
|
|||||||
kind: Pod
|
kind: Pod
|
||||||
metadata:
|
metadata:
|
||||||
name: b
|
name: b
|
||||||
|
namespace: nsb
|
||||||
labels:
|
labels:
|
||||||
prune-group: "true"
|
prune-group: "true"
|
||||||
spec:
|
spec:
|
||||||
|
@ -635,6 +635,9 @@ See http://k8s.io/docs/reference/using-api/api-concepts/#conflicts`, err)
|
|||||||
}
|
}
|
||||||
|
|
||||||
for n := range visitedNamespaces {
|
for n := range visitedNamespaces {
|
||||||
|
if len(o.Namespace) != 0 && n != o.Namespace {
|
||||||
|
continue
|
||||||
|
}
|
||||||
for _, m := range namespacedRESTMappings {
|
for _, m := range namespacedRESTMappings {
|
||||||
if err := p.prune(n, m); err != nil {
|
if err := p.prune(n, m); err != nil {
|
||||||
return fmt.Errorf("error pruning namespaced object %v: %v", m.GroupVersionKind, err)
|
return fmt.Errorf("error pruning namespaced object %v: %v", m.GroupVersionKind, err)
|
||||||
|
@ -144,6 +144,19 @@ __EOF__
|
|||||||
output_message=$(! kubectl get pods a 2>&1 "${kube_flags[@]:?}")
|
output_message=$(! kubectl get pods a 2>&1 "${kube_flags[@]:?}")
|
||||||
kube::test::if_has_string "${output_message}" 'pods "a" not found'
|
kube::test::if_has_string "${output_message}" 'pods "a" not found'
|
||||||
|
|
||||||
|
kubectl delete pods a
|
||||||
|
kubectl delete pods b
|
||||||
|
|
||||||
|
# apply a
|
||||||
|
kubectl apply --namespace nsb -l prune-group=true -f hack/testdata/prune/a.yaml "${kube_flags[@]:?}"
|
||||||
|
# apply b with namespace
|
||||||
|
kubectl apply --namespace nsb --prune -l prune-group=true -f hack/testdata/prune/b.yaml "${kube_flags[@]:?}"
|
||||||
|
# check right pod exists
|
||||||
|
kube::test::get_object_assert 'pods b' "{{${id_field:?}}}" 'b'
|
||||||
|
# check wrong pod doesn't exist
|
||||||
|
output_message=$(! kubectl get pods a 2>&1 "${kube_flags[@]:?}")
|
||||||
|
kube::test::if_has_string "${output_message}" 'pods "a" not found'
|
||||||
|
|
||||||
# cleanup
|
# cleanup
|
||||||
kubectl delete pods b
|
kubectl delete pods b
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user