From 20df844d5aa1fe34b2109c5241ba54372ad3374f Mon Sep 17 00:00:00 2001 From: wang yan Date: Wed, 29 Jul 2020 12:31:31 +0800 Subject: [PATCH] revise the blob logs 1, update typo in the update blob status sql, the typo will not impact the sql result. 2, correct blob status in the middleware & GC job log. Signed-off-by: wang yan --- src/jobservice/job/impl/gc/garbage_collection.go | 6 ++---- src/pkg/blob/dao/dao.go | 4 ++-- src/server/middleware/blob/head_blob.go | 4 ++-- src/server/middleware/blob/util.go | 2 +- 4 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/jobservice/job/impl/gc/garbage_collection.go b/src/jobservice/job/impl/gc/garbage_collection.go index 7424337de..c08f227bd 100644 --- a/src/jobservice/job/impl/gc/garbage_collection.go +++ b/src/jobservice/job/impl/gc/garbage_collection.go @@ -224,7 +224,6 @@ func (gc *GarbageCollector) mark(ctx job.Context) error { } gc.logger.Infof("blob eligible for deletion: %s", blob.Digest) gc.deleteSet = append(gc.deleteSet, blob) - // as table blob has no repository name, here needs to use the ArtifactTrash to fill it in. if blob.IsManifest() { mfCt++ } else { @@ -233,7 +232,7 @@ func (gc *GarbageCollector) mark(ctx job.Context) error { makeSize = makeSize + blob.Size } gc.logger.Infof("%d blobs and %d manifests eligible for deletion", blobCt, mfCt) - gc.logger.Infof("The GC could free up %d MB space, the size is a rough estimate.", makeSize/1024/1024) + gc.logger.Infof("The GC could free up %d MB space, the size is a rough estimation.", makeSize/1024/1024) return nil } @@ -294,7 +293,6 @@ func (gc *GarbageCollector) sweep(ctx job.Context) error { return err } return errors.Wrapf(err, "failed to delete blob from storage: %s, %s", blob.Digest, blob.Status) - } // remove the blob record @@ -479,7 +477,7 @@ func (gc *GarbageCollector) markDeleteFailed(ctx job.Context, blob *blob_models. return errors.Wrapf(err, "failed to mark gc candidate delete failed: %s, %s", blob.Digest, blob.Status) } if count == 0 { - return errors.New(nil).WithMessage("no blob found to mark gc candidate, ID:%d, digest:%s", blob.ID, blob.Digest).WithCode(errors.NotFoundCode) + return errors.New(nil).WithMessage("no blob found to mark delete failed, ID:%d, digest:%s", blob.ID, blob.Digest).WithCode(errors.NotFoundCode) } return nil } diff --git a/src/pkg/blob/dao/dao.go b/src/pkg/blob/dao/dao.go index aef624fd1..0b3689959 100644 --- a/src/pkg/blob/dao/dao.go +++ b/src/pkg/blob/dao/dao.go @@ -181,9 +181,9 @@ func (d *dao) UpdateBlobStatus(ctx context.Context, blob *models.Blob) (int64, e var sql string if blob.Status == models.StatusNone { - sql = `UPDATE blob SET version = version + 1, update_time = ?, status = ? where id = ? AND version >= ? AND status IN (%s) RETURNING version as new_vesrion` + sql = `UPDATE blob SET version = version + 1, update_time = ?, status = ? where id = ? AND version >= ? AND status IN (%s) RETURNING version as new_version` } else { - sql = `UPDATE blob SET version = version + 1, update_time = ?, status = ? where id = ? AND version = ? AND status IN (%s) RETURNING version as new_vesrion` + sql = `UPDATE blob SET version = version + 1, update_time = ?, status = ? where id = ? AND version = ? AND status IN (%s) RETURNING version as new_version` } var newVersion int64 diff --git a/src/server/middleware/blob/head_blob.go b/src/server/middleware/blob/head_blob.go index 483ba8b0a..9c4a6615c 100644 --- a/src/server/middleware/blob/head_blob.go +++ b/src/server/middleware/blob/head_blob.go @@ -55,9 +55,9 @@ func handleHead(req *http.Request) error { return errors.Wrapf(err, fmt.Sprintf("the request id is: %s", req.Header.Get(requestid.HeaderXRequestID))) } } - return errors.New(nil).WithMessage(fmt.Sprintf("the asking blob is delete failed, mark it as non existing, request id: %s", req.Header.Get(requestid.HeaderXRequestID))).WithCode(errors.NotFoundCode) - case blob_models.StatusDeleteFailed: return errors.New(nil).WithMessage(fmt.Sprintf("the asking blob is in GC, mark it as non existing, request id: %s", req.Header.Get(requestid.HeaderXRequestID))).WithCode(errors.NotFoundCode) + case blob_models.StatusDeleteFailed: + return errors.New(nil).WithMessage(fmt.Sprintf("the asking blob is delete failed, mark it as non existing, request id: %s", req.Header.Get(requestid.HeaderXRequestID))).WithCode(errors.NotFoundCode) default: return errors.New(nil).WithMessage(fmt.Sprintf("wrong blob status, %s", bb.Status)) } diff --git a/src/server/middleware/blob/util.go b/src/server/middleware/blob/util.go index 3fa036279..b2b26e0e8 100644 --- a/src/server/middleware/blob/util.go +++ b/src/server/middleware/blob/util.go @@ -42,7 +42,7 @@ func probeBlob(r *http.Request, digest string) error { // StatusDeleteFailed => StatusNone, and then let the proxy to handle manifest upload return probeBlob(r, digest) } - return errors.New(nil).WithMessage(fmt.Sprintf("the asking blob is delete failed, mark it as non existing, request id: %s", r.Header.Get(requestid.HeaderXRequestID))).WithCode(errors.NotFoundCode) + return errors.New(nil).WithMessage(fmt.Sprintf("the asking blob is in GC, mark it as non existing, request id: %s", r.Header.Get(requestid.HeaderXRequestID))).WithCode(errors.NotFoundCode) default: return nil }