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

End2End - Pod Security Admission fixes #368

Merged
merged 2 commits into from
Oct 27, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions test/util/clean/clean.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@ func All() error {
return fmt.Errorf("failed to restore node drain state %v", err)
}
}
if !namespaces.Exists(namespaces.Test, clients) {
return nil
}

err := namespaces.DeleteAndWait(clients, namespaces.Test, 5*time.Minute)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm a bit confused by this change and the commit message: will it remove sriov resources from all namespaces or just from the specified one?

Copy link
Collaborator

Choose a reason for hiding this comment

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

this function delete the namespace and all the objects in that namespace. it's for a test namespace we don't run this function on the operator namespace.

There is also a clean sriov function to remove all the sriov related objects like sriovNetwork and sriovNetworkNodePolicy

if err != nil {
return fmt.Errorf("failed to delete sriov tests namespace %v", err)
Expand Down
9 changes: 7 additions & 2 deletions test/util/namespaces/namespaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,17 @@ func Create(namespace string, cs *testclient.ClientSet) error {
return err
}

// DeleteAndWait deletes a namespace and waits until delete
// DeleteAndWait deletes a namespace and waits until it is deleted
func DeleteAndWait(cs *testclient.ClientSet, namespace string, timeout time.Duration) error {
err := cs.Namespaces().Delete(context.Background(), namespace, metav1.DeleteOptions{})
if k8serrors.IsNotFound(err) {
return nil
}

if err != nil {
return err
return fmt.Errorf("failed to delete namespace [%s]: %w", namespace, err)
}

return WaitForDeletion(cs, namespace, timeout)
}

Expand Down