forked from TrueCloudLab/frostfs-s3-gw
[#754] Add CID and OID to logs
Signed-off-by: Artem Tataurov <a.tataurov@yadro.com>
This commit is contained in:
parent
a68aca764b
commit
af7fbd6f32
7 changed files with 104 additions and 4 deletions
|
@ -348,6 +348,13 @@ func (h *handler) UploadPartCopy(w http.ResponseWriter, r *http.Request) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
h.log.Debug("copy details",
|
||||||
|
zap.String("reqId", reqInfo.RequestID),
|
||||||
|
zap.String("bucket", reqInfo.BucketName),
|
||||||
|
zap.Stringer("cid", bktInfo.CID),
|
||||||
|
zap.String("object", reqInfo.ObjectName),
|
||||||
|
zap.Stringer("oid", info.ID))
|
||||||
|
|
||||||
response := UploadPartCopyResponse{
|
response := UploadPartCopyResponse{
|
||||||
ETag: info.HashSum,
|
ETag: info.HashSum,
|
||||||
LastModified: info.Created.UTC().Format(time.RFC3339),
|
LastModified: info.Created.UTC().Format(time.RFC3339),
|
||||||
|
|
|
@ -730,6 +730,9 @@ func (h *handler) CreateBucketHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
h.log.Debug("target details", zap.String("reqId", reqInfo.RequestID),
|
||||||
|
zap.String("bucket", reqInfo.BucketName), zap.Stringer("cid", bktInfo.CID))
|
||||||
|
|
||||||
if p.ObjectLockEnabled {
|
if p.ObjectLockEnabled {
|
||||||
sp := &layer.PutSettingsParams{
|
sp := &layer.PutSettingsParams{
|
||||||
BktInfo: bktInfo,
|
BktInfo: bktInfo,
|
||||||
|
|
|
@ -52,6 +52,13 @@ func (h *handler) PutObjectTaggingHandler(w http.ResponseWriter, r *http.Request
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
h.log.Debug("target details",
|
||||||
|
zap.String("reqId", reqInfo.RequestID),
|
||||||
|
zap.String("bucket", reqInfo.BucketName),
|
||||||
|
zap.Stringer("cid", bktInfo.CID),
|
||||||
|
zap.String("object", reqInfo.ObjectName),
|
||||||
|
zap.Stringer("oid", nodeVersion.OID))
|
||||||
|
|
||||||
s := &SendNotificationParams{
|
s := &SendNotificationParams{
|
||||||
Event: EventObjectTaggingPut,
|
Event: EventObjectTaggingPut,
|
||||||
NotificationInfo: &data.NotificationInfo{
|
NotificationInfo: &data.NotificationInfo{
|
||||||
|
@ -99,6 +106,13 @@ func (h *handler) GetObjectTaggingHandler(w http.ResponseWriter, r *http.Request
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
h.log.Debug("target details",
|
||||||
|
zap.String("reqId", reqInfo.RequestID),
|
||||||
|
zap.String("bucket", reqInfo.BucketName),
|
||||||
|
zap.Stringer("cid", bktInfo.CID),
|
||||||
|
zap.String("object", reqInfo.ObjectName),
|
||||||
|
zap.String("oid", versionID))
|
||||||
|
|
||||||
if settings.VersioningEnabled() {
|
if settings.VersioningEnabled() {
|
||||||
w.Header().Set(api.AmzVersionID, versionID)
|
w.Header().Set(api.AmzVersionID, versionID)
|
||||||
}
|
}
|
||||||
|
@ -128,6 +142,13 @@ func (h *handler) DeleteObjectTaggingHandler(w http.ResponseWriter, r *http.Requ
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
h.log.Debug("target details",
|
||||||
|
zap.String("reqId", reqInfo.RequestID),
|
||||||
|
zap.String("bucket", reqInfo.BucketName),
|
||||||
|
zap.Stringer("cid", bktInfo.CID),
|
||||||
|
zap.String("object", reqInfo.ObjectName),
|
||||||
|
zap.Stringer("oid", nodeVersion.OID))
|
||||||
|
|
||||||
s := &SendNotificationParams{
|
s := &SendNotificationParams{
|
||||||
Event: EventObjectTaggingDelete,
|
Event: EventObjectTaggingDelete,
|
||||||
NotificationInfo: &data.NotificationInfo{
|
NotificationInfo: &data.NotificationInfo{
|
||||||
|
|
|
@ -482,11 +482,27 @@ func (n *layer) GetObjectInfo(ctx context.Context, p *HeadObjectParams) (*data.O
|
||||||
|
|
||||||
// GetExtendedObjectInfo returns meta information and corresponding info from the tree service about the object.
|
// GetExtendedObjectInfo returns meta information and corresponding info from the tree service about the object.
|
||||||
func (n *layer) GetExtendedObjectInfo(ctx context.Context, p *HeadObjectParams) (*data.ExtendedObjectInfo, error) {
|
func (n *layer) GetExtendedObjectInfo(ctx context.Context, p *HeadObjectParams) (*data.ExtendedObjectInfo, error) {
|
||||||
|
var objInfo *data.ExtendedObjectInfo
|
||||||
|
var err error
|
||||||
|
|
||||||
if len(p.VersionID) == 0 {
|
if len(p.VersionID) == 0 {
|
||||||
return n.headLastVersionIfNotDeleted(ctx, p.BktInfo, p.Object)
|
objInfo, err = n.headLastVersionIfNotDeleted(ctx, p.BktInfo, p.Object)
|
||||||
|
} else {
|
||||||
|
objInfo, err = n.headVersion(ctx, p.BktInfo, p)
|
||||||
|
}
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return n.headVersion(ctx, p.BktInfo, p)
|
reqInfo := api.GetReqInfo(ctx)
|
||||||
|
n.log.Debug("get object",
|
||||||
|
zap.String("reqId", reqInfo.RequestID),
|
||||||
|
zap.String("bucket", p.BktInfo.Name),
|
||||||
|
zap.Stringer("cid", p.BktInfo.CID),
|
||||||
|
zap.String("object", objInfo.ObjectInfo.Name),
|
||||||
|
zap.Stringer("oid", objInfo.ObjectInfo.ID))
|
||||||
|
|
||||||
|
return objInfo, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// CopyObject from one bucket into another bucket.
|
// CopyObject from one bucket into another bucket.
|
||||||
|
@ -645,7 +661,12 @@ func (n *layer) CreateBucket(ctx context.Context, p *CreateBucketParams) (*data.
|
||||||
func (n *layer) ResolveBucket(ctx context.Context, name string) (cid.ID, error) {
|
func (n *layer) ResolveBucket(ctx context.Context, name string) (cid.ID, error) {
|
||||||
var cnrID cid.ID
|
var cnrID cid.ID
|
||||||
if err := cnrID.DecodeString(name); err != nil {
|
if err := cnrID.DecodeString(name); err != nil {
|
||||||
return n.resolver.Resolve(ctx, name)
|
if cnrID, err = n.resolver.Resolve(ctx, name); err != nil {
|
||||||
|
return cid.ID{}, err
|
||||||
|
}
|
||||||
|
|
||||||
|
reqInfo := api.GetReqInfo(ctx)
|
||||||
|
n.log.Info("resolve bucket", zap.String("reqId", reqInfo.RequestID), zap.String("bucket", name), zap.Stringer("cid", cnrID))
|
||||||
}
|
}
|
||||||
|
|
||||||
return cnrID, nil
|
return cnrID, nil
|
||||||
|
|
|
@ -11,6 +11,7 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/TrueCloudLab/frostfs-s3-gw/api"
|
||||||
"github.com/TrueCloudLab/frostfs-s3-gw/api/data"
|
"github.com/TrueCloudLab/frostfs-s3-gw/api/data"
|
||||||
"github.com/TrueCloudLab/frostfs-s3-gw/api/errors"
|
"github.com/TrueCloudLab/frostfs-s3-gw/api/errors"
|
||||||
"github.com/TrueCloudLab/frostfs-s3-gw/api/layer/encryption"
|
"github.com/TrueCloudLab/frostfs-s3-gw/api/layer/encryption"
|
||||||
|
@ -228,6 +229,13 @@ func (n *layer) uploadPart(ctx context.Context, multipartInfo *data.MultipartInf
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
reqInfo := api.GetReqInfo(ctx)
|
||||||
|
n.log.Debug("upload part",
|
||||||
|
zap.String("reqId", reqInfo.RequestID),
|
||||||
|
zap.String("bucket", bktInfo.Name), zap.Stringer("cid", bktInfo.CID),
|
||||||
|
zap.String("multipart upload", p.Info.UploadID),
|
||||||
|
zap.Int("part number", p.PartNumber), zap.String("object", p.Info.Key), zap.Stringer("oid", id))
|
||||||
|
|
||||||
partInfo := &data.PartInfo{
|
partInfo := &data.PartInfo{
|
||||||
Key: p.Info.Key,
|
Key: p.Info.Key,
|
||||||
UploadID: p.Info.UploadID,
|
UploadID: p.Info.UploadID,
|
||||||
|
@ -535,6 +543,11 @@ func (n *layer) AbortMultipartUpload(ctx context.Context, p *UploadInfoParams) e
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, info := range parts {
|
for _, info := range parts {
|
||||||
|
reqInfo := api.GetReqInfo(ctx)
|
||||||
|
n.log.Debug("part details",
|
||||||
|
zap.String("reqId", reqInfo.RequestID),
|
||||||
|
zap.String("bucket", p.Bkt.Name), zap.Stringer("cid", p.Bkt.CID),
|
||||||
|
zap.String("object", info.Key), zap.Stringer("oid", info.OID))
|
||||||
if err = n.objectDelete(ctx, p.Bkt, info.OID); err != nil {
|
if err = n.objectDelete(ctx, p.Bkt, info.OID); err != nil {
|
||||||
n.log.Warn("couldn't delete part", zap.String("cid", p.Bkt.CID.EncodeToString()),
|
n.log.Warn("couldn't delete part", zap.String("cid", p.Bkt.CID.EncodeToString()),
|
||||||
zap.String("oid", info.OID.EncodeToString()), zap.Int("part number", info.Number), zap.Error(err))
|
zap.String("oid", info.OID.EncodeToString()), zap.Int("part number", info.Number), zap.Error(err))
|
||||||
|
@ -562,6 +575,11 @@ func (n *layer) ListParts(ctx context.Context, p *ListPartsParams) (*ListPartsIn
|
||||||
parts := make([]*Part, 0, len(partsInfo))
|
parts := make([]*Part, 0, len(partsInfo))
|
||||||
|
|
||||||
for _, partInfo := range partsInfo {
|
for _, partInfo := range partsInfo {
|
||||||
|
reqInfo := api.GetReqInfo(ctx)
|
||||||
|
n.log.Debug("part details",
|
||||||
|
zap.String("reqId", reqInfo.RequestID),
|
||||||
|
zap.String("container", p.Info.Bkt.Name), zap.Stringer("cid", p.Info.Bkt.CID),
|
||||||
|
zap.String("object", partInfo.Key), zap.Stringer("oid", partInfo.OID))
|
||||||
parts = append(parts, &Part{
|
parts = append(parts, &Part{
|
||||||
ETag: partInfo.ETag,
|
ETag: partInfo.ETag,
|
||||||
LastModified: partInfo.Created.UTC().Format(time.RFC3339),
|
LastModified: partInfo.Created.UTC().Format(time.RFC3339),
|
||||||
|
@ -609,10 +627,24 @@ func (n *layer) getUploadParts(ctx context.Context, p *UploadInfoParams) (*data.
|
||||||
}
|
}
|
||||||
|
|
||||||
res := make(map[int]*data.PartInfo, len(parts))
|
res := make(map[int]*data.PartInfo, len(parts))
|
||||||
for _, part := range parts {
|
partsNumbers := make([]int, len(parts))
|
||||||
|
oids := make([]string, len(parts))
|
||||||
|
for i, part := range parts {
|
||||||
res[part.Number] = part
|
res[part.Number] = part
|
||||||
|
partsNumbers[i] = part.Number
|
||||||
|
oids[i] = part.OID.EncodeToString()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
reqInfo := api.GetReqInfo(ctx)
|
||||||
|
n.log.Debug("part details",
|
||||||
|
zap.String("reqId", reqInfo.RequestID),
|
||||||
|
zap.String("bucket", p.Bkt.Name),
|
||||||
|
zap.Stringer("cid", p.Bkt.CID),
|
||||||
|
zap.String("object", p.Key),
|
||||||
|
zap.String("upload id", p.UploadID),
|
||||||
|
zap.Ints("part numbers", partsNumbers),
|
||||||
|
zap.Strings("oids", oids))
|
||||||
|
|
||||||
return multipartInfo, res, nil
|
return multipartInfo, res, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -248,6 +248,12 @@ func (n *layer) PutObject(ctx context.Context, p *PutObjectParams) (*data.Extend
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
reqInfo := api.GetReqInfo(ctx)
|
||||||
|
n.log.Debug("put object",
|
||||||
|
zap.String("reqId", reqInfo.RequestID),
|
||||||
|
zap.String("bucket", p.BktInfo.Name), zap.Stringer("cid", p.BktInfo.CID),
|
||||||
|
zap.String("object", p.Object), zap.Stringer("oid", id))
|
||||||
|
|
||||||
newVersion.OID = id
|
newVersion.OID = id
|
||||||
newVersion.ETag = hex.EncodeToString(hash)
|
newVersion.ETag = hex.EncodeToString(hash)
|
||||||
if newVersion.ID, err = n.treeService.AddVersion(ctx, p.BktInfo, newVersion); err != nil {
|
if newVersion.ID, err = n.treeService.AddVersion(ctx, p.BktInfo, newVersion); err != nil {
|
||||||
|
|
|
@ -4,11 +4,13 @@ import (
|
||||||
"context"
|
"context"
|
||||||
errorsStd "errors"
|
errorsStd "errors"
|
||||||
|
|
||||||
|
"github.com/TrueCloudLab/frostfs-s3-gw/api"
|
||||||
"github.com/TrueCloudLab/frostfs-s3-gw/api/data"
|
"github.com/TrueCloudLab/frostfs-s3-gw/api/data"
|
||||||
"github.com/TrueCloudLab/frostfs-s3-gw/api/errors"
|
"github.com/TrueCloudLab/frostfs-s3-gw/api/errors"
|
||||||
cid "github.com/TrueCloudLab/frostfs-sdk-go/container/id"
|
cid "github.com/TrueCloudLab/frostfs-sdk-go/container/id"
|
||||||
oid "github.com/TrueCloudLab/frostfs-sdk-go/object/id"
|
oid "github.com/TrueCloudLab/frostfs-sdk-go/object/id"
|
||||||
"github.com/TrueCloudLab/frostfs-sdk-go/user"
|
"github.com/TrueCloudLab/frostfs-sdk-go/user"
|
||||||
|
"go.uber.org/zap"
|
||||||
)
|
)
|
||||||
|
|
||||||
type GetObjectTaggingParams struct {
|
type GetObjectTaggingParams struct {
|
||||||
|
@ -175,6 +177,14 @@ func (n *layer) getNodeVersion(ctx context.Context, objVersion *ObjectVersion) (
|
||||||
return nil, errors.GetAPIError(errors.ErrNoSuchKey)
|
return nil, errors.GetAPIError(errors.ErrNoSuchKey)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if err == nil && version != nil && !version.IsDeleteMarker() {
|
||||||
|
reqInfo := api.GetReqInfo(ctx)
|
||||||
|
n.log.Debug("target details",
|
||||||
|
zap.String("reqId", reqInfo.RequestID),
|
||||||
|
zap.String("bucket", objVersion.BktInfo.Name), zap.Stringer("cid", objVersion.BktInfo.CID),
|
||||||
|
zap.String("object", objVersion.ObjectName), zap.Stringer("oid", version.OID))
|
||||||
|
}
|
||||||
|
|
||||||
return version, err
|
return version, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue