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

Prepare queue healthHandler for optional aggressive retries #4649

Merged
merged 5 commits into from
Jul 9, 2019

Conversation

joshrider
Copy link
Contributor

Co-authored-by: Shash Reddy [email protected]

Support #4014
One of many parts, spun out from #4600

Proposed Changes

  • Update queue health package to include TCP and HTTP retries and pave way for user-defined readinessProbes from the queue-proxy.
  • Following PRs will use this package.

Release Note


@googlebot
Copy link

So there's good news and bad news.

👍 The good news is that everyone that needs to sign a CLA (the pull request submitter and all commit authors) have done so. Everything is all good there.

😕 The bad news is that it appears that one or more commits were authored or co-authored by someone other than the pull request submitter. We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that here in the pull request.

Note to project maintainer: This is a terminal state, meaning the cla/google commit status will not change from this state. It's up to you to confirm consent of all the commit author(s), set the cla label to yes (if enabled on your project), and then merge this pull request when appropriate.

ℹ️ Googlers: Go here for more info.

@googlebot googlebot added the cla: no Indicates the PR's author has not signed the CLA. label Jul 8, 2019
@knative-prow-robot knative-prow-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Jul 8, 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.

@joshrider: 1 warning.

In response to this:

Co-authored-by: Shash Reddy [email protected]

Support #4014
One of many parts, spun out from #4600

Proposed Changes

  • Update queue health package to include TCP and HTTP retries and pave way for user-defined readinessProbes from the queue-proxy.
  • Following PRs will use this package.

Release Note


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.

pkg/queue/health/probe.go Show resolved Hide resolved
cmd/queue/main.go Outdated Show resolved Hide resolved
cmd/queue/main.go Outdated Show resolved Hide resolved
pkg/queue/health/health_state.go Outdated Show resolved Hide resolved
pkg/queue/health/probe.go Outdated Show resolved Hide resolved
},
Timeout: config.Timeout,
}
url := fmt.Sprintf("%s://%s:%d%s", config.Scheme, config.Host, config.Port.IntValue(), config.Path)
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not construct url.URL object and then use its String method?

Copy link
Contributor

@shashwathi shashwathi Jul 8, 2019

Choose a reason for hiding this comment

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

If we build url.URL object then would we end up with something like below

	url := url.URL{
		Scheme: fmt.Sprintf("%s", config.Scheme),
		Host:   fmt.Sprintf("%s:%d", config.Host, config.Port.IntValue()),
		Path:   config.Path,
	}

Not sure if we gain anything by making building URL object.

Copy link
Contributor

Choose a reason for hiding this comment

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

Well:

  1. Scheme can be just assigned (no need to sprintf)
  2. Host is just config.Host + ":" + config.Port.String() (no need to sprintf)
  3. you don't have to deal with validating slashes "/" (you don't currently, so in fact a wrong URL can be built)

Copy link
Contributor

Choose a reason for hiding this comment

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

Scheme can be just assigned (no need to sprintf)

config.Scheme is not string type so that needs to be converted.

I agree with the rest so I will update

Copy link
Contributor

Choose a reason for hiding this comment

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

URIScheme is string alias. So just string(config.Scheme) will do.

pkg/queue/health/probe.go Outdated Show resolved Hide resolved
pkg/queue/health/probe.go Outdated Show resolved Hide resolved
pkg/queue/health/probe.go Outdated Show resolved Hide resolved
pkg/queue/health/probe.go Show resolved Hide resolved
@shashwathi
Copy link
Contributor

@vagababov : Addressed your comments. Ready for another review 👍

pkg/queue/health/probe.go Show resolved Hide resolved
}

if !IsHTTPProbeReady(res) {
return errors.New("HTTP probe did not respond Ready")
Copy link
Member

Choose a reason for hiding this comment

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

Feels like this should include the status code 🤔

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.

Mostly cosmetic from me.

@@ -95,7 +97,7 @@ func (h *State) HealthHandler(prober func() bool) func(w http.ResponseWriter, r
}

switch {
case h.IsAlive():
case isNotAggressive && h.IsAlive():
Copy link
Contributor

Choose a reason for hiding this comment

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

I kind of envisioned the change to be !isAggressive here. But I guess this works also :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

will brainstorm a more descriptive name and update in future 🤔

@@ -249,7 +253,8 @@ func handler(reqChan chan queue.ReqEvent, breaker *queue.Breaker, handler http.H
// Sets up /health and /wait-for-drain endpoints.
func createAdminHandlers() *http.ServeMux {
mux := http.NewServeMux()
mux.HandleFunc(requestQueueHealthPath, healthState.HealthHandler(probeUserContainer))
// TODO(@joshrider): temporary change while waiting on other PRs to merge (See #4014)
mux.HandleFunc(requestQueueHealthPath, healthState.HealthHandler(probeUserContainer, true /*isNotAggressive is set to true to piggyback on previous success and not aggressively retry everytime*/))
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
mux.HandleFunc(requestQueueHealthPath, healthState.HealthHandler(probeUserContainer, true /*isNotAggressive is set to true to piggyback on previous success and not aggressively retry everytime*/))
mux.HandleFunc(requestQueueHealthPath, healthState.HealthHandler(probeUserContainer, true /*isNotAggressive*/))

Timeout: config.Timeout,
}
url := url.URL{
Scheme: fmt.Sprintf("%s", config.Scheme),
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
Scheme: fmt.Sprintf("%s", config.Scheme),
Scheme: string(config.Scheme),

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.

Couple comments still inline seem relevant

@joshrider
Copy link
Contributor Author

On the case 👍

pkg/queue/health/probe.go Show resolved Hide resolved
pkg/queue/health/probe.go Outdated Show resolved Hide resolved
pkg/queue/health/probe_test.go Outdated Show resolved Hide resolved
@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/queue/health/probe.go 100.0% 90.9% -9.1

@mattmoor
Copy link
Member

mattmoor commented Jul 9, 2019

/lgtm
/approve

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

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: joshrider, 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

@mattmoor mattmoor added cla: yes Indicates the PR's author has signed the CLA. and removed cla: no Indicates the PR's author has not signed the CLA. labels Jul 9, 2019
@knative-prow-robot knative-prow-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jul 9, 2019
@googlebot
Copy link

A Googler has manually verified that the CLAs look good.

(Googler, please make sure the reason for overriding the CLA status is clearly documented in these comments.)

ℹ️ Googlers: Go here for more info.

@knative-prow-robot knative-prow-robot merged commit 82596a8 into knative:master Jul 9, 2019
@joshrider joshrider deleted the queue-health branch August 6, 2019 15:17
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/networking 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.

7 participants