-
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
fix(cspc, webhook): add validation for cspc deletion #1594
fix(cspc, webhook): add validation for cspc deletion #1594
Conversation
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.
provided comments
pkg/webhook/configuration.go
Outdated
@@ -447,7 +448,7 @@ func preUpgrade(openebsNamespace string) error { | |||
} | |||
|
|||
for _, service := range svcList.Items { | |||
if len(service.Labels["openebs.io/version"]) == 0 { | |||
if service.Labels["openebs.io/version"] != version.Current() { |
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.
Why does service need to be deleted for every upgrade?
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.
No, we should not
pkg/webhook/configuration.go
Outdated
@@ -460,7 +461,7 @@ func preUpgrade(openebsNamespace string) error { | |||
} | |||
|
|||
for _, config := range webhookConfigList.Items { | |||
if len(config.Labels["openebs.io/version"]) == 0 { | |||
if config.Labels["openebs.io/version"] != version.Current() { |
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.
Instead of deleting for every upgrade can't we handle with patch/update call?
cc: @prateekpandey14
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.
Yes, better to patch/update instead of delete based on version
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.
lgtm
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.
provided comments regarding logs.. rest of the things looks good
Signed-off-by: shubham <[email protected]>
Signed-off-by: shubham <[email protected]>
Signed-off-by: shubham <[email protected]>
Signed-off-by: shubham <[email protected]>
Signed-off-by: shubham <[email protected]>
Signed-off-by: shubham <[email protected]>
309900e
to
30405ac
Compare
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
pkg/webhook/cspc.go
Outdated
return response | ||
} | ||
for _, cspiObj := range cspiList.Items { | ||
cvrList, err := cvr.NewKubeclient().WithNamespace(cspiObj.Namespace).List(metav1.ListOptions{ |
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.
CVRs seems to be created in openebs namespace rather than cspiObj namespace.. so, list can fail here
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.
As the same container is having controllers for CSPI
and CVR
, shouldn't they be created in same namespace?
Signed-off-by: shubham <[email protected]>
for i, rule := range config.Webhooks[0].Rules { | ||
if util.ContainsString(rule.Rule.Resources, "cstorpoolclusters") { | ||
index = i | ||
} |
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.
add a 'break'
Signed-off-by: shubham <[email protected]>
889826b
to
9a5cc80
Compare
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
Signed-off-by: shubham [email protected]
What this PR does / why we need it:
This PR adds validation for cspc deletion. When a volume is still present on the cspc pool the deletion of cspc should not be allowed.
mayadata:setup$ k delete cspc --all Error from server (BadRequest): admission webhook "admission-webhook.openebs.io" denied the request: invalid cspc sparse-pool-1 deletion: volume still exists on pool sparse-pool-1-ff87
This PR also fixes the pre-upgrade cleanup or update of webhook secret, service, and validator.
Which issue this PR fixes (optional, in
fixes #<issue number>(, fixes #<issue_number>, ...)
format, will close that issue when PR gets merged): fixes #Special notes for your reviewer:
Checklist:
documentation
tagbreaking-changes
tagrequires-upgrade
tag