Merge branch 'master' into msg_channel

This commit is contained in:
Chris Lu 2020-05-13 03:54:15 -07:00
commit 3fbf635308

View file

@ -45,7 +45,7 @@ func (ms *MasterServer) dirLookupHandler(w http.ResponseWriter, r *http.Request)
vid = fileId[0:commaSep] vid = fileId[0:commaSep]
} }
} }
collection := r.FormValue("collection") //optional, but can be faster if too many collections collection := r.FormValue("collection") // optional, but can be faster if too many collections
location := ms.findVolumeLocation(collection, vid) location := ms.findVolumeLocation(collection, vid)
httpStatus := http.StatusOK httpStatus := http.StatusOK
if location.Error != "" || location.Locations == nil { if location.Error != "" || location.Locations == nil {
@ -72,9 +72,6 @@ func (ms *MasterServer) findVolumeLocation(collection, vid string) operation.Loo
for _, loc := range machines { for _, loc := range machines {
locations = append(locations, operation.Location{Url: loc.Url(), PublicUrl: loc.PublicUrl}) locations = append(locations, operation.Location{Url: loc.Url(), PublicUrl: loc.PublicUrl})
} }
if locations == nil {
err = fmt.Errorf("volume id %s not found", vid)
}
} }
} else { } else {
machines, getVidLocationsErr := ms.MasterClient.GetVidLocations(vid) machines, getVidLocationsErr := ms.MasterClient.GetVidLocations(vid)
@ -83,6 +80,9 @@ func (ms *MasterServer) findVolumeLocation(collection, vid string) operation.Loo
} }
err = getVidLocationsErr err = getVidLocationsErr
} }
if len(locations) == 0 && err == nil {
err = fmt.Errorf("volume id %s not found", vid)
}
ret := operation.LookupResult{ ret := operation.LookupResult{
VolumeId: vid, VolumeId: vid,
Locations: locations, Locations: locations,