rpc auth: handle some auth errors gracefully
particuarly we will ignore authorization errors for some broadcasts and somply not include those responses in the assembled one.
This commit is contained in:
parent
949e6f2364
commit
a86c7cae2b
|
@ -624,6 +624,10 @@ func (proxy *Server) repoStatHandler(w http.ResponseWriter, r *http.Request) {
|
|||
|
||||
for i, err := range errs {
|
||||
if err != nil {
|
||||
if rpc.IsAuthorizationError(err) {
|
||||
logger.Debug(err)
|
||||
continue
|
||||
}
|
||||
logger.Errorf("%s repo/stat errored: %s", peers[i], err)
|
||||
continue
|
||||
}
|
||||
|
|
22
cluster.go
22
cluster.go
|
@ -1333,13 +1333,22 @@ func (c *Cluster) Peers(ctx context.Context) []*api.ID {
|
|||
rpcutil.CopyIDsToIfaces(peers),
|
||||
)
|
||||
|
||||
finalPeers := []*api.ID{}
|
||||
|
||||
for i, err := range errs {
|
||||
if err != nil {
|
||||
if err == nil {
|
||||
finalPeers = append(finalPeers, peers[i])
|
||||
continue
|
||||
}
|
||||
|
||||
if rpc.IsAuthorizationError(err) {
|
||||
continue
|
||||
}
|
||||
|
||||
peers[i] = &api.ID{}
|
||||
peers[i].ID = members[i]
|
||||
peers[i].Error = err.Error()
|
||||
}
|
||||
}
|
||||
|
||||
return peers
|
||||
}
|
||||
|
@ -1382,6 +1391,11 @@ func (c *Cluster) globalPinInfoCid(ctx context.Context, comp, method string, h c
|
|||
continue
|
||||
}
|
||||
|
||||
if rpc.IsAuthorizationError(e) {
|
||||
logger.Debug("rpc auth error:", e)
|
||||
continue
|
||||
}
|
||||
|
||||
// Deal with error cases (err != nil): wrap errors in PinInfo
|
||||
logger.Errorf("%s: error in broadcast response from %s: %s ", c.id, members[i], e)
|
||||
pin.PeerMap[peer.IDB58Encode(members[i])] = &api.PinInfo{
|
||||
|
@ -1447,6 +1461,10 @@ func (c *Cluster) globalPinInfoSlice(ctx context.Context, comp, method string) (
|
|||
erroredPeers := make(map[peer.ID]string)
|
||||
for i, r := range replies {
|
||||
if e := errs[i]; e != nil { // This error must come from not being able to contact that cluster member
|
||||
if rpc.IsAuthorizationError(e) {
|
||||
logger.Debug("rpc auth error", e)
|
||||
continue
|
||||
}
|
||||
logger.Errorf("%s: error in broadcast response from %s: %s ", c.id, members[i], e)
|
||||
erroredPeers[members[i]] = e.Error()
|
||||
} else {
|
||||
|
|
Loading…
Reference in New Issue
Block a user