Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[YUNIKORN-3016] Cleanup cluster resources after persistent_volume e2e test failed #947

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

kaichiachen
Copy link

What is this PR for?

In the e2e test persistent_volume_test.go, the test case Verify_dynamic_binding_with_nfs_server may leave behind cluster resources (e.g., StorageClasses, ClusterRoles, Deployments, etc.) when the test fails. These resources could cause subsequent tests using the same namespace to encounter unexpected errors.

What type of PR is it?

  • - Bug Fix
  • - Improvement
  • - Feature
  • - Documentation
  • - Hot Fix
  • - Refactoring

Todos

  • - Task

What is the Jira issue?

https://issues.apache.org/jira/browse/YUNIKORN-3016

How should this be tested?

  1. Inject an error to the end of testcase "Verify_dynamic_binding_with_nfs_server" in persistent_volume_test
  2. Run e2e test, verify resources are all cleaned up
#> kubectl get clusterrolebindings nfs-cluster-role-binding -n dev-hkp8i
Error from server (NotFound): clusterrolebindings.rbac.authorization.k8s.io "nfs-cluster-role-binding" not found
#> kubectl get ClusterRole nfs-cluster-role -n dev-hkp8i          
Error from server (NotFound): clusterroles.rbac.authorization.k8s.io "nfs-cluster-role" not found
#> kubectl get storageclasses nfs-sc -n dev-hkp8i                  
Error from server (NotFound): storageclasses.storage.k8s.io "nfs-sc" not found
#> kubectl get serviceaccount nfs-service-account -n dev-hkp8i          
Error from server (NotFound): serviceaccounts "nfs-service-account" not found
#> kubectl get deployment nfs-provisioner -n dev-hkp8i             
Error from server (NotFound): deployments.apps "nfs-provisioner" not found

Screenshots (if appropriate)

Questions:

  • - The licenses files need update.
  • - There is breaking changes for older versions.
  • - It needs documentation.

Copy link
Contributor

@ryankert01 ryankert01 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for you patch! Having a simple question.

err2 := kClient.DeleteClusterRole(clusterRole)
err3 := kClient.DeleteServiceAccount(serviceAccount, dev)
if err2 != nil && !k8serrors.IsNotFound(err2) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why assert only when k8serror is found?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Ryan for helping me review! k8serrors.IsNotFound returns true if the resource is not found
At line 147/148
147 createNfsRbac(saName, crName, crbName)
148 createNfsProvisioner(saName, serverName, scName)
At the beginning of the test, resources are created sequentially while some of them might be created successfully and some of not. We don't want to show resource not found error when cleaning up resources.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants