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

Determine ingress backend service by parsing addressable URI #10197

Merged
merged 2 commits into from
Nov 25, 2020

Conversation

julz
Copy link
Member

@julz julz commented Nov 25, 2020

Part of #9713.

Properly parses the backend service to use from the resolved Addressable URI rather than assuming it's named the same as the ref. This assumes the resolved address is of the form {name}.{namespace}.svc.{cluster.local.suffix}, and validates that this is the case. I think this should be fine for most things we care about - when we want to support other types of targets we'll need to synthesise an ExternalName, but that's left for a future PR.

Note: as of now the validation will still (now unnecessarily) insist the target is a ksvc; I'll relax that in the next PR.

/assign @mattmoor @vagababov

@google-cla google-cla bot added the cla: yes Indicates the PR's author has signed the CLA. label Nov 25, 2020
@knative-prow-robot knative-prow-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Nov 25, 2020
@knative-prow-robot knative-prow-robot added the area/API API objects and controllers label Nov 25, 2020
@codecov
Copy link

codecov bot commented Nov 25, 2020

Codecov Report

Merging #10197 (45ff26b) into master (2e457fa) will increase coverage by 0.06%.
The diff coverage is 76.31%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #10197      +/-   ##
==========================================
+ Coverage   88.04%   88.10%   +0.06%     
==========================================
  Files         184      184              
  Lines        8621     8611      -10     
==========================================
- Hits         7590     7587       -3     
+ Misses        789      787       -2     
+ Partials      242      237       -5     
Impacted Files Coverage Δ
cmd/queue/main.go 0.50% <0.00%> (-0.01%) ⬇️
pkg/autoscaler/statserver/server.go 79.61% <ø> (+1.23%) ⬆️
pkg/reconciler/domainmapping/resources/ingress.go 100.00% <ø> (ø)
pkg/reconciler/service/service.go 85.10% <90.90%> (+6.19%) ⬆️
pkg/reconciler/domainmapping/reconciler.go 89.18% <100.00%> (+0.61%) ⬆️
pkg/reconciler/route/traffic/rollout.go 100.00% <100.00%> (ø)
pkg/reconciler/service/resources/configuration.go 100.00% <100.00%> (ø)
pkg/reconciler/service/resources/route.go 100.00% <100.00%> (ø)
pkg/reconciler/autoscaling/kpa/scaler.go 88.57% <0.00%> (-1.43%) ⬇️
pkg/reconciler/configuration/configuration.go 85.93% <0.00%> (-0.79%) ⬇️

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 2e457fa...1963348. Read the comment docs.

// TODO(julz) in the future we may support addressables that are not created
// from Services, in which case we would need to dynamically create the
// an ExternalName Service for the KIngress to use.
requiredSuffix := ".svc." + network.GetClusterDomainName()
Copy link
Contributor

Choose a reason for hiding this comment

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

this looks like something that can be precomputed as global var requiredSuffix ...

Copy link
Member Author

Choose a reason for hiding this comment

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

theoretically yeah but in practice the method has a once.Do inside it anyway. Doesn't look like we pre-compute in any of the other various places we use it, e.g.

system.Namespace(), network.GetClusterDomainName(), ssc.Port)
,
return "svc." + network.GetClusterDomainName()
,
return strings.HasSuffix(domain, pkgnet.GetClusterDomainName())

Copy link
Contributor

Choose a reason for hiding this comment

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

One has to start somewhere :)

@@ -138,26 +138,43 @@ func (r *Reconciler) reconcileIngress(ctx context.Context, dm *v1alpha1.DomainMa
return ingress, err
}

func (r *Reconciler) resolveRef(ctx context.Context, dm *v1alpha1.DomainMapping) (*apis.URL, error) {
func (r *Reconciler) resolveRef(ctx context.Context, dm *v1alpha1.DomainMapping) (host string, backendSvc string, err error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
func (r *Reconciler) resolveRef(ctx context.Context, dm *v1alpha1.DomainMapping) (host string, backendSvc string, err error) {
func (r *Reconciler) resolveRef(ctx context.Context, dm *v1alpha1.DomainMapping) (host, backendSvc string, err error) {

@vagababov
Copy link
Contributor

/lgtm
/approve

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

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: julz, vagababov

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 added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Nov 25, 2020
@knative-prow-robot knative-prow-robot merged commit 280e3a5 into knative:master Nov 25, 2020
nak3 pushed a commit to nak3/serving that referenced this pull request Jan 21, 2021
…#10197)

* Determine ingress backend service by parsing URI

* nit
nak3 pushed a commit to nak3/serving that referenced this pull request Jan 21, 2021
…#10197)

* Determine ingress backend service by parsing URI

* nit
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/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.

4 participants