diff --git a/satellite/metainfo/endpoint.go b/satellite/metainfo/endpoint.go index bee298980..d12719857 100644 --- a/satellite/metainfo/endpoint.go +++ b/satellite/metainfo/endpoint.go @@ -141,10 +141,7 @@ func (endpoint *Endpoint) Close() error { return nil } func (endpoint *Endpoint) ProjectInfo(ctx context.Context, req *pb.ProjectInfoRequest) (_ *pb.ProjectInfoResponse, err error) { defer mon.Task()(&ctx)(&err) - err = endpoint.versionCollector.collect(req.Header.UserAgent, mon.Func().ShortName()) - if err != nil { - endpoint.log.Warn("unable to collect uplink version", zap.Error(err)) - } + endpoint.versionCollector.collect(req.Header.UserAgent, mon.Func().ShortName()) keyInfo, err := endpoint.validateAuth(ctx, req.Header, macaroon.Action{ Op: macaroon.ActionProjectInfo, @@ -165,10 +162,7 @@ func (endpoint *Endpoint) ProjectInfo(ctx context.Context, req *pb.ProjectInfoRe func (endpoint *Endpoint) RevokeAPIKey(ctx context.Context, req *pb.RevokeAPIKeyRequest) (resp *pb.RevokeAPIKeyResponse, err error) { defer mon.Task()(&ctx)(&err) - err = endpoint.versionCollector.collect(req.Header.UserAgent, mon.Func().ShortName()) - if err != nil { - endpoint.log.Warn("unable to collect uplink version", zap.Error(err)) - } + endpoint.versionCollector.collect(req.Header.UserAgent, mon.Func().ShortName()) macToRevoke, err := macaroon.ParseMacaroon(req.GetApiKey()) if err != nil { diff --git a/satellite/metainfo/endpoint_bucket.go b/satellite/metainfo/endpoint_bucket.go index fb62c963c..37fe1b789 100644 --- a/satellite/metainfo/endpoint_bucket.go +++ b/satellite/metainfo/endpoint_bucket.go @@ -25,10 +25,7 @@ import ( func (endpoint *Endpoint) GetBucket(ctx context.Context, req *pb.BucketGetRequest) (resp *pb.BucketGetResponse, err error) { defer mon.Task()(&ctx)(&err) - err = endpoint.versionCollector.collect(req.Header.UserAgent, mon.Func().ShortName()) - if err != nil { - endpoint.log.Warn("unable to collect uplink version", zap.Error(err)) - } + endpoint.versionCollector.collect(req.Header.UserAgent, mon.Func().ShortName()) keyInfo, err := endpoint.validateAuth(ctx, req.Header, macaroon.Action{ Op: macaroon.ActionRead, @@ -63,10 +60,7 @@ func (endpoint *Endpoint) GetBucket(ctx context.Context, req *pb.BucketGetReques func (endpoint *Endpoint) CreateBucket(ctx context.Context, req *pb.BucketCreateRequest) (resp *pb.BucketCreateResponse, err error) { defer mon.Task()(&ctx)(&err) - err = endpoint.versionCollector.collect(req.Header.UserAgent, mon.Func().ShortName()) - if err != nil { - endpoint.log.Warn("unable to collect uplink version", zap.Error(err)) - } + endpoint.versionCollector.collect(req.Header.UserAgent, mon.Func().ShortName()) keyInfo, err := endpoint.validateAuth(ctx, req.Header, macaroon.Action{ Op: macaroon.ActionWrite, @@ -147,10 +141,7 @@ func (endpoint *Endpoint) CreateBucket(ctx context.Context, req *pb.BucketCreate func (endpoint *Endpoint) DeleteBucket(ctx context.Context, req *pb.BucketDeleteRequest) (resp *pb.BucketDeleteResponse, err error) { defer mon.Task()(&ctx)(&err) - err = endpoint.versionCollector.collect(req.Header.UserAgent, mon.Func().ShortName()) - if err != nil { - endpoint.log.Warn("unable to collect uplink version", zap.Error(err)) - } + endpoint.versionCollector.collect(req.Header.UserAgent, mon.Func().ShortName()) now := time.Now() @@ -309,10 +300,7 @@ func (endpoint *Endpoint) deleteBucketObjects(ctx context.Context, projectID uui func (endpoint *Endpoint) ListBuckets(ctx context.Context, req *pb.BucketListRequest) (resp *pb.BucketListResponse, err error) { defer mon.Task()(&ctx)(&err) - err = endpoint.versionCollector.collect(req.Header.UserAgent, mon.Func().ShortName()) - if err != nil { - endpoint.log.Warn("unable to collect uplink version", zap.Error(err)) - } + endpoint.versionCollector.collect(req.Header.UserAgent, mon.Func().ShortName()) action := macaroon.Action{ // TODO: This has to be ActionList, but it seems to be set to diff --git a/satellite/metainfo/endpoint_object.go b/satellite/metainfo/endpoint_object.go index b66808da5..c21537993 100644 --- a/satellite/metainfo/endpoint_object.go +++ b/satellite/metainfo/endpoint_object.go @@ -30,10 +30,7 @@ import ( func (endpoint *Endpoint) BeginObject(ctx context.Context, req *pb.ObjectBeginRequest) (resp *pb.ObjectBeginResponse, err error) { defer mon.Task()(&ctx)(&err) - err = endpoint.versionCollector.collect(req.Header.UserAgent, mon.Func().ShortName()) - if err != nil { - endpoint.log.Warn("unable to collect uplink version", zap.Error(err)) - } + endpoint.versionCollector.collect(req.Header.UserAgent, mon.Func().ShortName()) now := time.Now() @@ -195,10 +192,7 @@ func (endpoint *Endpoint) BeginObject(ctx context.Context, req *pb.ObjectBeginRe func (endpoint *Endpoint) CommitObject(ctx context.Context, req *pb.ObjectCommitRequest) (resp *pb.ObjectCommitResponse, err error) { defer mon.Task()(&ctx)(&err) - err = endpoint.versionCollector.collect(req.Header.UserAgent, mon.Func().ShortName()) - if err != nil { - endpoint.log.Warn("unable to collect uplink version", zap.Error(err)) - } + endpoint.versionCollector.collect(req.Header.UserAgent, mon.Func().ShortName()) streamID, err := endpoint.unmarshalSatStreamID(ctx, req.StreamId) if err != nil { @@ -275,10 +269,7 @@ func (endpoint *Endpoint) CommitObject(ctx context.Context, req *pb.ObjectCommit func (endpoint *Endpoint) GetObject(ctx context.Context, req *pb.ObjectGetRequest) (resp *pb.ObjectGetResponse, err error) { defer mon.Task()(&ctx)(&err) - err = endpoint.versionCollector.collect(req.Header.UserAgent, mon.Func().ShortName()) - if err != nil { - endpoint.log.Warn("unable to collect uplink version", zap.Error(err)) - } + endpoint.versionCollector.collect(req.Header.UserAgent, mon.Func().ShortName()) keyInfo, err := endpoint.validateAuth(ctx, req.Header, macaroon.Action{ Op: macaroon.ActionRead, @@ -356,10 +347,7 @@ func (endpoint *Endpoint) DownloadObject(ctx context.Context, req *pb.ObjectDown return nil, rpcstatus.Error(rpcstatus.Canceled, "client has closed the connection") } - err = endpoint.versionCollector.collect(req.Header.UserAgent, mon.Func().ShortName()) - if err != nil { - endpoint.log.Warn("unable to collect uplink version", zap.Error(err)) - } + endpoint.versionCollector.collect(req.Header.UserAgent, mon.Func().ShortName()) keyInfo, err := endpoint.validateAuth(ctx, req.Header, macaroon.Action{ Op: macaroon.ActionRead, @@ -691,6 +679,8 @@ func calculateStreamRange(object metabase.Object, req *pb.Range) (*metabase.Stre func (endpoint *Endpoint) ListObjects(ctx context.Context, req *pb.ObjectListRequest) (resp *pb.ObjectListResponse, err error) { defer mon.Task()(&ctx)(&err) + endpoint.versionCollector.collect(req.Header.UserAgent, mon.Func().ShortName()) + keyInfo, err := endpoint.validateAuth(ctx, req.Header, macaroon.Action{ Op: macaroon.ActionList, Bucket: req.Bucket, @@ -791,10 +781,7 @@ func (endpoint *Endpoint) ListObjects(ctx context.Context, req *pb.ObjectListReq func (endpoint *Endpoint) ListPendingObjectStreams(ctx context.Context, req *pb.ObjectListPendingStreamsRequest) (resp *pb.ObjectListPendingStreamsResponse, err error) { defer mon.Task()(&ctx)(&err) - err = endpoint.versionCollector.collect(req.Header.UserAgent, mon.Func().ShortName()) - if err != nil { - endpoint.log.Warn("unable to collect uplink version", zap.Error(err)) - } + endpoint.versionCollector.collect(req.Header.UserAgent, mon.Func().ShortName()) keyInfo, err := endpoint.validateAuth(ctx, req.Header, macaroon.Action{ Op: macaroon.ActionList, @@ -878,10 +865,7 @@ func (endpoint *Endpoint) ListPendingObjectStreams(ctx context.Context, req *pb. func (endpoint *Endpoint) BeginDeleteObject(ctx context.Context, req *pb.ObjectBeginDeleteRequest) (resp *pb.ObjectBeginDeleteResponse, err error) { defer mon.Task()(&ctx)(&err) - err = endpoint.versionCollector.collect(req.Header.UserAgent, mon.Func().ShortName()) - if err != nil { - endpoint.log.Warn("unable to collect uplink version", zap.Error(err)) - } + endpoint.versionCollector.collect(req.Header.UserAgent, mon.Func().ShortName()) now := time.Now() @@ -988,10 +972,7 @@ func (endpoint *Endpoint) BeginDeleteObject(ctx context.Context, req *pb.ObjectB func (endpoint *Endpoint) GetObjectIPs(ctx context.Context, req *pb.ObjectGetIPsRequest) (resp *pb.ObjectGetIPsResponse, err error) { defer mon.Task()(&ctx)(&err) - err = endpoint.versionCollector.collect(req.Header.UserAgent, mon.Func().ShortName()) - if err != nil { - endpoint.log.Warn("unable to collect uplink version", zap.Error(err)) - } + endpoint.versionCollector.collect(req.Header.UserAgent, mon.Func().ShortName()) keyInfo, err := endpoint.validateAuth(ctx, req.Header, macaroon.Action{ Op: macaroon.ActionRead, @@ -1066,10 +1047,7 @@ func (endpoint *Endpoint) GetObjectIPs(ctx context.Context, req *pb.ObjectGetIPs func (endpoint *Endpoint) UpdateObjectMetadata(ctx context.Context, req *pb.ObjectUpdateMetadataRequest) (resp *pb.ObjectUpdateMetadataResponse, err error) { defer mon.Task()(&ctx)(&err) - err = endpoint.versionCollector.collect(req.Header.UserAgent, mon.Func().ShortName()) - if err != nil { - endpoint.log.Warn("unable to collect uplink version", zap.Error(err)) - } + endpoint.versionCollector.collect(req.Header.UserAgent, mon.Func().ShortName()) keyInfo, err := endpoint.validateAuth(ctx, req.Header, macaroon.Action{ Op: macaroon.ActionWrite, @@ -1454,10 +1432,7 @@ func groupPiecesByNodeID(segments []metabase.DeletedSegmentInfo) map[storj.NodeI func (endpoint *Endpoint) BeginMoveObject(ctx context.Context, req *pb.ObjectBeginMoveRequest) (resp *pb.ObjectBeginMoveResponse, err error) { defer mon.Task()(&ctx)(&err) - err = endpoint.versionCollector.collect(req.Header.UserAgent, mon.Func().ShortName()) - if err != nil { - endpoint.log.Warn("unable to collect uplink version", zap.Error(err)) - } + endpoint.versionCollector.collect(req.Header.UserAgent, mon.Func().ShortName()) now := time.Now() keyInfo, err := endpoint.validateAuthN(ctx, req.Header, @@ -1617,10 +1592,7 @@ func convertBeginMoveObjectResults(result metabase.BeginMoveObjectResult) (*pb.O func (endpoint *Endpoint) FinishMoveObject(ctx context.Context, req *pb.ObjectFinishMoveRequest) (resp *pb.ObjectFinishMoveResponse, err error) { defer mon.Task()(&ctx)(&err) - err = endpoint.versionCollector.collect(req.Header.UserAgent, mon.Func().ShortName()) - if err != nil { - endpoint.log.Warn("unable to collect uplink version", zap.Error(err)) - } + endpoint.versionCollector.collect(req.Header.UserAgent, mon.Func().ShortName()) streamID, err := endpoint.unmarshalSatStreamID(ctx, req.StreamId) if err != nil { @@ -1686,10 +1658,7 @@ func (endpoint *Endpoint) BeginCopyObject(ctx context.Context, req *pb.ObjectBeg return nil, rpcstatus.Error(rpcstatus.Unimplemented, "Unimplemented") } - err = endpoint.versionCollector.collect(req.Header.UserAgent, mon.Func().ShortName()) - if err != nil { - endpoint.log.Warn("unable to collect uplink version", zap.Error(err)) - } + endpoint.versionCollector.collect(req.Header.UserAgent, mon.Func().ShortName()) now := time.Now() keyInfo, err := endpoint.validateAuthN(ctx, req.Header, @@ -1853,10 +1822,7 @@ func (endpoint *Endpoint) FinishCopyObject(ctx context.Context, req *pb.ObjectFi return nil, rpcstatus.Error(rpcstatus.Unimplemented, "Unimplemented") } - err = endpoint.versionCollector.collect(req.Header.UserAgent, mon.Func().ShortName()) - if err != nil { - endpoint.log.Warn("unable to collect uplink version", zap.Error(err)) - } + endpoint.versionCollector.collect(req.Header.UserAgent, mon.Func().ShortName()) streamID, err := endpoint.unmarshalSatStreamID(ctx, req.StreamId) if err != nil { diff --git a/satellite/metainfo/endpoint_segment.go b/satellite/metainfo/endpoint_segment.go index 585689faf..c599cf1e9 100644 --- a/satellite/metainfo/endpoint_segment.go +++ b/satellite/metainfo/endpoint_segment.go @@ -32,10 +32,7 @@ func calculateSpaceUsed(segmentSize int64, numberOfPieces int, rs storj.Redundan func (endpoint *Endpoint) BeginSegment(ctx context.Context, req *pb.SegmentBeginRequest) (resp *pb.SegmentBeginResponse, err error) { defer mon.Task()(&ctx)(&err) - err = endpoint.versionCollector.collect(req.Header.UserAgent, mon.Func().ShortName()) - if err != nil { - endpoint.log.Warn("unable to collect uplink version", zap.Error(err)) - } + endpoint.versionCollector.collect(req.Header.UserAgent, mon.Func().ShortName()) streamID, err := endpoint.unmarshalSatStreamID(ctx, req.StreamId) if err != nil { @@ -142,10 +139,7 @@ func (endpoint *Endpoint) BeginSegment(ctx context.Context, req *pb.SegmentBegin func (endpoint *Endpoint) CommitSegment(ctx context.Context, req *pb.SegmentCommitRequest) (resp *pb.SegmentCommitResponse, err error) { defer mon.Task()(&ctx)(&err) - err = endpoint.versionCollector.collect(req.Header.UserAgent, mon.Func().ShortName()) - if err != nil { - endpoint.log.Warn("unable to collect uplink version", zap.Error(err)) - } + endpoint.versionCollector.collect(req.Header.UserAgent, mon.Func().ShortName()) segmentID, err := endpoint.unmarshalSatSegmentID(ctx, req.SegmentId) if err != nil { @@ -319,10 +313,7 @@ func (endpoint *Endpoint) CommitSegment(ctx context.Context, req *pb.SegmentComm func (endpoint *Endpoint) MakeInlineSegment(ctx context.Context, req *pb.SegmentMakeInlineRequest) (resp *pb.SegmentMakeInlineResponse, err error) { defer mon.Task()(&ctx)(&err) - err = endpoint.versionCollector.collect(req.Header.UserAgent, mon.Func().ShortName()) - if err != nil { - endpoint.log.Warn("unable to collect uplink version", zap.Error(err)) - } + endpoint.versionCollector.collect(req.Header.UserAgent, mon.Func().ShortName()) streamID, err := endpoint.unmarshalSatStreamID(ctx, req.StreamId) if err != nil { @@ -410,6 +401,8 @@ func (endpoint *Endpoint) MakeInlineSegment(ctx context.Context, req *pb.Segment func (endpoint *Endpoint) ListSegments(ctx context.Context, req *pb.SegmentListRequest) (resp *pb.SegmentListResponse, err error) { defer mon.Task()(&ctx)(&err) + endpoint.versionCollector.collect(req.Header.UserAgent, mon.Func().ShortName()) + streamID, err := endpoint.unmarshalSatStreamID(ctx, req.StreamId) if err != nil { return nil, rpcstatus.Error(rpcstatus.InvalidArgument, err.Error()) @@ -493,10 +486,7 @@ func (endpoint *Endpoint) DownloadSegment(ctx context.Context, req *pb.SegmentDo return nil, rpcstatus.Error(rpcstatus.Canceled, "client has closed the connection") } - err = endpoint.versionCollector.collect(req.Header.UserAgent, mon.Func().ShortName()) - if err != nil { - endpoint.log.Warn("unable to collect uplink version", zap.Error(err)) - } + endpoint.versionCollector.collect(req.Header.UserAgent, mon.Func().ShortName()) streamID, err := endpoint.unmarshalSatStreamID(ctx, req.StreamId) if err != nil { diff --git a/satellite/metainfo/version_collector.go b/satellite/metainfo/version_collector.go index e1dc645a2..78a628416 100644 --- a/satellite/metainfo/version_collector.go +++ b/satellite/metainfo/version_collector.go @@ -10,7 +10,6 @@ import ( "github.com/blang/semver" "github.com/spacemonkeygo/monkit/v3" - "github.com/zeebo/errs" "go.uber.org/zap" "storj.io/common/useragent" @@ -39,14 +38,16 @@ func newVersionCollector(log *zap.Logger) *versionCollector { } } -func (vc *versionCollector) collect(useragentRaw []byte, method string) error { +func (vc *versionCollector) collect(useragentRaw []byte, method string) { if len(useragentRaw) == 0 { - return nil + return } entries, err := useragent.ParseEntries(useragentRaw) if err != nil { - return errs.New("invalid user agent %q: %v", string(useragentRaw), err) + vc.log.Warn("unable to collect uplink version", zap.Error(err)) + mon.Meter("user_agents", monkit.NewSeriesTag("user_agent", "unparseable")).Mark(1) + return } // foundProducts tracks potentially multiple noteworthy products names from the user-agent @@ -68,8 +69,6 @@ func (vc *versionCollector) collect(useragentRaw []byte, method string) error { } else { // lets keep also general value for user agents with no known product mon.Meter("user_agents", monkit.NewSeriesTag("user_agent", "other")).Mark(1) } - - return nil } func (vc *versionCollector) sendUplinkMetric(vo versionOccurrence) {