Skip to content
This repository has been archived by the owner on Apr 25, 2023. It is now read-only.

Webhook checking for KubeFedConfig #941

Merged
merged 5 commits into from
Jun 7, 2019

Conversation

xunpan
Copy link
Contributor

@xunpan xunpan commented May 29, 2019

This is not ready to review until #914 is merged and I rebase the code with UT developed.

I also fix a minor non-function helm chart related issue: make clusterrole in clusterrole.yaml. It is not functional change, so I use a single commit instead of a new PR.

Fixes #916

@k8s-ci-robot k8s-ci-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels May 29, 2019
@k8s-ci-robot k8s-ci-robot requested review from marun and onyiny-ang May 29, 2019 03:07
@marun
Copy link
Contributor

marun commented May 30, 2019

Please rebase.

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label May 30, 2019
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label May 31, 2019
@xunpan
Copy link
Contributor Author

xunpan commented May 31, 2019

rebase done and basic test passed.

I'm adding test now

@xunpan xunpan force-pushed the webhook branch 4 times, most recently from d4dea93 to 5cb33ac Compare June 3, 2019 13:41
@xunpan xunpan changed the title WIP Webhook checking for KubeFedConfig Webhook checking for KubeFedConfig Jun 3, 2019
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jun 3, 2019
@marun
Copy link
Contributor

marun commented Jun 3, 2019

CI failure looks like a potential flake.

@xunpan
Copy link
Contributor Author

xunpan commented Jun 4, 2019

Not sure details but make CI passed by adding scope: Cluster. I'm checking it.

@xunpan
Copy link
Contributor Author

xunpan commented Jun 4, 2019

webhook reject scope is empty case. This is because we had no default value setting in webhook and the old default setting does not set value for scope but expected it to be set in .yaml file.

add scope can make it work.

Copy link
Contributor

@marun marun left a comment

Choose a reason for hiding this comment

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

Yay validation!

}
if elect.RenewDeadline.Duration <= time.Duration(float64(elect.RetryPeriod.Duration)*leaderelection.JitterFactor) {
allErrs = append(allErrs, field.Invalid(electPath.Child("renewDeadline"), elect.RenewDeadline,
"renewDeadline must be greater than retryPeriod*JitterFactor"))
Copy link
Contributor

Choose a reason for hiding this comment

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

Please include the jitter factor in the message.

Also, is there a reason the jitter factor isn't configurable?

cc: @shashidharatd

Copy link
Contributor

Choose a reason for hiding this comment

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

Seems JitterFactor is agreed upon constant https://github.com/kubernetes/kubernetes/blob/master/staging/src/k8s.io/client-go/tools/leaderelection/leaderelection.go#L72 and is not exposed by the leader election library. lets keep it like that for now.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok, so it should remain non-configurable. Is there a reason it should not be exposed in the error message though? I think the value should either be explicitly mentioned in the error message or mention of JitterFactor removed.


gates := spec.FeatureGates
gatesPath := specPath.Child("featureGates")
for _, gate := range gates {
Copy link
Contributor

Choose a reason for hiding this comment

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

Please ensure that a gate appears at most once.

pkg/webhook/webhook.go Show resolved Hide resolved
@xunpan
Copy link
Contributor Author

xunpan commented Jun 5, 2019

Done:

  1. duplicated feature checking in featureGates
  2. add test case for duplicated features
  3. reorder test cases with struct definition order

Copy link
Contributor

@marun marun left a comment

Choose a reason for hiding this comment

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

Functionally this looks fine, and I'm going to merge it. Please ensure that variable names in the unit test reflect their contents (i.e. if a variable is going to be configured to contain an invalid value, it should be prefixed with invalid rather than valid).

/approve
/lgtm

validElectorResourceLock.Spec.LeaderElect.ResourceLock = "NeitherConfigmapsOrEndpoints"
errorCases["spec.leaderElect.resourceLock: Unsupported value"] = validElectorResourceLock

validFeatureGateName := validKubeFedConfig()
Copy link
Contributor

Choose a reason for hiding this comment

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

This is a bad feature gate name.


errorCases := map[string]*v1beta1.KubeFedConfig{}

validScope := validKubeFedConfig()
Copy link
Contributor

Choose a reason for hiding this comment

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

This is an invalid scope

@k8s-ci-robot k8s-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Jun 7, 2019
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: marun, xunpan

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jun 7, 2019
@k8s-ci-robot k8s-ci-robot merged commit 46e221e into kubernetes-retired:master Jun 7, 2019
k8s-ci-robot added a commit that referenced this pull request Jun 7, 2019
Fix lint errors introduced by #966 and #941 merging without rebase
@xunpan xunpan deleted the webhook branch June 9, 2019 23:47
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm Indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Validations for KubefedConfig API
5 participants