mirror of
https://github.com/go-gitea/gitea.git
synced 2025-09-24 19:08:30 +00:00
Fix container parallel upload bugs (#32022)
This PR should be replaced by #31860 in v1.23. The aim of creating this PR is to fix it in 1.22 because globallock hasn't been introduced. Fix #27640 Fix #29563 Fix #31215
This commit is contained in:
@@ -24,6 +24,7 @@ import (
|
||||
packages_module "code.gitea.io/gitea/modules/packages"
|
||||
container_module "code.gitea.io/gitea/modules/packages/container"
|
||||
"code.gitea.io/gitea/modules/setting"
|
||||
"code.gitea.io/gitea/modules/sync"
|
||||
"code.gitea.io/gitea/modules/util"
|
||||
"code.gitea.io/gitea/routers/api/packages/helper"
|
||||
auth_service "code.gitea.io/gitea/services/auth"
|
||||
@@ -540,7 +541,7 @@ func DeleteBlob(ctx *context.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
if err := deleteBlob(ctx, ctx.Package.Owner.ID, ctx.Params("image"), d); err != nil {
|
||||
if err := deleteBlob(ctx, ctx.Package.Owner, ctx.Params("image"), d); err != nil {
|
||||
apiError(ctx, http.StatusInternalServerError, err)
|
||||
return
|
||||
}
|
||||
@@ -550,6 +551,9 @@ func DeleteBlob(ctx *context.Context) {
|
||||
})
|
||||
}
|
||||
|
||||
// TODO: use clustered lock
|
||||
var lockManifest = sync.NewExclusivePool()
|
||||
|
||||
// https://github.com/opencontainers/distribution-spec/blob/main/spec.md#pushing-manifests
|
||||
func UploadManifest(ctx *context.Context) {
|
||||
reference := ctx.Params("reference")
|
||||
@@ -581,6 +585,10 @@ func UploadManifest(ctx *context.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
imagePath := ctx.Package.Owner.Name + "/" + ctx.Params("image")
|
||||
lockManifest.CheckIn(imagePath)
|
||||
defer lockManifest.CheckOut(imagePath)
|
||||
|
||||
digest, err := processManifest(ctx, mci, buf)
|
||||
if err != nil {
|
||||
var namedError *namedError
|
||||
@@ -679,6 +687,10 @@ func DeleteManifest(ctx *context.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
imagePath := ctx.Package.Owner.Name + "/" + ctx.Params("image")
|
||||
lockManifest.CheckIn(imagePath)
|
||||
defer lockManifest.CheckOut(imagePath)
|
||||
|
||||
pvs, err := container_model.GetManifestVersions(ctx, opts)
|
||||
if err != nil {
|
||||
apiError(ctx, http.StatusInternalServerError, err)
|
||||
|
Reference in New Issue
Block a user