OLD | NEW |
1 // Copyright 2015 The LUCI Authors. All rights reserved. | 1 // Copyright 2015 The LUCI Authors. All rights reserved. |
2 // Use of this source code is governed under the Apache License, Version 2.0 | 2 // Use of this source code is governed under the Apache License, Version 2.0 |
3 // that can be found in the LICENSE file. | 3 // that can be found in the LICENSE file. |
4 | 4 |
5 package cli | 5 package cli |
6 | 6 |
7 import ( | 7 import ( |
8 "io" | 8 "io" |
9 "os" | 9 "os" |
10 "strconv" | 10 "strconv" |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 log.Fields{ | 114 log.Fields{ |
115 log.ErrorKey: err, | 115 log.ErrorKey: err, |
116 "index": i, | 116 "index": i, |
117 "project": addr.Project, | 117 "project": addr.Project, |
118 "path": addr.Path, | 118 "path": addr.Path, |
119 }.Errorf(a, "Invalid command-line stream path.") | 119 }.Errorf(a, "Invalid command-line stream path.") |
120 return 1 | 120 return 1 |
121 } | 121 } |
122 | 122 |
123 if addr.Host, err = a.resolveHost(""); err != nil { | 123 if addr.Host, err = a.resolveHost(""); err != nil { |
124 » » » err = errors.Annotate(err).Reason("failed to resolve hos
t: %(host)q"). | 124 » » » err = errors.Annotate(err, "failed to resolve host: %q",
addr.Host).Err() |
125 » » » » D("host", addr.Host).Err() | |
126 errors.Log(a, err) | 125 errors.Log(a, err) |
127 return 1 | 126 return 1 |
128 } | 127 } |
129 | 128 |
130 addrs[i] = &addr | 129 addrs[i] = &addr |
131 } | 130 } |
132 if cmd.buffer <= 0 { | 131 if cmd.buffer <= 0 { |
133 log.Fields{ | 132 log.Fields{ |
134 "value": cmd.buffer, | 133 "value": cmd.buffer, |
135 }.Errorf(a, "Buffer size must be >0.") | 134 }.Errorf(a, "Buffer size must be >0.") |
136 } | 135 } |
137 | 136 |
138 coords := make(map[string]*coordinator.Client, len(addrs)) | 137 coords := make(map[string]*coordinator.Client, len(addrs)) |
139 for _, addr := range addrs { | 138 for _, addr := range addrs { |
140 if _, ok := coords[addr.Host]; ok { | 139 if _, ok := coords[addr.Host]; ok { |
141 continue | 140 continue |
142 } | 141 } |
143 | 142 |
144 var err error | 143 var err error |
145 if coords[addr.Host], err = a.coordinatorClient(addr.Host); err
!= nil { | 144 if coords[addr.Host], err = a.coordinatorClient(addr.Host); err
!= nil { |
146 » » » err = errors.Annotate(err).Reason("failed to create Coor
dinator client for %(host)q"). | 145 » » » err = errors.Annotate(err, "failed to create Coordinator
client for %q", addr.Host).Err() |
147 » » » » D("host", addr.Host).Err() | |
148 | 146 |
149 errors.Log(a, err) | 147 errors.Log(a, err) |
150 return 1 | 148 return 1 |
151 } | 149 } |
152 } | 150 } |
153 | 151 |
154 tctx, _ := a.timeoutCtx(a) | 152 tctx, _ := a.timeoutCtx(a) |
155 for i, addr := range addrs { | 153 for i, addr := range addrs { |
156 if err := cmd.catPath(tctx, coords[addr.Host], addr); err != nil
{ | 154 if err := cmd.catPath(tctx, coords[addr.Host], addr); err != nil
{ |
157 log.Fields{ | 155 log.Fields{ |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
255 } | 253 } |
256 | 254 |
257 if err := proto.MarshalText(w, pb); err != nil { | 255 if err := proto.MarshalText(w, pb); err != nil { |
258 log.WithError(err).Errorf(c, "Failed to marshal datagram
as text.") | 256 log.WithError(err).Errorf(c, "Failed to marshal datagram
as text.") |
259 return false | 257 return false |
260 } | 258 } |
261 | 259 |
262 return true | 260 return true |
263 } | 261 } |
264 } | 262 } |
OLD | NEW |