Update controller address handling (#2089)

* Don't assume it's non-empty or that this is an issue
* Ensure it's empty if the response is coming back through the multihop
  service so that it simply uses what is in the config file, at least
  for now
This commit is contained in:
Jeff Mitchell authored and GitHub committed 2022-06-01 01:09:56 -04:00
1 parent eece174e5e
commit 7bfe35da0d
2 files changed
+15 -11

No files matched your search

+6 -10
View File
@@ -189,16 +189,12 @@ func (w *Worker) sendWorkerStatus(cancelCtx context.Context) {
}
} else {
w.updateTags.Store(false)
addrs := make([]resolver.Address, 0, len(result.Controllers))
strAddrs := make([]string, 0, len(result.Controllers))
for _, v := range result.Controllers {
addrs = append(addrs, resolver.Address{Addr: v.Address})
strAddrs = append(strAddrs, v.Address)
}
switch len(strAddrs) {
case 0:
event.WriteError(statusCtx, op, errors.New("got no controller addresses from controller; possibly prior to first status save, not persisting"))
default:
// This may be nil if we are in a multiple hop scenario
if len(result.Controllers) > 0 {
addrs := make([]resolver.Address, 0, len(result.Controllers))
for _, v := range result.Controllers {
addrs = append(addrs, resolver.Address{Addr: v.Address})
}
w.Resolver().UpdateState(resolver.State{Addresses: addrs})
}
w.lastStatusSuccess.Store(&LastStatusInformation{StatusResponse: result, StatusTime: time.Now()})
@@ -31,7 +31,15 @@ var (
)
func (ws *workerProxyServiceServer) Status(ctx context.Context, req *pbs.StatusRequest) (*pbs.StatusResponse, error) {
return ws.scsClient.Load().(pbs.ServerCoordinationServiceClient).Status(ctx, req)
resp, err := ws.scsClient.Load().(pbs.ServerCoordinationServiceClient).Status(ctx, req)
if resp != nil {
// We don't currently support distributing new addreses to workers
// multiple hops away so ensure they're stripped out
resp.Controllers = nil
}
return resp, err
}
func (ws *workerProxyServiceServer) LookupSession(ctx context.Context, req *pbs.LookupSessionRequest) (*pbs.LookupSessionResponse, error) {