HEAD check for container blobs deletes blob if content store cannot find
blob nil on repeat logging for blob insert Upload blob recovery during push console cleanup
This commit is contained in:
parent
3c07ed0911
commit
00f3f3aedf
@ -23,7 +23,7 @@ import (
|
||||
// The uploaded blob gets stored in a special upload version to link them to the package/image
|
||||
func saveAsPackageBlob(hsr packages_module.HashedSizeReader, pi *packages_service.PackageInfo) (*packages_model.PackageBlob, error) {
|
||||
pb := packages_service.NewPackageBlob(hsr)
|
||||
|
||||
fmt.Println("saveAsPackageBlob: ", pb.HashSHA256)
|
||||
exists := false
|
||||
|
||||
contentStore := packages_module.NewContentStore()
|
||||
@ -45,7 +45,7 @@ func saveAsPackageBlob(hsr packages_module.HashedSizeReader, pi *packages_servic
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
fmt.Println("CREATED!!!")
|
||||
if created {
|
||||
if _, err := packages_model.InsertProperty(ctx, packages_model.PropertyTypePackage, p.ID, container_module.PropertyRepository, strings.ToLower(pi.Owner.LowerName+"/"+pi.Name)); err != nil {
|
||||
log.Error("Error setting package property: %v", err)
|
||||
@ -73,6 +73,16 @@ func saveAsPackageBlob(hsr packages_module.HashedSizeReader, pi *packages_servic
|
||||
log.Error("Error inserting package blob: %v", err)
|
||||
return err
|
||||
}
|
||||
if exists {
|
||||
_, err := contentStore.Get(packages_module.BlobHash256Key(pb.HashSHA256))
|
||||
if err != nil {
|
||||
log.Info("BLOB MODEL and ERR in ContentStore. Resaving Blob to content store ", err.Error())
|
||||
if err := contentStore.Save(packages_module.BlobHash256Key(pb.HashSHA256), hsr, hsr.Size()); err != nil {
|
||||
log.Error("Error saving package blob in content store during FIXITUP: %v", err)
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
if !exists {
|
||||
if err := contentStore.Save(packages_module.BlobHash256Key(pb.HashSHA256), hsr, hsr.Size()); err != nil {
|
||||
log.Error("Error saving package blob in content store: %v", err)
|
||||
|
@ -379,7 +379,23 @@ func HeadBlob(ctx *context.Context) {
|
||||
}
|
||||
return
|
||||
}
|
||||
//check if actually in ContentStore
|
||||
//if not, delete Blob and return 404
|
||||
//content_store.Get()
|
||||
cStore := packages_module.NewContentStore()
|
||||
configReader, err := cStore.Get(packages_module.BlobHash256Key(blob.Blob.HashSHA256))
|
||||
if err != nil {
|
||||
log.Warn("ContentStore Get Error while HEAD for Blob: ", blob.Blob.HashSHA256, err.Error())
|
||||
|
||||
digest := ctx.Params("digest")
|
||||
|
||||
if err := deleteBlob(ctx.Package.Owner.ID, ctx.Params("image"), digest); err != nil {
|
||||
log.Warn("Error while deleteBlob in HEAD: ", err.Error())
|
||||
}
|
||||
apiErrorDefined(ctx, errBlobUnknown)
|
||||
return
|
||||
}
|
||||
defer configReader.Close()
|
||||
setResponseHeaders(ctx.Resp, &containerHeaders{
|
||||
ContentDigest: blob.Properties.GetByName(container_module.PropertyDigest),
|
||||
ContentLength: blob.Blob.Size,
|
||||
|
@ -224,7 +224,6 @@ func NewPackageBlob(hsr packages_module.HashedSizeReader) *packages_model.Packag
|
||||
|
||||
func addFileToPackageVersion(ctx context.Context, pv *packages_model.PackageVersion, pfci *PackageFileCreationInfo) (*packages_model.PackageFile, *packages_model.PackageBlob, bool, error) {
|
||||
log.Trace("Adding package file: %v, %s", pv.ID, pfci.Filename)
|
||||
|
||||
pb, exists, err := packages_model.GetOrInsertBlob(ctx, NewPackageBlob(pfci.Data))
|
||||
if err != nil {
|
||||
log.Error("Error inserting package blob: %v", err)
|
||||
|
Loading…
Reference in New Issue
Block a user