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 URL to TrafficTarget Status #3526

Merged
merged 7 commits into from
Mar 29, 2019

Conversation

dgerd
Copy link

@dgerd dgerd commented Mar 25, 2019

This change adds URL to the output of each named Traffic Target. The URL
is prefixed with a scheme. Currently we only support subdomains for
named traffic targets and 'http' as the scheme. However, this change enables
clients to grab the URL from the API rather than making assumptions on
scheme and URL format which paves the way for operator customization.

Fixes #3450

Release Note

URL is now present on Status.Traffic entries that have "name" specified.

This change adds URL to the output of each named Traffic Target. The URL
is prefixed with a scheme. Currently we only support subdomains for
named traffic targets and 'http' as the scheme. However, this change enables
clients to grab the URL from the API rather than making assumptions on
scheme and URL format which paves the way for operator customization.

Fixes knative#3450
@knative-prow-robot knative-prow-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. area/API API objects and controllers area/networking area/test-and-release It flags unit/e2e/conformance/perf test issues for product features labels Mar 25, 2019
Copy link
Contributor

@knative-prow-robot knative-prow-robot left a comment

Choose a reason for hiding this comment

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

@dgerd: 1 warning.

In response to this:

This change adds URL to the output of each named Traffic Target. The URL
is prefixed with a scheme. Currently we only support subdomains for
named traffic targets and 'http' as the scheme. However, this change enables
clients to grab the URL from the API rather than making assumptions on
scheme and URL format which paves the way for operator customization.

Fixes #3450

Release Note

URL is now present on Status.Traffic entries that have "name" specified.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

* Add domain as status update in route reconciler test
* Switch back to using K8sServiceFullname instead of Address.Hostname
* Unexport scheme
@dgerd
Copy link
Author

dgerd commented Mar 26, 2019

Created an issue ( knative/docs#1078 ) to update docs when this is merged.

Also created an issue to expand our scheme support from HTTP ( #3527 ).

@mattmoor mattmoor added this to the Serving 0.5 milestone Mar 27, 2019
if tt.Name == blue.TrafficTarget {
// Strip prefix as WaitForEndPointState expects a domain
// without scheme.
blueDomain = strings.TrimPrefix(tt.URL, "http://")
Copy link
Member

Choose a reason for hiding this comment

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

Perhaps use "net/url" to parse the URL and extract the host?

Copy link
Author

@dgerd dgerd Mar 27, 2019

Choose a reason for hiding this comment

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

I prefer this for now as it is the opposite of what "WaitForEndpoingState" is doing. However, "WaitForEndpointState" needs to be fixed.

I would like to follow up and update pkg to not do url.Parse(fmt.Sprintf("http://%s", theURL)). There is a fallback to asURL, err = url.Parse(theURL); however, due to the parsing behavior the fallback does not actually work.

Once pkg is updated this can be removed entirely.

greenDomain = strings.TrimPrefix(tt.URL, "http://")
}
}
if blueDomain == "" || greenDomain == "" {
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we want to validate the actual values?

Copy link
Author

Choose a reason for hiding this comment

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

For conformance I don't want to validate how the sub-route domains get formed (i.e. "green.ksvc.domain.com" or "green-ksvc.domain.com").

I could use url.Parse() and make sure a domain comes out, but I am not in love with the validation, and we do not do anything similar for route.Status.Domain in any of our e2e tests.

If the url is not empty and the domain is invalid the problem should be fairly easy to spot with existing output. It should look something like:

util.go:210: For domain green.blue-green-route-nfluhlbe.serving-tests.example.com: wanted at least 50, got 0 requests.

Copy link
Contributor

@vagababov vagababov 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 Mar 27, 2019
@ZhiminXiang
Copy link

/lgtm

@dgerd
Copy link
Author

dgerd commented Mar 27, 2019

/test pull-knative-serving-integration-tests

@knative-prow-robot knative-prow-robot removed the lgtm Indicates that a PR is ready to be merged. label Mar 28, 2019
@dgerd dgerd force-pushed the 3450-url-status branch from ed5039f to 8962f7c Compare March 28, 2019 18:37
@dgerd dgerd force-pushed the 3450-url-status branch from 8962f7c to d3ea04c Compare March 28, 2019 21:09
@dgerd
Copy link
Author

dgerd commented Mar 28, 2019

Forgot to clear cache before testing/building locally. Should be good now.

@dgerd
Copy link
Author

dgerd commented Mar 28, 2019

/test pull-knative-serving-integration-tests

@googlebot googlebot added the cla: yes Indicates the PR's author has signed the CLA. label Mar 28, 2019
@dgerd
Copy link
Author

dgerd commented Mar 28, 2019

/test pull-knative-serving-integration-tests

@vagababov
Copy link
Contributor

/lgtm

@knative-prow-robot knative-prow-robot added the lgtm Indicates that a PR is ready to be merged. label Mar 29, 2019
@knative-prow-robot knative-prow-robot removed the lgtm Indicates that a PR is ready to be merged. label Mar 29, 2019
Copy link
Contributor

@vagababov vagababov 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 Mar 29, 2019
return p.String() == "URL"
},
cmp.Ignore(),
)
Copy link
Member

Choose a reason for hiding this comment

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

opt -> ignoreURLs?

@knative-prow-robot knative-prow-robot removed the lgtm Indicates that a PR is ready to be merged. label Mar 29, 2019
@knative-metrics-robot
Copy link

The following is the coverage report on pkg/.
Say /test pull-knative-serving-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/reconciler/v1alpha1/route/route.go 92.5% 92.4% -0.1
pkg/reconciler/v1alpha1/route/traffic/traffic.go 95.1% 95.4% 0.3
pkg/reconciler/v1alpha1/service/service.go 92.3% 92.5% 0.2

Copy link
Member

@mattmoor mattmoor left a comment

Choose a reason for hiding this comment

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

/lgtm
/approve

@knative-prow-robot knative-prow-robot added the lgtm Indicates that a PR is ready to be merged. label Mar 29, 2019
@knative-prow-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: dgerd, mattmoor

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 Mar 29, 2019
@knative-prow-robot knative-prow-robot merged commit 538fc22 into knative:master Mar 29, 2019
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 area/networking area/test-and-release It flags unit/e2e/conformance/perf test issues for product features 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.

Add url to traffic status in Route and Service
8 participants