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

kncloudevents now uses a singleton http client #4465

Merged
merged 10 commits into from
Nov 5, 2020

Conversation

slinkydeveloper
Copy link
Contributor

Fix #4461

Signed-off-by: Francesco Guardiani francescoguard@gmail.com

Proposed Changes

  • Now every new message sender always reuse the same underlying client, whenever possible

Now every new message sender always reuse the same underlying client, whenever possible

Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
@google-cla google-cla bot added the cla: yes Indicates the PR's author has signed the CLA. label Nov 5, 2020
@knative-prow-robot knative-prow-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Nov 5, 2020
@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 5, 2020
@slinkydeveloper
Copy link
Contributor Author

This is an important fix, do we want it before or after the release?

@codecov
Copy link

codecov bot commented Nov 5, 2020

Codecov Report

Merging #4465 into master will increase coverage by 0.06%.
The diff coverage is 88.37%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #4465      +/-   ##
==========================================
+ Coverage   81.19%   81.25%   +0.06%     
==========================================
  Files         281      282       +1     
  Lines        7981     8003      +22     
==========================================
+ Hits         6480     6503      +23     
  Misses       1112     1112              
+ Partials      389      388       -1     
Impacted Files Coverage Δ
...econciler/inmemorychannel/dispatcher/controller.go 78.26% <20.00%> (ø)
pkg/kncloudevents/message_sender.go 78.00% <50.00%> (-1.67%) ⬇️
pkg/adapter/v2/main_message.go 32.50% <100.00%> (ø)
pkg/channel/message_dispatcher.go 77.31% <100.00%> (-0.24%) ⬇️
pkg/kncloudevents/http_client.go 100.00% <100.00%> (ø)
pkg/mtbroker/filter/filter_handler.go 78.78% <100.00%> (+0.26%) ⬆️
...iler/inmemorychannel/dispatcher/inmemorychannel.go 89.39% <100.00%> (+0.86%) ⬆️

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 44e2412...695cf4a. Read the comment docs.

Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
pkg/kncloudevents/http_client.go Outdated Show resolved Hide resolved

return &HTTPMessageSender{Client: client, Target: target}, nil
func NewHTTPMessageSenderWithTarget(target string) (*HTTPMessageSender, error) {
return &HTTPMessageSender{Client: getClient(), Target: target}, nil
Copy link
Contributor

Choose a reason for hiding this comment

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

Just an observation/thought, probably silly, but if we pass in here interface to how to get the client, we don't need the global resync at the cost of the doing the Read lock on the mutex guarding the client. This might make it easier to write tests also? Curious on what the overhead for a read mutex would be.

Copy link
Contributor Author

@slinkydeveloper slinkydeveloper Nov 5, 2020

Choose a reason for hiding this comment

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

I completely disagree with this idea 😄 Putting a lock, shared between all dispatchers in the instance, on the hot path, doesn't sound at all like a good idea IMO.

To be honest, I think the configuration of these http params shouldn't be allowed at all during the execution of the dispatcher. It should be a single read when the process is started and that's it. These are params that are usually configured only at setup time, when you "setup" the capacity of your deployments: you don't change it on fly.

If you do, then you expect in any case a sort of "downtime"... So what I did in this PR is that I've done the bare minimum to fix the issue, I would love to open later a discussions on these params and why they should be configurable only at startup (and not like watches)

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, just jotted it down :) I figured you'd be a fan :)
I'm curious also on how often these in practice need to change.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I guess never, hence my idea of removing that watch

Copy link
Contributor

Choose a reason for hiding this comment

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

If that complexity is not needed in the first place, removing it in another PR sounds like an excellent idea to me. Does anyone know if there is/was a use-case in Eventing for reconfiguring the transport on the fly?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
@antoineco
Copy link
Contributor

/lgtm

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

/hold for another pass

