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

fix(cspc, webhook): add validation for cspc deletion #1594

Merged
merged 9 commits into from
Jan 29, 2020

Conversation

shubham14bajpai
Copy link
Contributor

@shubham14bajpai shubham14bajpai commented Jan 24, 2020

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:

  • Fixes #
  • Labelled this PR & related issue with documentation tag
  • PR messages has document related information
  • Labelled this PR & related issue with breaking-changes tag
  • PR messages has breaking changes related information
  • Labelled this PR & related issue with requires-upgrade tag
  • PR messages has upgrade related information
  • Commit has unit tests
  • Commit has integration tests

Copy link

@mittachaitu mittachaitu left a comment

Choose a reason for hiding this comment

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

provided comments

@@ -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() {

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?

Copy link
Contributor

@prateekpandey14 prateekpandey14 Jan 27, 2020

Choose a reason for hiding this comment

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

No, we should not

@@ -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() {

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

Copy link
Contributor

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

pkg/webhook/configuration.go Outdated Show resolved Hide resolved
pkg/webhook/configuration.go Outdated Show resolved Hide resolved
pkg/webhook/configuration.go Outdated Show resolved Hide resolved
Copy link
Contributor

@prateekpandey14 prateekpandey14 left a comment

Choose a reason for hiding this comment

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

lgtm

Copy link

@mittachaitu mittachaitu left a 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

pkg/kubernetes/service/v1alpha1/kubernetes.go Outdated Show resolved Hide resolved
pkg/kubernetes/secret/kubernetes.go Outdated Show resolved Hide resolved
pkg/webhook/configuration.go Outdated Show resolved Hide resolved
Copy link

@mittachaitu mittachaitu left a comment

Choose a reason for hiding this comment

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

changes are good

return response
}
for _, cspiObj := range cspiList.Items {
cvrList, err := cvr.NewKubeclient().WithNamespace(cspiObj.Namespace).List(metav1.ListOptions{
Copy link
Contributor

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

Copy link
Contributor Author

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?

for i, rule := range config.Webhooks[0].Rules {
if util.ContainsString(rule.Rule.Resources, "cstorpoolclusters") {
index = i
}
Copy link
Contributor

Choose a reason for hiding this comment

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

add a 'break'

Copy link
Contributor

@vishnuitta vishnuitta left a comment

Choose a reason for hiding this comment

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

changes are good

@vishnuitta vishnuitta merged commit 626a647 into openebs-archive:master Jan 29, 2020
@kmova kmova added this to the 1.7.0 milestone Feb 4, 2020
@shubham14bajpai shubham14bajpai deleted the cspc_webhook branch March 17, 2020 06:09
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.

6 participants