-
Notifications
You must be signed in to change notification settings - Fork 200
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
feat(webhook): add validation for namspace delete requests #1754
Conversation
This PR adds validation on deletion of openebs namespace to avoid - loss of data in case of accidental deletion of namespace - stale resources with finalizers in openebs namespace which may be stuck on namespace deletion. Signed-off-by: shubham <[email protected]>
pkg/webhook/webhook.go
Outdated
if req.Operation == v1beta1.Delete { | ||
return wh.validateNamespaceDeleteRequest(req) | ||
} | ||
klog.V(2).Info("Admission wehbook for PVC module not " + |
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.
Can you also check that this rule only applies to openebs namespace? Other namespace requests shouldn't get impacted by this.
Add a test to verify that when BDCs are present, a test namespace can be created and deleted without any issues.
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.
Fixed the log message and added the manual test result to the PR description.
Signed-off-by: shubham <[email protected]>
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.
changes are good but provided few comments...
Signed-off-by: shubham <[email protected]>
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.
changes are good
…rchive#1754) This PR adds validation on deletion of openebs namespace to avoid - loss of data in case of accidental deletion of namespace - stale resources with finalizers in openebs namespace which may be stuck on namespace deletion. Signed-off-by: shubham <[email protected]>
…rchive#1754) This PR adds validation on deletion of openebs namespace to avoid - loss of data in case of accidental deletion of namespace - stale resources with finalizers in openebs namespace which may be stuck on namespace deletion. Signed-off-by: shubham <[email protected]>
…rchive#1754) This PR adds validation on deletion of openebs namespace to avoid - loss of data in case of accidental deletion of namespace - stale resources with finalizers in openebs namespace which may be stuck on namespace deletion. Signed-off-by: shubham <[email protected]>
This PR adds validation on deletion of openebs namespace to avoid - loss of data in case of accidental deletion of namespace - stale resources with finalizers in openebs namespace which may be stuck on namespace deletion. Signed-off-by: shubham <[email protected]>
This PR adds validation on deletion of openebs namespace to avoid - loss of data in case of accidental deletion of namespace - stale resources with finalizers in openebs namespace which may be stuck on namespace deletion. Signed-off-by: shubham <[email protected]>
This PR adds validation on deletion of openebs namespace to avoid - loss of data in case of accidental deletion of namespace - stale resources with finalizers in openebs namespace which may be stuck on namespace deletion. Signed-off-by: shubham <[email protected]>
if err != nil { | ||
response.Allowed = false | ||
response.Result = &metav1.Status{ | ||
Message: fmt.Sprintf("error listing BDC in namespace %s: %v", req.Name, err.Error()), |
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.
Failure is here in case of helm chart deletion
@@ -421,6 +426,9 @@ func (wh *webhook) validate(ar *v1beta1.AdmissionReview) *v1beta1.AdmissionRespo | |||
response.Allowed = true | |||
klog.Info("Admission webhook request received") | |||
switch req.Kind.Kind { | |||
case "Namespace": | |||
klog.V(2).Infof("Admission webhook request for type %s", req.Kind.Kind) | |||
return wh.validateNamespace(ar) |
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 validate kicks in for any namespace deletion , can we use the webhook namespace itself to get the openebs namespace and skip for other namespace validations
What this PR does?:
This PR adds validation on the deletion of openebs namespace
to avoid
namespace
maybe stuck on namespace deletion.
Does this PR require any upgrade changes?:
Yes already handled in the PR itself. Tested 1.10 to latest upgrade: namespace gets added to validatingwebhookconfigurations automatically.
If the changes in this PR are manually verified, list down the scenarios covered::
Local test performed:
Both jiva and cstor volume exist
Only cstor volume exists
Only jiva volume exists
After deleting all volumes and pools
mayadata:setup$ kubectl delete ns openebs namespace "openebs" deleted
Created a cstor & jiva volume in test namespace and deleted the namespace. The webhook did not impact the deletion and cleanup was successful.
TODO
Add unit test for the added webhook validation.
Checklist:
<type>(<scope>): <subject>