-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix merging artifact chunks error when minio storage basepath is set #28555
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Took me a bit to understand the fix, but I understand it now.
However, what really confuses me: Aren't PR description and fix completely different?
baseName := filepath.Base(fpath) | ||
// when read chunks from storage, it only contains storage dir and basename, | ||
// no matter the subdirectory setting in storage config | ||
item := chunkFileItem{Path: path.Join(storageDir, baseName)} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It confused me that it sometimes calls filepath
(line 74) while sometimes calls path
(here). It looks quite fragile to me.
At least, IMO it needs to normalize the "paths" before using it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The second path.Join
is not necessary. It saves chunk as filename tmp/xxx.chunk
in above. So just storageDir +"/" + basename
is enough.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still have difficulty to understand whether it is right to do these magic path operations.
Could it clarify these "path kinds"? If a path is a filesystem path, then it needs filepath
package, if it is a web path (or a web path converted from filepath), then it needs util.PathJoinRelX
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
baseName := filepath.Base(fpath)
is the real fix. fpath
is from Storage and can be filesystem path so use filepath
to get basename.
chunkFileItem.Path
is a key to read and write file for Storage. When saving chunk, it uses fmt.Sprintf("tmp%d/%d-%d-%d-%d.chunk", runID, runID, artifact.ID, start, end)
with /
slash when saving into Storage.
Using storageDir +"/" + basename
is enough in item.Path to read from Storage. Storage module can handle os difference.
a3f0872
to
3644975
Compare
…o-gitea#28555) Related to go-gitea#28279 When merging artifact chunks, it lists chunks from storage. When storage is minio, chunk's path contains `MINIO_BASE_PATH` that makes merging break. <del>So trim the `MINIO_BASE_PATH` when handle chunks.</del> Update the chunk file's basename to retain necessary information. It ensures that the directory in the chunk's path remains unaffected.
…28555) (#28568) Backport #28555 by @fuxiaohei Related to #28279 When merging artifact chunks, it lists chunks from storage. When storage is minio, chunk's path contains `MINIO_BASE_PATH` that makes merging break. <del>So trim the `MINIO_BASE_PATH` when handle chunks.</del> Update the chunk file's basename to retain necessary information. It ensures that the directory in the chunk's path remains unaffected. Co-authored-by: FuXiaoHei <fuxiaohei@vip.qq.com>
* giteaofficial/main: Add more ways to try (go-gitea#28581) Convert to url auth to header auth in tests (go-gitea#28484) Fix 500 error of searching commits (go-gitea#28576) improve possible performance bottleneck (go-gitea#28547) Use information from previous blame parts (go-gitea#28572) Make offline mode as default to no connect external avatar service by default (go-gitea#28548) Fix merging artifact chunks error when minio storage basepath is set (go-gitea#28555) feat: bump `dessant/lock-threads` and `actions/setup-go` to use nodejs20 runtime (go-gitea#28565) Update actions document about comparsion as Github Actions (go-gitea#28560) Fix inperformant query on retrifing review from database. (go-gitea#28552) Fix the issue ref rendering for wiki (go-gitea#28556) Add missing head of lfs client batch (go-gitea#28550) [skip ci] Updated translations via Crowdin Remove deadcode under models/issues (go-gitea#28536) Always enable caches (go-gitea#28527) Improve ObjectFormat interface (go-gitea#28496)
…o-gitea#28555) Related to go-gitea#28279 When merging artifact chunks, it lists chunks from storage. When storage is minio, chunk's path contains `MINIO_BASE_PATH` that makes merging break. <del>So trim the `MINIO_BASE_PATH` when handle chunks.</del> Update the chunk file's basename to retain necessary information. It ensures that the directory in the chunk's path remains unaffected.
…o-gitea#28555) Related to go-gitea#28279 When merging artifact chunks, it lists chunks from storage. When storage is minio, chunk's path contains `MINIO_BASE_PATH` that makes merging break. <del>So trim the `MINIO_BASE_PATH` when handle chunks.</del> Update the chunk file's basename to retain necessary information. It ensures that the directory in the chunk's path remains unaffected.
Related to #28279
When merging artifact chunks, it lists chunks from storage. When storage is minio, chunk's path contains
MINIO_BASE_PATH
that makes merging break.So trim theMINIO_BASE_PATH
when handle chunks.Update the chunk file's basename to retain necessary information. It ensures that the directory in the chunk's path remains unaffected.