这是indexloc提供的服务,不要输入任何密码
Skip to content

Add domainmapping name validation #10379

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

Merged
merged 1 commit into from
Dec 31, 2020

Conversation

nak3
Copy link
Contributor

@nak3 nak3 commented Dec 16, 2020

This patch adds domain validation by k8s's IsFullyQualifiedDomainName.
Currently It is easy to create invalid domain by DomainMapping.

For example, this domainmapping

cat <<EOF | kubectl apply -f - 
apiVersion: serving.knative.dev/v1alpha1
kind: DomainMapping
metadata:
 name: mydomain
 namespace: default
spec:
 ref:
   name: hello-example
   kind: Service
   apiVersion: serving.knative.dev/v1
EOF

will get the following validation error.

Error from server (BadRequest): error when creating "STDIN": admission webhook "validation.webhook.domainmapping.serving.knative.dev" denied the request: validation failed: invalid name "mydomain": name: Invalid value: "mydomain": should be a domain with at least two segments separated by dots: metadata.name

Release Note

DomainMapping name is validated if the domain name is fully qualified.

/cc @julz @markusthoemmes @dprotaso

This patch adds domain validation by k8s's IsFullyQualifiedDomainName.
It is easy to create custom domain by current DomainMapping.
@google-cla google-cla bot added the cla: yes Indicates the PR's author has signed the CLA. label Dec 16, 2020
@knative-prow-robot knative-prow-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. area/API API objects and controllers approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Dec 16, 2020
@codecov
Copy link

codecov bot commented Dec 16, 2020

Codecov Report

Merging #10379 (e10058c) into master (0a24aef) will increase coverage by 0.05%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #10379      +/-   ##
==========================================
+ Coverage   87.99%   88.04%   +0.05%     
==========================================
  Files         186      186              
  Lines        8720     8767      +47     
==========================================
+ Hits         7673     7719      +46     
- Misses        810      811       +1     
  Partials      237      237              
Impacted Files Coverage Δ
.../apis/serving/v1alpha1/domainmapping_validation.go 100.00% <100.00%> (ø)
pkg/reconciler/autoscaling/kpa/scaler.go 88.57% <0.00%> (-1.43%) ⬇️
pkg/reconciler/route/resources/ingress.go 96.68% <0.00%> (-0.12%) ⬇️
pkg/apis/serving/fieldmask.go 95.48% <0.00%> (+0.01%) ⬆️
pkg/autoscaler/scaling/autoscaler.go 97.88% <0.00%> (+0.24%) ⬆️
pkg/apis/config/features.go 93.75% <0.00%> (+0.41%) ⬆️
pkg/reconciler/configuration/configuration.go 88.28% <0.00%> (+1.56%) ⬆️

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 0a24aef...e10058c. Read the comment docs.

@nak3
Copy link
Contributor Author

nak3 commented Dec 17, 2020

/retest

Copy link
Contributor

@tcnghia tcnghia left a comment

Choose a reason for hiding this comment

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

/lgtm

@knative-prow-robot knative-prow-robot added the lgtm Indicates that a PR is ready to be merged. label Dec 31, 2020
@knative-prow-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: nak3, tcnghia

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

@knative-prow-robot knative-prow-robot merged commit 07b9faa into knative:master Dec 31, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. area/API API objects and controllers cla: yes Indicates the PR's author has signed the CLA. lgtm Indicates that a PR is ready to be merged. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants