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

Add validation on akodeploymentconfig avi fields in webhook #94

Merged
merged 11 commits into from
Jun 27, 2022

Conversation

XudongLiuHarold
Copy link
Member

@XudongLiuHarold XudongLiuHarold commented Jun 15, 2022

Signed-off-by: Xudong Liu xudongl@vmware.com

What this PR does / why we need it:
When users create or update AKODeploymentConfig objects, add validation on those changed fields, to ensure those input fields are validate and format is correct.

  • check cluster selector format is correct or not
  • check Avi controller, credentials, certificate is correct or not
  • check Avi cloud, service engine group, networks existing or not
  • check Avi network's subnet cidr format is correct or not

Which issue(s) this PR fixes:

Fixes #

Describe testing done for PR:

  • unit test cases passed
  • integration test cases passed
  • Manually e2e tested:
kubo@ubuntu-2004:~$ k apply -f test-adc.yaml
The AKODeploymentConfig "install-ako-for-test" is invalid:
* spec.ClusterSelector: Invalid value: v1.LabelSelector{MatchLabels:map[string]string(nil), MatchExpressions:[]v1.LabelSelectorRequirement(nil)}: field should not be empty for non-default ADC
* spec.tkg-system-networking/avi-controller-credential: Invalid value: "avi-controller-credential": can't find secret
* spec.tkg-system-networking/avi-controller-c: Invalid value: "avi-controller-c": can't find secret

kubo@ubuntu-2004:~$ k apply -f test-adc.yaml
The AKODeploymentConfig "install-ako-for-test" is invalid:
* spec.cloudName: Invalid value: "Default-Clouda": failed to get cloud from avi controller:No object of type cloud with name Default-Cloudais found
* spec.controlPlaneNetwork.name: Invalid value: "VM Networkd": failed to get control plane network VM Networkd from avi controller:No object of type network with name VM Networkdis found
* spec.dataNetwork.name: Invalid value: "VM Networkf": failed to get data plane network VM Networkf from avi controller:No object of type network with name VM Networkfis found
* spec.dataNetwork.name: Invalid value: "VM Networkf": failed to get data plane network VM Networkf from avi controller:No object of type network with name VM Networkfis found

Special notes for your reviewer:

Release note:

AKODeploymentConfig object's input fields will be checked when users create or update those objects.

New PR Checklist

  • Ensure PR contains only public links or terms
  • Use good commit messages
  • Squash the commits in this branch before merge to preserve our git history
  • If this PR is just an idea or POC, use a Draft PR instead of a full PR
  • Add appropriate labels according to what type of issue is being addressed.

@XudongLiuHarold XudongLiuHarold force-pushed the add-avi-validation-in-webhook branch 2 times, most recently from 185e92c to 02317b1 Compare June 15, 2022 22:25
@XudongLiuHarold XudongLiuHarold changed the title add validation on akodeploymentconfig avi fields in webhook Add validation on akodeploymentconfig avi fields in webhook Jun 15, 2022
@XudongLiuHarold XudongLiuHarold added the kind/enhancement enhancement on repo or code quality label Jun 15, 2022
@XudongLiuHarold XudongLiuHarold marked this pull request as ready for review June 19, 2022 05:17
Xudong Liu added 8 commits June 18, 2022 22:23
Signed-off-by: Xudong Liu <xudongl@vmware.com>
Signed-off-by: Xudong Liu <xudongl@vmware.com>
Signed-off-by: Xudong Liu <xudongl@vmware.com>
Signed-off-by: Xudong Liu <xudongl@vmware.com>
Signed-off-by: Xudong Liu <xudongl@vmware.com>
Signed-off-by: Xudong Liu <xudongl@vmware.com>
Signed-off-by: Xudong Liu <xudongl@vmware.com>
Signed-off-by: Xudong Liu <xudongl@vmware.com>
@codecov-commenter
Copy link

codecov-commenter commented Jun 19, 2022

Codecov Report

Merging #94 (01581fb) into main (9d7eba5) will increase coverage by 9.67%.
The diff coverage is 82.88%.

@@            Coverage Diff             @@
##             main      #94      +/-   ##
==========================================
+ Coverage   16.31%   25.99%   +9.67%     
==========================================
  Files          29       22       -7     
  Lines        2568     2270     -298     
==========================================
+ Hits          419      590     +171     
+ Misses       2115     1627     -488     
- Partials       34       53      +19     
Impacted Files Coverage Δ
api/v1alpha1/akodeploymentconfig_webhook.go 82.03% <82.88%> (+12.80%) ⬆️
e2e/pkg/env/avi.go
e2e/pkg/env/tkg.go
e2e/pkg/env/vip.go
e2e/pkg/env/env.go
e2e/pkg/env/kubectl.go
e2e/pkg/env/io.go
e2e/pkg/env/assertions.go
api/v1alpha1/zz_generated.deepcopy.go 16.98% <0.00%> (+16.98%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 9d7eba5...01581fb. Read the comment docs.

Xudong Liu added 2 commits June 18, 2022 22:58
Signed-off-by: Xudong Liu <xudongl@vmware.com>
Signed-off-by: Xudong Liu <xudongl@vmware.com>
@HanFa
Copy link
Contributor

HanFa commented Jun 27, 2022

this is great, can we formulate the validation rule as a readme under <proj_root>/docs?

@XudongLiuHarold
Copy link
Member Author

this is great, can we formulate the validation rule as a readme under <proj_root>/docs?

Sure thing, that is the next step, the document

Signed-off-by: Xudong Liu <xudongl@vmware.com>
@HanFa HanFa merged commit 3231743 into main Jun 27, 2022
@HanFa HanFa deleted the add-avi-validation-in-webhook branch June 27, 2022 20:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla-not-required kind/enhancement enhancement on repo or code quality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants