Merge pull request #107162 from ardaguclu/invalidate-cache-after-delete

Add manually invalidate cache documentation into delete
This commit is contained in:
Kubernetes Prow Robot 2022-02-02 23:51:45 -08:00 committed by GitHub
commit a5e70054bd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 103 additions and 1 deletions

View File

@ -0,0 +1,6 @@
apiVersion: test.com/v1
kind: Example
metadata:
name: test
spec:
test: test

View 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

View File

@ -0,0 +1,7 @@
apiVersion: test.com/v1
kind: Example
metadata:
name: test
namespace: default
spec:
test: test

View 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

View File

@ -69,7 +69,11 @@ var (
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
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(`
# Delete a pod using the type and name specified in pod.json

View File

@ -96,6 +96,36 @@ run_resource_aliasing_tests() {
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() {
set -o nounset
set -o errexit

View File

@ -892,6 +892,13 @@ runTests() {
record_command run_kubectl_explain_tests
fi
##############################
# CRD Deletion / Re-creation #
##############################
if kube::test::if_supports_resource "${namespaces}" ; then
record_command run_crd_deletion_recreation_tests
fi
###########
# Swagger #