-
Notifications
You must be signed in to change notification settings - Fork 113
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,13 @@ import ( | |
// Test is the namespace to be use for testing | ||
const Test = "sriov-conformance-testing" | ||
|
||
var inhibitSecurityAdmissionLabels = map[string]string{ | ||
"pod-security.kubernetes.io/audit": "privileged", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We might want to align this with what we have for #371 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. From what I see the labels have a delta. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @wizhaoredhat this is fine for the test-pods we have this in other places where we run tests like openshift-kni/cnf-features-deploy#1238 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah ok, got it. Thanks! |
||
"pod-security.kubernetes.io/enforce": "privileged", | ||
"pod-security.kubernetes.io/warn": "privileged", | ||
"security.openshift.io/scc.podSecurityLabelSync": "false", | ||
} | ||
|
||
// WaitForDeletion waits until the namespace will be removed from the cluster | ||
func WaitForDeletion(cs *testclient.ClientSet, nsName string, timeout time.Duration) error { | ||
return wait.PollImmediate(time.Second, timeout, func() (bool, error) { | ||
|
@@ -36,7 +43,8 @@ func WaitForDeletion(cs *testclient.ClientSet, nsName string, timeout time.Durat | |
func Create(namespace string, cs *testclient.ClientSet) error { | ||
_, err := cs.Namespaces().Create(context.Background(), &k8sv1.Namespace{ | ||
ObjectMeta: metav1.ObjectMeta{ | ||
Name: namespace, | ||
Name: namespace, | ||
Labels: inhibitSecurityAdmissionLabels, | ||
}}, metav1.CreateOptions{}) | ||
|
||
if k8serrors.IsAlreadyExists(err) { | ||
|
@@ -45,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) | ||
} | ||
|
||
|
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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