mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-28 22:17:14 +00:00
Merge pull request #107162 from ardaguclu/invalidate-cache-after-delete
Add manually invalidate cache documentation into delete
This commit is contained in:
commit
a5e70054bd
6
hack/testdata/CRD/example-crd-1-cluster-scoped-resource.yaml
vendored
Normal file
6
hack/testdata/CRD/example-crd-1-cluster-scoped-resource.yaml
vendored
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
apiVersion: test.com/v1
|
||||||
|
kind: Example
|
||||||
|
metadata:
|
||||||
|
name: test
|
||||||
|
spec:
|
||||||
|
test: test
|
24
hack/testdata/CRD/example-crd-1-cluster-scoped.yaml
vendored
Normal file
24
hack/testdata/CRD/example-crd-1-cluster-scoped.yaml
vendored
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
apiVersion: apiextensions.k8s.io/v1
|
||||||
|
kind: CustomResourceDefinition
|
||||||
|
metadata:
|
||||||
|
name: examples.test.com
|
||||||
|
spec:
|
||||||
|
group: test.com
|
||||||
|
scope: Cluster
|
||||||
|
versions:
|
||||||
|
- name: v1
|
||||||
|
served: true
|
||||||
|
storage: true
|
||||||
|
schema:
|
||||||
|
openAPIV3Schema:
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
spec:
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
test:
|
||||||
|
type: string
|
||||||
|
names:
|
||||||
|
plural: examples
|
||||||
|
singular: example
|
||||||
|
kind: Example
|
7
hack/testdata/CRD/example-crd-1-namespaced-resource.yaml
vendored
Normal file
7
hack/testdata/CRD/example-crd-1-namespaced-resource.yaml
vendored
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
apiVersion: test.com/v1
|
||||||
|
kind: Example
|
||||||
|
metadata:
|
||||||
|
name: test
|
||||||
|
namespace: default
|
||||||
|
spec:
|
||||||
|
test: test
|
24
hack/testdata/CRD/example-crd-1-namespaced.yaml
vendored
Normal file
24
hack/testdata/CRD/example-crd-1-namespaced.yaml
vendored
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
apiVersion: apiextensions.k8s.io/v1
|
||||||
|
kind: CustomResourceDefinition
|
||||||
|
metadata:
|
||||||
|
name: examples.test.com
|
||||||
|
spec:
|
||||||
|
group: test.com
|
||||||
|
scope: Namespaced
|
||||||
|
versions:
|
||||||
|
- name: v1
|
||||||
|
served: true
|
||||||
|
storage: true
|
||||||
|
schema:
|
||||||
|
openAPIV3Schema:
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
spec:
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
test:
|
||||||
|
type: string
|
||||||
|
names:
|
||||||
|
plural: examples
|
||||||
|
singular: example
|
||||||
|
kind: Example
|
@ -69,7 +69,11 @@ var (
|
|||||||
|
|
||||||
Note that the delete command does NOT do resource version checks, so if someone submits an
|
Note that the delete command does NOT do resource version checks, so if someone submits an
|
||||||
update to a resource right when you submit a delete, their update will be lost along with the
|
update to a resource right when you submit a delete, their update will be lost along with the
|
||||||
rest of the resource.`))
|
rest of the resource.
|
||||||
|
|
||||||
|
After a CustomResourceDefinition is deleted, invalidation of discovery cache may take up
|
||||||
|
to 10 minutes. If you don't want to wait, you might want to run "kubectl api-resources"
|
||||||
|
to refresh the discovery cache.`))
|
||||||
|
|
||||||
deleteExample = templates.Examples(i18n.T(`
|
deleteExample = templates.Examples(i18n.T(`
|
||||||
# Delete a pod using the type and name specified in pod.json
|
# Delete a pod using the type and name specified in pod.json
|
||||||
|
@ -96,6 +96,36 @@ run_resource_aliasing_tests() {
|
|||||||
set +o errexit
|
set +o errexit
|
||||||
}
|
}
|
||||||
|
|
||||||
|
run_crd_deletion_recreation_tests() {
|
||||||
|
set -o nounset
|
||||||
|
set -o errexit
|
||||||
|
|
||||||
|
create_and_use_new_namespace
|
||||||
|
kube::log::status "Testing resource creation, deletion, and re-creation"
|
||||||
|
|
||||||
|
output_message=$(kubectl apply -f hack/testdata/CRD/example-crd-1-cluster-scoped.yaml)
|
||||||
|
kube::test::if_has_string "${output_message}" 'created'
|
||||||
|
output_message=$(kubectl apply -f hack/testdata/CRD/example-crd-1-cluster-scoped-resource.yaml)
|
||||||
|
kube::test::if_has_string "${output_message}" 'created'
|
||||||
|
output_message=$(kubectl delete -f hack/testdata/CRD/example-crd-1-cluster-scoped.yaml)
|
||||||
|
kube::test::if_has_string "${output_message}" 'deleted'
|
||||||
|
# Invalidate local cache because cluster scoped CRD in cache is stale.
|
||||||
|
# Invalidation of cache may take up to 10 minutes and we are manually
|
||||||
|
# invalidate cache and expect that scope changed CRD should be created without problem.
|
||||||
|
kubectl api-resources
|
||||||
|
output_message=$(kubectl apply -f hack/testdata/CRD/example-crd-1-namespaced.yaml)
|
||||||
|
kube::test::if_has_string "${output_message}" 'created'
|
||||||
|
output_message=$(kubectl apply -f hack/testdata/CRD/example-crd-1-namespaced-resource.yaml)
|
||||||
|
kube::test::if_has_string "${output_message}" 'created'
|
||||||
|
|
||||||
|
# Cleanup
|
||||||
|
kubectl delete -f hack/testdata/CRD/example-crd-1-namespaced-resource.yaml
|
||||||
|
kubectl delete -f hack/testdata/CRD/example-crd-1-namespaced.yaml
|
||||||
|
|
||||||
|
set +o nounset
|
||||||
|
set +o errexit
|
||||||
|
}
|
||||||
|
|
||||||
run_kubectl_explain_tests() {
|
run_kubectl_explain_tests() {
|
||||||
set -o nounset
|
set -o nounset
|
||||||
set -o errexit
|
set -o errexit
|
||||||
|
@ -892,6 +892,13 @@ runTests() {
|
|||||||
record_command run_kubectl_explain_tests
|
record_command run_kubectl_explain_tests
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
##############################
|
||||||
|
# CRD Deletion / Re-creation #
|
||||||
|
##############################
|
||||||
|
|
||||||
|
if kube::test::if_supports_resource "${namespaces}" ; then
|
||||||
|
record_command run_crd_deletion_recreation_tests
|
||||||
|
fi
|
||||||
|
|
||||||
###########
|
###########
|
||||||
# Swagger #
|
# Swagger #
|
||||||
|
Loading…
Reference in New Issue
Block a user