diff options
author | Ben Kochie <superq@gmail.com> | 2020-06-22 20:15:04 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-22 20:15:04 +0200 |
commit | 5d42d4d99fc3774591aa0a03a36a1ab15f72bd3b (patch) | |
tree | 9078340f33827e44ce58fdebbd77c3cac414a32b | |
parent | 08ce3c6dd430deb51798826701a395e460620d60 (diff) | |
parent | 79ef305a191e6b762ed4667b5fd7e6d3ce0ed8f3 (diff) | |
download | prometheus_node_collector-5d42d4d99fc3774591aa0a03a36a1ab15f72bd3b.tar.bz2 prometheus_node_collector-5d42d4d99fc3774591aa0a03a36a1ab15f72bd3b.tar.xz prometheus_node_collector-5d42d4d99fc3774591aa0a03a36a1ab15f72bd3b.zip |
Merge pull request #1732 from fach/master
Adding backlog/current queue length to qdisc collector
-rw-r--r-- | collector/fixtures/e2e-64k-page-output.txt | 8 | ||||
-rw-r--r-- | collector/fixtures/e2e-output.txt | 8 | ||||
-rw-r--r-- | collector/qdisc_linux.go | 14 | ||||
-rw-r--r-- | go.mod | 4 | ||||
-rw-r--r-- | go.sum | 8 | ||||
-rw-r--r-- | vendor/github.com/ema/qdisc/get.go | 6 | ||||
-rw-r--r-- | vendor/golang.org/x/net/http2/transport.go | 66 | ||||
-rw-r--r-- | vendor/modules.txt | 4 |
8 files changed, 105 insertions, 13 deletions
diff --git a/collector/fixtures/e2e-64k-page-output.txt b/collector/fixtures/e2e-64k-page-output.txt index fe32915..7b857ff 100644 --- a/collector/fixtures/e2e-64k-page-output.txt +++ b/collector/fixtures/e2e-64k-page-output.txt | |||
@@ -2497,10 +2497,18 @@ node_procs_blocked 0 | |||
2497 | # HELP node_procs_running Number of processes in runnable state. | 2497 | # HELP node_procs_running Number of processes in runnable state. |
2498 | # TYPE node_procs_running gauge | 2498 | # TYPE node_procs_running gauge |
2499 | node_procs_running 2 | 2499 | node_procs_running 2 |
2500 | # HELP node_qdisc_backlog Number of bytes currently in queue to be sent. | ||
2501 | # TYPE node_qdisc_backlog gauge | ||
2502 | node_qdisc_backlog{device="eth0",kind="pfifo_fast"} 0 | ||
2503 | node_qdisc_backlog{device="wlan0",kind="fq"} 0 | ||
2500 | # HELP node_qdisc_bytes_total Number of bytes sent. | 2504 | # HELP node_qdisc_bytes_total Number of bytes sent. |
2501 | # TYPE node_qdisc_bytes_total counter | 2505 | # TYPE node_qdisc_bytes_total counter |
2502 | node_qdisc_bytes_total{device="eth0",kind="pfifo_fast"} 83 | 2506 | node_qdisc_bytes_total{device="eth0",kind="pfifo_fast"} 83 |
2503 | node_qdisc_bytes_total{device="wlan0",kind="fq"} 42 | 2507 | node_qdisc_bytes_total{device="wlan0",kind="fq"} 42 |
2508 | # HELP node_qdisc_current_queue_length Number of packets currently in queue to be sent. | ||
2509 | # TYPE node_qdisc_current_queue_length gauge | ||
2510 | node_qdisc_current_queue_length{device="eth0",kind="pfifo_fast"} 0 | ||
2511 | node_qdisc_current_queue_length{device="wlan0",kind="fq"} 0 | ||
2504 | # HELP node_qdisc_drops_total Number of packets dropped. | 2512 | # HELP node_qdisc_drops_total Number of packets dropped. |
2505 | # TYPE node_qdisc_drops_total counter | 2513 | # TYPE node_qdisc_drops_total counter |
2506 | node_qdisc_drops_total{device="eth0",kind="pfifo_fast"} 0 | 2514 | node_qdisc_drops_total{device="eth0",kind="pfifo_fast"} 0 |
diff --git a/collector/fixtures/e2e-output.txt b/collector/fixtures/e2e-output.txt index 0edc65b..e8a5779 100644 --- a/collector/fixtures/e2e-output.txt +++ b/collector/fixtures/e2e-output.txt | |||
@@ -2566,10 +2566,18 @@ node_procs_blocked 0 | |||
2566 | # HELP node_procs_running Number of processes in runnable state. | 2566 | # HELP node_procs_running Number of processes in runnable state. |
2567 | # TYPE node_procs_running gauge | 2567 | # TYPE node_procs_running gauge |
2568 | node_procs_running 2 | 2568 | node_procs_running 2 |
2569 | # HELP node_qdisc_backlog Number of bytes currently in queue to be sent. | ||
2570 | # TYPE node_qdisc_backlog gauge | ||
2571 | node_qdisc_backlog{device="eth0",kind="pfifo_fast"} 0 | ||
2572 | node_qdisc_backlog{device="wlan0",kind="fq"} 0 | ||
2569 | # HELP node_qdisc_bytes_total Number of bytes sent. | 2573 | # HELP node_qdisc_bytes_total Number of bytes sent. |
2570 | # TYPE node_qdisc_bytes_total counter | 2574 | # TYPE node_qdisc_bytes_total counter |
2571 | node_qdisc_bytes_total{device="eth0",kind="pfifo_fast"} 83 | 2575 | node_qdisc_bytes_total{device="eth0",kind="pfifo_fast"} 83 |
2572 | node_qdisc_bytes_total{device="wlan0",kind="fq"} 42 | 2576 | node_qdisc_bytes_total{device="wlan0",kind="fq"} 42 |
2577 | # HELP node_qdisc_current_queue_length Number of packets currently in queue to be sent. | ||
2578 | # TYPE node_qdisc_current_queue_length gauge | ||
2579 | node_qdisc_current_queue_length{device="eth0",kind="pfifo_fast"} 0 | ||
2580 | node_qdisc_current_queue_length{device="wlan0",kind="fq"} 0 | ||
2573 | # HELP node_qdisc_drops_total Number of packets dropped. | 2581 | # HELP node_qdisc_drops_total Number of packets dropped. |
2574 | # TYPE node_qdisc_drops_total counter | 2582 | # TYPE node_qdisc_drops_total counter |
2575 | node_qdisc_drops_total{device="eth0",kind="pfifo_fast"} 0 | 2583 | node_qdisc_drops_total{device="eth0",kind="pfifo_fast"} 0 |
diff --git a/collector/qdisc_linux.go b/collector/qdisc_linux.go index daba199..ba462a0 100644 --- a/collector/qdisc_linux.go +++ b/collector/qdisc_linux.go | |||
@@ -32,6 +32,8 @@ type qdiscStatCollector struct { | |||
32 | drops typedDesc | 32 | drops typedDesc |
33 | requeues typedDesc | 33 | requeues typedDesc |
34 | overlimits typedDesc | 34 | overlimits typedDesc |
35 | qlength typedDesc | ||
36 | backlog typedDesc | ||
35 | logger log.Logger | 37 | logger log.Logger |
36 | } | 38 | } |
37 | 39 | ||
@@ -71,6 +73,16 @@ func NewQdiscStatCollector(logger log.Logger) (Collector, error) { | |||
71 | "Number of overlimit packets.", | 73 | "Number of overlimit packets.", |
72 | []string{"device", "kind"}, nil, | 74 | []string{"device", "kind"}, nil, |
73 | ), prometheus.CounterValue}, | 75 | ), prometheus.CounterValue}, |
76 | qlength: typedDesc{prometheus.NewDesc( | ||
77 | prometheus.BuildFQName(namespace, "qdisc", "current_queue_length"), | ||
78 | "Number of packets currently in queue to be sent.", | ||
79 | []string{"device", "kind"}, nil, | ||
80 | ), prometheus.GaugeValue}, | ||
81 | backlog: typedDesc{prometheus.NewDesc( | ||
82 | prometheus.BuildFQName(namespace, "qdisc", "backlog"), | ||
83 | "Number of bytes currently in queue to be sent.", | ||
84 | []string{"device", "kind"}, nil, | ||
85 | ), prometheus.GaugeValue}, | ||
74 | logger: logger, | 86 | logger: logger, |
75 | }, nil | 87 | }, nil |
76 | } | 88 | } |
@@ -114,6 +126,8 @@ func (c *qdiscStatCollector) Update(ch chan<- prometheus.Metric) error { | |||
114 | ch <- c.drops.mustNewConstMetric(float64(msg.Drops), msg.IfaceName, msg.Kind) | 126 | ch <- c.drops.mustNewConstMetric(float64(msg.Drops), msg.IfaceName, msg.Kind) |
115 | ch <- c.requeues.mustNewConstMetric(float64(msg.Requeues), msg.IfaceName, msg.Kind) | 127 | ch <- c.requeues.mustNewConstMetric(float64(msg.Requeues), msg.IfaceName, msg.Kind) |
116 | ch <- c.overlimits.mustNewConstMetric(float64(msg.Overlimits), msg.IfaceName, msg.Kind) | 128 | ch <- c.overlimits.mustNewConstMetric(float64(msg.Overlimits), msg.IfaceName, msg.Kind) |
129 | ch <- c.qlength.mustNewConstMetric(float64(msg.Qlen), msg.IfaceName, msg.Kind) | ||
130 | ch <- c.backlog.mustNewConstMetric(float64(msg.Backlog), msg.IfaceName, msg.Kind) | ||
117 | } | 131 | } |
118 | 132 | ||
119 | return nil | 133 | return nil |
@@ -4,7 +4,7 @@ require ( | |||
4 | github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d // indirect | 4 | github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d // indirect |
5 | github.com/beevik/ntp v0.3.0 | 5 | github.com/beevik/ntp v0.3.0 |
6 | github.com/coreos/go-systemd v0.0.0-20191104093116-d3cd4ed1dbcf | 6 | github.com/coreos/go-systemd v0.0.0-20191104093116-d3cd4ed1dbcf |
7 | github.com/ema/qdisc v0.0.0-20190904071900-b82c76788043 | 7 | github.com/ema/qdisc v0.0.0-20200603082823-62d0308e3e00 |
8 | github.com/go-kit/kit v0.10.0 | 8 | github.com/go-kit/kit v0.10.0 |
9 | github.com/godbus/dbus v0.0.0-20190402143921-271e53dc4968 | 9 | github.com/godbus/dbus v0.0.0-20190402143921-271e53dc4968 |
10 | github.com/golang/protobuf v1.4.1 // indirect | 10 | github.com/golang/protobuf v1.4.1 // indirect |
@@ -26,7 +26,7 @@ require ( | |||
26 | go.uber.org/multierr v1.5.0 // indirect | 26 | go.uber.org/multierr v1.5.0 // indirect |
27 | golang.org/x/crypto v0.0.0-20200510223506-06a226fb4e37 | 27 | golang.org/x/crypto v0.0.0-20200510223506-06a226fb4e37 |
28 | golang.org/x/lint v0.0.0-20200302205851-738671d3881b // indirect | 28 | golang.org/x/lint v0.0.0-20200302205851-738671d3881b // indirect |
29 | golang.org/x/net v0.0.0-20200513185701-a91f0712d120 // indirect | 29 | golang.org/x/net v0.0.0-20200602114024-627f9648deb9 // indirect |
30 | golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a // indirect | 30 | golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a // indirect |
31 | golang.org/x/sys v0.0.0-20200602225109-6fdc65e7d980 | 31 | golang.org/x/sys v0.0.0-20200602225109-6fdc65e7d980 |
32 | golang.org/x/tools v0.0.0-20200513201620-d5fe73897c97 // indirect | 32 | golang.org/x/tools v0.0.0-20200513201620-d5fe73897c97 // indirect |
@@ -60,8 +60,8 @@ github.com/eapache/go-resiliency v1.1.0/go.mod h1:kFI+JgMyC7bLPUVY133qvEBtVayf5m | |||
60 | github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21/go.mod h1:+020luEh2TKB4/GOp8oxxtq0Daoen/Cii55CzbTV6DU= | 60 | github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21/go.mod h1:+020luEh2TKB4/GOp8oxxtq0Daoen/Cii55CzbTV6DU= |
61 | github.com/eapache/queue v1.1.0/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFPTqq+I= | 61 | github.com/eapache/queue v1.1.0/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFPTqq+I= |
62 | github.com/edsrzf/mmap-go v1.0.0/go.mod h1:YO35OhQPt3KJa3ryjFM5Bs14WD66h8eGKpfaBNrHW5M= | 62 | github.com/edsrzf/mmap-go v1.0.0/go.mod h1:YO35OhQPt3KJa3ryjFM5Bs14WD66h8eGKpfaBNrHW5M= |
63 | github.com/ema/qdisc v0.0.0-20190904071900-b82c76788043 h1:I3hLsM87FSASssIrIOGwJCio31dvLkvpYDKn2+r31ec= | 63 | github.com/ema/qdisc v0.0.0-20200603082823-62d0308e3e00 h1:0GHzegkDz/zSrt+Zph1OueNImPdUxoToypnkhhRYTjI= |
64 | github.com/ema/qdisc v0.0.0-20190904071900-b82c76788043/go.mod h1:ix4kG2zvdUd8kEKSW0ZTr1XLks0epFpI4j745DXxlNE= | 64 | github.com/ema/qdisc v0.0.0-20200603082823-62d0308e3e00/go.mod h1:ix4kG2zvdUd8kEKSW0ZTr1XLks0epFpI4j745DXxlNE= |
65 | github.com/envoyproxy/go-control-plane v0.6.9/go.mod h1:SBwIajubJHhxtWwsL9s8ss4safvEdbitLhGGK48rN6g= | 65 | github.com/envoyproxy/go-control-plane v0.6.9/go.mod h1:SBwIajubJHhxtWwsL9s8ss4safvEdbitLhGGK48rN6g= |
66 | github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= | 66 | github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= |
67 | github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= | 67 | github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= |
@@ -394,8 +394,8 @@ golang.org/x/net v0.0.0-20191007182048-72f939374954/go.mod h1:z5CRVTTTmAJ677TzLL | |||
394 | golang.org/x/net v0.0.0-20200202094626-16171245cfb2 h1:CCH4IOTTfewWjGOlSp+zGcjutRKlBEZQ6wTn8ozI/nI= | 394 | golang.org/x/net v0.0.0-20200202094626-16171245cfb2 h1:CCH4IOTTfewWjGOlSp+zGcjutRKlBEZQ6wTn8ozI/nI= |
395 | golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= | 395 | golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= |
396 | golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= | 396 | golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= |
397 | golang.org/x/net v0.0.0-20200513185701-a91f0712d120 h1:EZ3cVSzKOlJxAd8e8YAJ7no8nNypTxexh/YE/xW3ZEY= | 397 | golang.org/x/net v0.0.0-20200602114024-627f9648deb9 h1:pNX+40auqi2JqRfOP1akLGtYcn15TUbkhwuCO3foqqM= |
398 | golang.org/x/net v0.0.0-20200513185701-a91f0712d120/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= | 398 | golang.org/x/net v0.0.0-20200602114024-627f9648deb9/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= |
399 | golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= | 399 | golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= |
400 | golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= | 400 | golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= |
401 | golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= | 401 | golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= |
diff --git a/vendor/github.com/ema/qdisc/get.go b/vendor/github.com/ema/qdisc/get.go index 9191594..c83024c 100644 --- a/vendor/github.com/ema/qdisc/get.go +++ b/vendor/github.com/ema/qdisc/get.go | |||
@@ -86,6 +86,8 @@ type QdiscInfo struct { | |||
86 | GcFlows uint64 | 86 | GcFlows uint64 |
87 | Throttled uint64 | 87 | Throttled uint64 |
88 | FlowsPlimit uint64 | 88 | FlowsPlimit uint64 |
89 | Qlen uint32 | ||
90 | Backlog uint32 | ||
89 | } | 91 | } |
90 | 92 | ||
91 | func parseTCAStats(attr netlink.Attribute) TC_Stats { | 93 | func parseTCAStats(attr netlink.Attribute) TC_Stats { |
@@ -237,6 +239,8 @@ func parseMessage(msg netlink.Message) (QdiscInfo, error) { | |||
237 | // requeues only available in TCA_STATS2, not in TCA_STATS | 239 | // requeues only available in TCA_STATS2, not in TCA_STATS |
238 | m.Requeues = s2.Requeues | 240 | m.Requeues = s2.Requeues |
239 | m.Overlimits = s2.Overlimits | 241 | m.Overlimits = s2.Overlimits |
242 | m.Qlen = s2.Qlen | ||
243 | m.Backlog = s2.Backlog | ||
240 | case TCA_STATS: | 244 | case TCA_STATS: |
241 | // Legacy | 245 | // Legacy |
242 | s = parseTCAStats(attr) | 246 | s = parseTCAStats(attr) |
@@ -244,6 +248,8 @@ func parseMessage(msg netlink.Message) (QdiscInfo, error) { | |||
244 | m.Packets = s.Packets | 248 | m.Packets = s.Packets |
245 | m.Drops = s.Drops | 249 | m.Drops = s.Drops |
246 | m.Overlimits = s.Overlimits | 250 | m.Overlimits = s.Overlimits |
251 | m.Qlen = s.Qlen | ||
252 | m.Backlog = s.Backlog | ||
247 | default: | 253 | default: |
248 | // TODO: TCA_OPTIONS and TCA_XSTATS | 254 | // TODO: TCA_OPTIONS and TCA_XSTATS |
249 | } | 255 | } |
diff --git a/vendor/golang.org/x/net/http2/transport.go b/vendor/golang.org/x/net/http2/transport.go index 54acc1e..76a92e0 100644 --- a/vendor/golang.org/x/net/http2/transport.go +++ b/vendor/golang.org/x/net/http2/transport.go | |||
@@ -108,6 +108,19 @@ type Transport struct { | |||
108 | // waiting for their turn. | 108 | // waiting for their turn. |
109 | StrictMaxConcurrentStreams bool | 109 | StrictMaxConcurrentStreams bool |
110 | 110 | ||
111 | // ReadIdleTimeout is the timeout after which a health check using ping | ||
112 | // frame will be carried out if no frame is received on the connection. | ||
113 | // Note that a ping response will is considered a received frame, so if | ||
114 | // there is no other traffic on the connection, the health check will | ||
115 | // be performed every ReadIdleTimeout interval. | ||
116 | // If zero, no health check is performed. | ||
117 | ReadIdleTimeout time.Duration | ||
118 | |||
119 | // PingTimeout is the timeout after which the connection will be closed | ||
120 | // if a response to Ping is not received. | ||
121 | // Defaults to 15s. | ||
122 | PingTimeout time.Duration | ||
123 | |||
111 | // t1, if non-nil, is the standard library Transport using | 124 | // t1, if non-nil, is the standard library Transport using |
112 | // this transport. Its settings are used (but not its | 125 | // this transport. Its settings are used (but not its |
113 | // RoundTrip method, etc). | 126 | // RoundTrip method, etc). |
@@ -131,6 +144,14 @@ func (t *Transport) disableCompression() bool { | |||
131 | return t.DisableCompression || (t.t1 != nil && t.t1.DisableCompression) | 144 | return t.DisableCompression || (t.t1 != nil && t.t1.DisableCompression) |
132 | } | 145 | } |
133 | 146 | ||
147 | func (t *Transport) pingTimeout() time.Duration { | ||
148 | if t.PingTimeout == 0 { | ||
149 | return 15 * time.Second | ||
150 | } | ||
151 | return t.PingTimeout | ||
152 | |||
153 | } | ||
154 | |||
134 | // ConfigureTransport configures a net/http HTTP/1 Transport to use HTTP/2. | 155 | // ConfigureTransport configures a net/http HTTP/1 Transport to use HTTP/2. |
135 | // It returns an error if t1 has already been HTTP/2-enabled. | 156 | // It returns an error if t1 has already been HTTP/2-enabled. |
136 | func ConfigureTransport(t1 *http.Transport) error { | 157 | func ConfigureTransport(t1 *http.Transport) error { |
@@ -675,6 +696,20 @@ func (t *Transport) newClientConn(c net.Conn, singleUse bool) (*ClientConn, erro | |||
675 | return cc, nil | 696 | return cc, nil |
676 | } | 697 | } |
677 | 698 | ||
699 | func (cc *ClientConn) healthCheck() { | ||
700 | pingTimeout := cc.t.pingTimeout() | ||
701 | // We don't need to periodically ping in the health check, because the readLoop of ClientConn will | ||
702 | // trigger the healthCheck again if there is no frame received. | ||
703 | ctx, cancel := context.WithTimeout(context.Background(), pingTimeout) | ||
704 | defer cancel() | ||
705 | err := cc.Ping(ctx) | ||
706 | if err != nil { | ||
707 | cc.closeForLostPing() | ||
708 | cc.t.connPool().MarkDead(cc) | ||
709 | return | ||
710 | } | ||
711 | } | ||
712 | |||
678 | func (cc *ClientConn) setGoAway(f *GoAwayFrame) { | 713 | func (cc *ClientConn) setGoAway(f *GoAwayFrame) { |
679 | cc.mu.Lock() | 714 | cc.mu.Lock() |
680 | defer cc.mu.Unlock() | 715 | defer cc.mu.Unlock() |
@@ -846,14 +881,12 @@ func (cc *ClientConn) sendGoAway() error { | |||
846 | return nil | 881 | return nil |
847 | } | 882 | } |
848 | 883 | ||
849 | // Close closes the client connection immediately. | 884 | // closes the client connection immediately. In-flight requests are interrupted. |
850 | // | 885 | // err is sent to streams. |
851 | // In-flight requests are interrupted. For a graceful shutdown, use Shutdown instead. | 886 | func (cc *ClientConn) closeForError(err error) error { |
852 | func (cc *ClientConn) Close() error { | ||
853 | cc.mu.Lock() | 887 | cc.mu.Lock() |
854 | defer cc.cond.Broadcast() | 888 | defer cc.cond.Broadcast() |
855 | defer cc.mu.Unlock() | 889 | defer cc.mu.Unlock() |
856 | err := errors.New("http2: client connection force closed via ClientConn.Close") | ||
857 | for id, cs := range cc.streams { | 890 | for id, cs := range cc.streams { |
858 | select { | 891 | select { |
859 | case cs.resc <- resAndError{err: err}: | 892 | case cs.resc <- resAndError{err: err}: |
@@ -866,6 +899,20 @@ func (cc *ClientConn) Close() error { | |||
866 | return cc.tconn.Close() | 899 | return cc.tconn.Close() |
867 | } | 900 | } |
868 | 901 | ||
902 | // Close closes the client connection immediately. | ||
903 | // | ||
904 | // In-flight requests are interrupted. For a graceful shutdown, use Shutdown instead. | ||
905 | func (cc *ClientConn) Close() error { | ||
906 | err := errors.New("http2: client connection force closed via ClientConn.Close") | ||
907 | return cc.closeForError(err) | ||
908 | } | ||
909 | |||
910 | // closes the client connection immediately. In-flight requests are interrupted. | ||
911 | func (cc *ClientConn) closeForLostPing() error { | ||
912 | err := errors.New("http2: client connection lost") | ||
913 | return cc.closeForError(err) | ||
914 | } | ||
915 | |||
869 | const maxAllocFrameSize = 512 << 10 | 916 | const maxAllocFrameSize = 512 << 10 |
870 | 917 | ||
871 | // frameBuffer returns a scratch buffer suitable for writing DATA frames. | 918 | // frameBuffer returns a scratch buffer suitable for writing DATA frames. |
@@ -1737,8 +1784,17 @@ func (rl *clientConnReadLoop) run() error { | |||
1737 | rl.closeWhenIdle = cc.t.disableKeepAlives() || cc.singleUse | 1784 | rl.closeWhenIdle = cc.t.disableKeepAlives() || cc.singleUse |
1738 | gotReply := false // ever saw a HEADERS reply | 1785 | gotReply := false // ever saw a HEADERS reply |
1739 | gotSettings := false | 1786 | gotSettings := false |
1787 | readIdleTimeout := cc.t.ReadIdleTimeout | ||
1788 | var t *time.Timer | ||
1789 | if readIdleTimeout != 0 { | ||
1790 | t = time.AfterFunc(readIdleTimeout, cc.healthCheck) | ||
1791 | defer t.Stop() | ||
1792 | } | ||
1740 | for { | 1793 | for { |
1741 | f, err := cc.fr.ReadFrame() | 1794 | f, err := cc.fr.ReadFrame() |
1795 | if t != nil { | ||
1796 | t.Reset(readIdleTimeout) | ||
1797 | } | ||
1742 | if err != nil { | 1798 | if err != nil { |
1743 | cc.vlogf("http2: Transport readFrame error on conn %p: (%T) %v", cc, err, err) | 1799 | cc.vlogf("http2: Transport readFrame error on conn %p: (%T) %v", cc, err, err) |
1744 | } | 1800 | } |
diff --git a/vendor/modules.txt b/vendor/modules.txt index 7d451f0..983f45d 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt | |||
@@ -14,7 +14,7 @@ github.com/cespare/xxhash/v2 | |||
14 | # github.com/coreos/go-systemd v0.0.0-20191104093116-d3cd4ed1dbcf | 14 | # github.com/coreos/go-systemd v0.0.0-20191104093116-d3cd4ed1dbcf |
15 | ## explicit | 15 | ## explicit |
16 | github.com/coreos/go-systemd/dbus | 16 | github.com/coreos/go-systemd/dbus |
17 | # github.com/ema/qdisc v0.0.0-20190904071900-b82c76788043 | 17 | # github.com/ema/qdisc v0.0.0-20200603082823-62d0308e3e00 |
18 | ## explicit | 18 | ## explicit |
19 | github.com/ema/qdisc | 19 | github.com/ema/qdisc |
20 | # github.com/go-kit/kit v0.10.0 | 20 | # github.com/go-kit/kit v0.10.0 |
@@ -108,7 +108,7 @@ golang.org/x/crypto/bcrypt | |||
108 | golang.org/x/crypto/blowfish | 108 | golang.org/x/crypto/blowfish |
109 | # golang.org/x/lint v0.0.0-20200302205851-738671d3881b | 109 | # golang.org/x/lint v0.0.0-20200302205851-738671d3881b |
110 | ## explicit | 110 | ## explicit |
111 | # golang.org/x/net v0.0.0-20200513185701-a91f0712d120 | 111 | # golang.org/x/net v0.0.0-20200602114024-627f9648deb9 |
112 | ## explicit | 112 | ## explicit |
113 | golang.org/x/net/bpf | 113 | golang.org/x/net/bpf |
114 | golang.org/x/net/http/httpguts | 114 | golang.org/x/net/http/httpguts |