shell: send read jwt when downloading chunks in fs.mergeVolumes and fs.distributeChunks (#10717)

* shell: fs.mergeVolumes sends read jwt when downloading chunks

* shell: fs.distributeChunks sends read jwt when downloading chunks
This commit is contained in:
Chris Lu
2026-08-11 11:57:53 -07:00
committed by GitHub
parent 01e97955f9
commit 5b145fe646
2 changed files with 9 additions and 2 deletions
@@ -692,6 +692,7 @@ func executeChunkMoves(
var resp *http.Response
var reader io.ReadCloser
var readErr error
readJwt := filer.JwtForVolumeServer(oldFidStr)
for _, serverURL := range downloadURLs {
var dlReq *http.Request
dlReq, readErr = http.NewRequestWithContext(dlCtx, http.MethodGet, fmt.Sprintf("http://%s/%s", serverURL, oldFidStr), nil)
@@ -699,6 +700,9 @@ func executeChunkMoves(
continue
}
dlReq.Header.Add("Accept-Encoding", "gzip")
if readJwt != "" {
dlReq.Header.Set("Authorization", security.BearerPrefix+readJwt)
}
resp, readErr = util_http.GetGlobalHttpClient().Do(dlReq)
if readErr == nil && resp.StatusCode >= 400 {
util_http.CloseResponse(resp)
+5 -2
View File
@@ -823,7 +823,7 @@ func moveChunk(chunk *filer_pb.FileChunk, toVolumeId needle.VolumeId, masterClie
}
uploadURL := fmt.Sprintf("http://%s/%s", uploadURLs[0], toFid.String())
resp, reader, err := readUrl(downloadURL)
resp, reader, err := readUrl(downloadURL, filer.JwtForVolumeServer(fromFid.String()))
if err != nil {
return err
}
@@ -877,13 +877,16 @@ func moveChunk(chunk *filer_pb.FileChunk, toVolumeId needle.VolumeId, masterClie
return nil
}
func readUrl(fileUrl string) (*http.Response, io.ReadCloser, error) {
func readUrl(fileUrl string, jwt string) (*http.Response, io.ReadCloser, error) {
req, err := http.NewRequest(http.MethodGet, fileUrl, nil)
if err != nil {
return nil, nil, err
}
req.Header.Add("Accept-Encoding", "gzip")
if jwt != "" {
req.Header.Set("Authorization", security.BearerPrefix+jwt)
}
r, err := util_http.GetGlobalHttpClient().Do(req)
if err != nil {