@knative-prow-robot knative-prow-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Nov 5, 2020
Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
@knative-prow-robot knative-prow-robot removed the lgtm Indicates that a PR is ready to be merged. label Nov 5, 2020
Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
@knative-metrics-robot
Copy link

The following is the coverage report on the affected files.
Say /test pull-knative-eventing-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/channel/message_dispatcher.go 86.4% 86.2% -0.2
pkg/kncloudevents/http_client.go Do not exist 100.0%
pkg/kncloudevents/message_sender.go 82.9% 82.9% -0.1
pkg/reconciler/inmemorychannel/dispatcher/controller.go 84.8% 79.4% -5.4

Copy link
Member

@matzew matzew 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 Nov 5, 2020
@knative-prow-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: matzew, slinkydeveloper

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:
  • OWNERS [matzew,slinkydeveloper]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@slinkydeveloper
Copy link
Contributor Author

/unhold

@knative-prow-robot knative-prow-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Nov 5, 2020
@knative-prow-robot knative-prow-robot merged commit 3e5eeab into knative:master Nov 5, 2020
@slinkydeveloper slinkydeveloper deleted the issues/4461 branch November 5, 2020 14:33
@slinkydeveloper
Copy link
Contributor Author

Backporting to 0.17 and 0.18

slinkydeveloper added a commit to slinkydeveloper/eventing that referenced this pull request Nov 5, 2020
Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
slinkydeveloper added a commit to slinkydeveloper/eventing that referenced this pull request Nov 5, 2020
Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
@slinkydeveloper
Copy link
Contributor Author

Backport 0.17 #4467 and 0.18 #4468

knative-prow-robot pushed a commit that referenced this pull request Nov 5, 2020
Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
matzew pushed a commit to matzew/eventing that referenced this pull request Nov 5, 2020
Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
knative-prow-robot pushed a commit that referenced this pull request Nov 5, 2020
Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
openshift-merge-robot pushed a commit to openshift/knative-eventing that referenced this pull request Nov 5, 2020
Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>

Co-authored-by: Francesco Guardiani <francescoguard@gmail.com>
matzew pushed a commit to matzew/eventing that referenced this pull request Nov 7, 2020
Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
matzew pushed a commit to openshift/knative-eventing that referenced this pull request Nov 7, 2020
Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
openshift-merge-robot pushed a commit to openshift/knative-eventing that referenced this pull request Nov 7, 2020
* Update pingsource-mt-adapter.yaml

* Like on 0.18.3, we skip the tracing tests

Signed-off-by: Matthias Wessendorf <mwessend@redhat.com>

* [release-0.18] Retry on network failures (knative#4454) (knative#4457)

* Retry on network failures (knative#4454)

Signed-off-by: Pierangelo Di Pilato <pierangelodipilato@gmail.com>

* nethttp -> http

Signed-off-by: Pierangelo Di Pilato <pierangelodipilato@gmail.com>

* Backport knative#4465 (knative#4468)

Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>

* [0.18] Backport knative#4466 (knative#4471)

* Remove double invocations to responseWriter.WriteHeader in filter handler (knative#4466)

* Fix knative#4464

Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>

* Docs

Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>

* Moar tests

Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>

* Linting

Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>

* Nit with metrics

Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>

(cherry picked from commit a6fc540)
Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>

* Nit

Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>

* fixed wrong marshall in apiserversouece which will fix the missing ceOverrides extension  (knative#4477) (knative#4480)

* fixed wrong marshall

* fixed UT

* [0.18] Readyness probe in broker ingress (knative#4483)

* Fix knative#4473

Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>

* Massage the filter yaml

Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>

Co-authored-by: Matthias Wessendorf <mwessend@redhat.com>
Co-authored-by: Pierangelo Di Pilato <pierangelodipilato@gmail.com>
Co-authored-by: Francesco Guardiani <francescoguard@gmail.com>
Co-authored-by: capri-xiyue <52932582+capri-xiyue@users.noreply.github.com>
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. 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.

imc-dispatcher dial tcp <IP>: connect: cannot assign requested address
6 participants