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

feat(validation): add webhook validations for CVC replica scale #1621

Merged
merged 7 commits into from
Mar 5, 2020

Conversation

mittachaitu
Copy link

@mittachaitu mittachaitu commented Feb 26, 2020

Signed-off-by: mittachaitu sai.chaithanya@mayadata.io

What this PR does / why we need it:
This PR adds validations for CVC update requests and also handles upgrade changes for the admission server controller(CVC scaling feature PR #1613).
This PR Covers Below Validations and Test Cases For CVC Update:

  • Reject the request if Replica Count was modified.
  • Reject the request if the repetition of pool names either under the spec or status of CVC.
  • Reject the request if the existing pool names were modified with new pool names.
  • Reject the request if Scaling(Up/Down) was triggered when one other request is in progress.
  • Reject the request if more than one replica was scaled down that one replica at a time for scale down.
  • Reject the request if status pool names don't exist under spec of existing CVC(etcd) or new CVC(for the first time update by the controller).

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

Signed-off-by: mittachaitu <sai.chaithanya@mayadata.io>
mittachaitu added 2 commits February 27, 2020 09:00
Signed-off-by: mittachaitu <sai.chaithanya@mayadata.io>
Signed-off-by: mittachaitu <sai.chaithanya@mayadata.io>
@mittachaitu mittachaitu added this to Pre-commits and Designs - Due: Feb 29th 2020 in 1.8 Release Tracker - Due Mar 15th. Feb 27, 2020
Signed-off-by: mittachaitu <sai.chaithanya@mayadata.io>
@prateekpandey14 prateekpandey14 changed the title feat(validation): add webhook validations for CVC feat(validation): add webhook validations for CVC replica scale Mar 2, 2020
@mittachaitu mittachaitu moved this from Pre-commits and Designs - Due: Feb 29th 2020 to RC1 - Due: Mar 5 2020 in 1.8 Release Tracker - Due Mar 15th. Mar 3, 2020
@@ -0,0 +1,199 @@
/*
Copyright 2019 The OpenEBS Authors.
Copy link
Contributor

Choose a reason for hiding this comment

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

2020 ?

if req.Operation == v1beta1.Update {
return wh.validateCVCUpdateRequest(req, getCVCObject)
}
klog.V(2).Info("Admission wehbook for CVC module not " +
Copy link
Contributor

Choose a reason for hiding this comment

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

change verbose level 4

Copy link
Contributor

@shubham14bajpai shubham14bajpai left a comment

Choose a reason for hiding this comment

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

Upgrade part lgtm

pkg/webhook/cvc.go Outdated Show resolved Hide resolved
pkg/webhook/cvc.go Outdated Show resolved Hide resolved
pkg/webhook/cvc.go Outdated Show resolved Hide resolved
pkg/webhook/cvc.go Outdated Show resolved Hide resolved
Signed-off-by: mittachaitu <sai.chaithanya@mayadata.io>
SetAllowed().
WithResultAsSuccess(http.StatusAccepted).AR
var cvcNewObj apis.CStorVolumeClaim
err := json.Unmarshal(req.Object.Raw, &cvcNewObj)
Copy link
Contributor

Choose a reason for hiding this comment

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

for this to work, upgrade of CVC should have been done?

Copy link
Author

Choose a reason for hiding this comment

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

Yes!! The user/Controller made an update call on CVC.

// on CVC status.
func validateStatusPoolList(cvcOldObj, cvcNewObj *apis.CStorVolumeClaim) error {
replicaPoolNames := []string{}
if len(cvcOldObj.Spec.Policy.ReplicaPoolInfo) == 0 &&
Copy link
Contributor

Choose a reason for hiding this comment

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

can we add validation that status should be Bound to allow any scaling operation to avoid this complex logic?

Copy link
Author

Choose a reason for hiding this comment

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

No this is particularly to verify the content of status with the spec (#1613 (comment) to incorporate this kind of cases). IMO we shouldn't validate the status(because the status will be updated only by the controllers).

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.

please note that we need one new attribute and validation for storage as well, similar to ReplicaCount

@mittachaitu
Copy link
Author

please note that we need one new attribute and validation for storage as well, similar to ReplicaCount

This is out of scope in this PR. It will be incorporated into newer API changes of CVC.

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

Signed-off-by: mittachaitu <sai.chaithanya@mayadata.io>
// If CVC Status is not bound then reject
if cvcOldObj.Status.Phase != apis.CStorVolumeClaimPhaseBound {
// If controller is updating pool info then new CVC will be in bound state
if cvcNewObj.Status.Phase != apis.CStorVolumeClaimPhaseBound &&
Copy link
Contributor

Choose a reason for hiding this comment

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

you can remove this check

Copy link
Author

Choose a reason for hiding this comment

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

@@ -130,6 +131,23 @@ func validatePoolListChanges(cvcOldObj, cvcNewObj *apis.CStorVolumeClaim) error
)
}
}
// Reject the request if someone perform scaling when CVC is not in Bound
Copy link
Contributor

Choose a reason for hiding this comment

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

move this new changes to top of function

Signed-off-by: mittachaitu <sai.chaithanya@mayadata.io>
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 7118ad1 into openebs-archive:master Mar 5, 2020
1.8 Release Tracker - Due Mar 15th. automation moved this from RC1 - Due: Mar 5 2020 to Done Mar 5, 2020
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.

None yet

4 participants