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 --disable-catch-all #3698

Merged
merged 1 commit into from
Jan 25, 2019

Conversation

alexkursell
Copy link
Contributor

What this PR does / why we need it:
The --disable-catch-all flag that was recently added in #3586 is supposed to disallow ingresses that create a catch all server. Normally, a catch all server is created only if an ingress both defines a default backend and has no rules, however the flag disallows any ingress that just defines a default backend. The result is that ingresses like this are blocked by the flag:

spec:
  backend:
    serviceName: echo-service
    servicePort: 8080
  rules:
  - host: example.com
    http:
      paths:
        - path: /testpath
          backend:
            serviceName: other-service
            servicePort: 5678

This PR tightens the circumstances under which the flag causes an ingress to be ignored from spec.Backend != nil to spec.Backend != nil && len(spec.Rules) == 0, as well as adding a test for the new behaviour.

cc: @ElvinEfendi

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jan 25, 2019
// CreatesCatchAll returns whether or not an ingress creates a catch-all backend
func CreatesCatchAll(spec extensions.IngressSpec) bool {
return spec.Backend != nil && len(spec.Rules) == 0
}
Copy link
Member

Choose a reason for hiding this comment

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

What about implementing the whole logic here - including disableCatchAll flag check here.

Copy link
Contributor

@wayt wayt Jan 25, 2019

Choose a reason for hiding this comment

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

agreed but I'd change the function name to something like IsAllowedIngress. wdyt?

@@ -617,6 +617,11 @@ func New(checkOCSP bool,
return store
}

// CreatesCatchAll returns whether or not an ingress creates a catch-all backend
func CreatesCatchAll(spec extensions.IngressSpec) bool {
return spec.Backend != nil && len(spec.Rules) == 0
Copy link
Contributor

Choose a reason for hiding this comment

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

Are we sure there is no case where len(spec.Rules) > 0 and it's still a catch-all Ingress?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@ElvinEfendi
Copy link
Member

LGTM, please squash your commits into one before we merge this.

@alexkursell alexkursell force-pushed the fix-disable-catch-all branch from c3dcfd4 to ca74960 Compare January 25, 2019 19:54
@ElvinEfendi
Copy link
Member

/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jan 25, 2019
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: alexkursell, ElvinEfendi

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 Jan 25, 2019
@k8s-ci-robot k8s-ci-robot merged commit 6618b39 into kubernetes:master Jan 25, 2019
@ElvinEfendi ElvinEfendi deleted the fix-disable-catch-all branch January 25, 2019 21:25
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. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", 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.

4 participants