diff --git a/pkg/audit/result.go b/pkg/audit/result.go index 6f5ea9f5..9ebb564e 100644 --- a/pkg/audit/result.go +++ b/pkg/audit/result.go @@ -124,6 +124,34 @@ func (r *Result) SetComplete(v bool) { SetComplete(v) } +// Requests returns number of requests made by PoR audit check to get +// all headers of the objects inside storage groups. +func (r *Result) Requests() uint32 { + return (*audit.DataAuditResult)(r). + GetRequests() +} + +// SetRequests sets number of requests made by PoR audit check to get +// all headers of the objects inside storage groups. +func (r *Result) SetRequests(v uint32) { + (*audit.DataAuditResult)(r). + SetRequests(v) +} + +// Retries returns number of retries made by PoR audit check to get +// all headers of the objects inside storage groups. +func (r *Result) Retries() uint32 { + return (*audit.DataAuditResult)(r). + GetRetries() +} + +// SetRetries sets number of retries made by PoR audit check to get +// all headers of the objects inside storage groups. +func (r *Result) SetRetries(v uint32) { + (*audit.DataAuditResult)(r). + SetRetries(v) +} + // PassSG returns list of Storage Groups that passed audit PoR stage. func (r *Result) PassSG() []*object.ID { mV2 := (*audit.DataAuditResult)(r). diff --git a/pkg/audit/result_test.go b/pkg/audit/result_test.go index 57038a34..af4a497e 100644 --- a/pkg/audit/result_test.go +++ b/pkg/audit/result_test.go @@ -50,6 +50,14 @@ func TestResult(t *testing.T) { r.SetComplete(true) require.True(t, r.Complete()) + requests := uint32(2) + r.SetRequests(requests) + require.Equal(t, requests, r.Requests()) + + retries := uint32(1) + r.SetRetries(retries) + require.Equal(t, retries, r.Retries()) + passSG := []*object.ID{testOID(), testOID()} r.SetPassSG(passSG) require.Equal(t, passSG, r.PassSG()) @@ -86,6 +94,8 @@ func TestStorageGroupEncoding(t *testing.T) { r.SetPublicKey([]byte{1, 2, 3}) r.SetPassSG([]*object.ID{testOID(), testOID()}) r.SetFailSG([]*object.ID{testOID(), testOID()}) + r.SetRequests(3) + r.SetRetries(2) r.SetHit(1) r.SetMiss(2) r.SetFail(3) diff --git a/v2/audit/convert.go b/v2/audit/convert.go index 43849533..6402041c 100644 --- a/v2/audit/convert.go +++ b/v2/audit/convert.go @@ -36,6 +36,9 @@ func DataAuditResultToGRPCMessage(a *DataAuditResult) *audit.DataAuditResult { refs.ObjectIDListToGRPCMessage(a.GetFailSG()), ) + m.SetRequests(a.GetRequests()) + m.SetRetries(a.GetRetries()) + m.SetHit(a.GetHit()) m.SetMiss(a.GetMiss()) m.SetFail(a.GetFail()) @@ -77,6 +80,9 @@ func DataAuditResultFromGRPCMessage(m *audit.DataAuditResult) *DataAuditResult { refs.ObjectIDListFromGRPCMessage(m.GetFailSg()), ) + a.SetRequests(m.GetRequests()) + a.SetRetries(m.GetRetries()) + a.SetHit(m.GetHit()) a.SetMiss(m.GetMiss()) a.SetFail(m.GetFail()) diff --git a/v2/audit/grpc/types.go b/v2/audit/grpc/types.go index 2c225efb..d8dd0d12 100644 --- a/v2/audit/grpc/types.go +++ b/v2/audit/grpc/types.go @@ -39,6 +39,20 @@ func (x *DataAuditResult) SetComplete(v bool) { } } +// SetRequests is a Requests field setter. +func (x *DataAuditResult) SetRequests(v uint32) { + if x != nil { + x.Requests = v + } +} + +// SetRetries is a Retries field setter. +func (x *DataAuditResult) SetRetries(v uint32) { + if x != nil { + x.Retries = v + } +} + // SetPassSg is a PassSg field setter. func (x *DataAuditResult) SetPassSg(v []*refs.ObjectID) { if x != nil { diff --git a/v2/audit/grpc/types.pb.go b/v2/audit/grpc/types.pb.go index 32daf3a1..dddc4412 100644 --- a/v2/audit/grpc/types.pb.go +++ b/v2/audit/grpc/types.pb.go @@ -44,24 +44,28 @@ type DataAuditResult struct { PublicKey []byte `protobuf:"bytes,4,opt,name=public_key,json=publicKey,proto3" json:"public_key,omitempty"` // Shows if Data Audit process was complete in time or if it was cancelled Complete bool `protobuf:"varint,5,opt,name=complete,proto3" json:"complete,omitempty"` + // Number of request done at PoR stage + Requests uint32 `protobuf:"varint,6,opt,name=requests,proto3" json:"requests,omitempty"` + // Number of retries done at PoR stage + Retries uint32 `protobuf:"varint,7,opt,name=retries,proto3" json:"retries,omitempty"` // List of Storage Groups that passed audit PoR stage - PassSg []*grpc.ObjectID `protobuf:"bytes,6,rep,name=pass_sg,json=passSG,proto3" json:"pass_sg,omitempty"` + PassSg []*grpc.ObjectID `protobuf:"bytes,8,rep,name=pass_sg,json=passSG,proto3" json:"pass_sg,omitempty"` // List of Storage Groups that failed audit PoR stage - FailSg []*grpc.ObjectID `protobuf:"bytes,7,rep,name=fail_sg,json=failSG,proto3" json:"fail_sg,omitempty"` + FailSg []*grpc.ObjectID `protobuf:"bytes,9,rep,name=fail_sg,json=failSG,proto3" json:"fail_sg,omitempty"` // Number of sampled objects under audit placed in an optimal way according to // the containers placement policy when checking PoP - Hit uint32 `protobuf:"varint,8,opt,name=hit,proto3" json:"hit,omitempty"` + Hit uint32 `protobuf:"varint,10,opt,name=hit,proto3" json:"hit,omitempty"` // Number of sampled objects under audit placed in suboptimal way according to // the containers placement policy, but still at a satisfactory level when // checking PoP - Miss uint32 `protobuf:"varint,9,opt,name=miss,proto3" json:"miss,omitempty"` + Miss uint32 `protobuf:"varint,11,opt,name=miss,proto3" json:"miss,omitempty"` // Number of sampled objects under audit stored in a way not confirming // placement policy or not found at all when checking PoP - Fail uint32 `protobuf:"varint,10,opt,name=fail,proto3" json:"fail,omitempty"` + Fail uint32 `protobuf:"varint,12,opt,name=fail,proto3" json:"fail,omitempty"` // List of storage node public keys that passed at least one PDP - PassNodes [][]byte `protobuf:"bytes,11,rep,name=pass_nodes,json=passNodes,proto3" json:"pass_nodes,omitempty"` + PassNodes [][]byte `protobuf:"bytes,13,rep,name=pass_nodes,json=passNodes,proto3" json:"pass_nodes,omitempty"` // List of storage node public keys that failed at least one PDP - FailNodes [][]byte `protobuf:"bytes,12,rep,name=fail_nodes,json=failNodes,proto3" json:"fail_nodes,omitempty"` + FailNodes [][]byte `protobuf:"bytes,14,rep,name=fail_nodes,json=failNodes,proto3" json:"fail_nodes,omitempty"` } func (x *DataAuditResult) Reset() { @@ -131,6 +135,20 @@ func (x *DataAuditResult) GetComplete() bool { return false } +func (x *DataAuditResult) GetRequests() uint32 { + if x != nil { + return x.Requests + } + return 0 +} + +func (x *DataAuditResult) GetRetries() uint32 { + if x != nil { + return x.Retries + } + return 0 +} + func (x *DataAuditResult) GetPassSg() []*grpc.ObjectID { if x != nil { return x.PassSg @@ -187,7 +205,7 @@ var file_v2_audit_grpc_types_proto_rawDesc = []byte{ 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0f, 0x6e, 0x65, 0x6f, 0x2e, 0x66, 0x73, 0x2e, 0x76, 0x32, 0x2e, 0x61, 0x75, 0x64, 0x69, 0x74, 0x1a, 0x18, 0x76, 0x32, 0x2f, 0x72, 0x65, 0x66, 0x73, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x2f, 0x74, 0x79, 0x70, 0x65, 0x73, - 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xbe, 0x03, 0x0a, 0x0f, 0x44, 0x61, 0x74, 0x61, 0x41, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xf4, 0x03, 0x0a, 0x0f, 0x44, 0x61, 0x74, 0x61, 0x41, 0x75, 0x64, 0x69, 0x74, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x12, 0x31, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x6e, 0x65, 0x6f, 0x2e, 0x66, 0x73, 0x2e, 0x76, 0x32, 0x2e, 0x72, 0x65, 0x66, 0x73, 0x2e, 0x56, 0x65, 0x72, @@ -201,26 +219,30 @@ var file_v2_audit_grpc_types_proto_rawDesc = []byte{ 0x0a, 0x0a, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x09, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x4b, 0x65, 0x79, 0x12, 0x1a, 0x0a, 0x08, 0x63, 0x6f, 0x6d, 0x70, 0x6c, 0x65, 0x74, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x08, 0x52, - 0x08, 0x63, 0x6f, 0x6d, 0x70, 0x6c, 0x65, 0x74, 0x65, 0x12, 0x31, 0x0a, 0x07, 0x70, 0x61, 0x73, - 0x73, 0x5f, 0x73, 0x67, 0x18, 0x06, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x6e, 0x65, 0x6f, - 0x2e, 0x66, 0x73, 0x2e, 0x76, 0x32, 0x2e, 0x72, 0x65, 0x66, 0x73, 0x2e, 0x4f, 0x62, 0x6a, 0x65, - 0x63, 0x74, 0x49, 0x44, 0x52, 0x06, 0x70, 0x61, 0x73, 0x73, 0x53, 0x47, 0x12, 0x31, 0x0a, 0x07, - 0x66, 0x61, 0x69, 0x6c, 0x5f, 0x73, 0x67, 0x18, 0x07, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x18, 0x2e, - 0x6e, 0x65, 0x6f, 0x2e, 0x66, 0x73, 0x2e, 0x76, 0x32, 0x2e, 0x72, 0x65, 0x66, 0x73, 0x2e, 0x4f, - 0x62, 0x6a, 0x65, 0x63, 0x74, 0x49, 0x44, 0x52, 0x06, 0x66, 0x61, 0x69, 0x6c, 0x53, 0x47, 0x12, - 0x10, 0x0a, 0x03, 0x68, 0x69, 0x74, 0x18, 0x08, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x03, 0x68, 0x69, - 0x74, 0x12, 0x12, 0x0a, 0x04, 0x6d, 0x69, 0x73, 0x73, 0x18, 0x09, 0x20, 0x01, 0x28, 0x0d, 0x52, - 0x04, 0x6d, 0x69, 0x73, 0x73, 0x12, 0x12, 0x0a, 0x04, 0x66, 0x61, 0x69, 0x6c, 0x18, 0x0a, 0x20, - 0x01, 0x28, 0x0d, 0x52, 0x04, 0x66, 0x61, 0x69, 0x6c, 0x12, 0x1d, 0x0a, 0x0a, 0x70, 0x61, 0x73, - 0x73, 0x5f, 0x6e, 0x6f, 0x64, 0x65, 0x73, 0x18, 0x0b, 0x20, 0x03, 0x28, 0x0c, 0x52, 0x09, 0x70, - 0x61, 0x73, 0x73, 0x4e, 0x6f, 0x64, 0x65, 0x73, 0x12, 0x1d, 0x0a, 0x0a, 0x66, 0x61, 0x69, 0x6c, - 0x5f, 0x6e, 0x6f, 0x64, 0x65, 0x73, 0x18, 0x0c, 0x20, 0x03, 0x28, 0x0c, 0x52, 0x09, 0x66, 0x61, - 0x69, 0x6c, 0x4e, 0x6f, 0x64, 0x65, 0x73, 0x42, 0x4c, 0x5a, 0x35, 0x67, 0x69, 0x74, 0x68, 0x75, - 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6e, 0x73, 0x70, 0x63, 0x63, 0x2d, 0x64, 0x65, 0x76, 0x2f, - 0x6e, 0x65, 0x6f, 0x66, 0x73, 0x2d, 0x61, 0x70, 0x69, 0x2d, 0x67, 0x6f, 0x2f, 0x76, 0x32, 0x2f, - 0x61, 0x75, 0x64, 0x69, 0x74, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x3b, 0x61, 0x75, 0x64, 0x69, 0x74, - 0xaa, 0x02, 0x12, 0x4e, 0x65, 0x6f, 0x46, 0x53, 0x2e, 0x41, 0x50, 0x49, 0x2e, 0x76, 0x32, 0x2e, - 0x41, 0x75, 0x64, 0x69, 0x74, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x08, 0x63, 0x6f, 0x6d, 0x70, 0x6c, 0x65, 0x74, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x72, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x73, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x08, 0x72, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x73, 0x12, 0x18, 0x0a, 0x07, 0x72, 0x65, 0x74, 0x72, 0x69, 0x65, 0x73, + 0x18, 0x07, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x07, 0x72, 0x65, 0x74, 0x72, 0x69, 0x65, 0x73, 0x12, + 0x31, 0x0a, 0x07, 0x70, 0x61, 0x73, 0x73, 0x5f, 0x73, 0x67, 0x18, 0x08, 0x20, 0x03, 0x28, 0x0b, + 0x32, 0x18, 0x2e, 0x6e, 0x65, 0x6f, 0x2e, 0x66, 0x73, 0x2e, 0x76, 0x32, 0x2e, 0x72, 0x65, 0x66, + 0x73, 0x2e, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x49, 0x44, 0x52, 0x06, 0x70, 0x61, 0x73, 0x73, + 0x53, 0x47, 0x12, 0x31, 0x0a, 0x07, 0x66, 0x61, 0x69, 0x6c, 0x5f, 0x73, 0x67, 0x18, 0x09, 0x20, + 0x03, 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x6e, 0x65, 0x6f, 0x2e, 0x66, 0x73, 0x2e, 0x76, 0x32, 0x2e, + 0x72, 0x65, 0x66, 0x73, 0x2e, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x49, 0x44, 0x52, 0x06, 0x66, + 0x61, 0x69, 0x6c, 0x53, 0x47, 0x12, 0x10, 0x0a, 0x03, 0x68, 0x69, 0x74, 0x18, 0x0a, 0x20, 0x01, + 0x28, 0x0d, 0x52, 0x03, 0x68, 0x69, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x6d, 0x69, 0x73, 0x73, 0x18, + 0x0b, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x04, 0x6d, 0x69, 0x73, 0x73, 0x12, 0x12, 0x0a, 0x04, 0x66, + 0x61, 0x69, 0x6c, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x04, 0x66, 0x61, 0x69, 0x6c, 0x12, + 0x1d, 0x0a, 0x0a, 0x70, 0x61, 0x73, 0x73, 0x5f, 0x6e, 0x6f, 0x64, 0x65, 0x73, 0x18, 0x0d, 0x20, + 0x03, 0x28, 0x0c, 0x52, 0x09, 0x70, 0x61, 0x73, 0x73, 0x4e, 0x6f, 0x64, 0x65, 0x73, 0x12, 0x1d, + 0x0a, 0x0a, 0x66, 0x61, 0x69, 0x6c, 0x5f, 0x6e, 0x6f, 0x64, 0x65, 0x73, 0x18, 0x0e, 0x20, 0x03, + 0x28, 0x0c, 0x52, 0x09, 0x66, 0x61, 0x69, 0x6c, 0x4e, 0x6f, 0x64, 0x65, 0x73, 0x42, 0x4c, 0x5a, + 0x35, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6e, 0x73, 0x70, 0x63, + 0x63, 0x2d, 0x64, 0x65, 0x76, 0x2f, 0x6e, 0x65, 0x6f, 0x66, 0x73, 0x2d, 0x61, 0x70, 0x69, 0x2d, + 0x67, 0x6f, 0x2f, 0x76, 0x32, 0x2f, 0x61, 0x75, 0x64, 0x69, 0x74, 0x2f, 0x67, 0x72, 0x70, 0x63, + 0x3b, 0x61, 0x75, 0x64, 0x69, 0x74, 0xaa, 0x02, 0x12, 0x4e, 0x65, 0x6f, 0x46, 0x53, 0x2e, 0x41, + 0x50, 0x49, 0x2e, 0x76, 0x32, 0x2e, 0x41, 0x75, 0x64, 0x69, 0x74, 0x62, 0x06, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x33, } var ( diff --git a/v2/audit/marshal.go b/v2/audit/marshal.go index 9aedb167..f1a0c599 100644 --- a/v2/audit/marshal.go +++ b/v2/audit/marshal.go @@ -14,6 +14,8 @@ const ( cidFNum pubKeyFNum completeFNum + requestsFNum + retriesFNum passSGFNum failSGFNum hitFNum @@ -74,6 +76,20 @@ func (a *DataAuditResult) StableMarshal(buf []byte) ([]byte, error) { offset += n + n, err = proto.UInt32Marshal(requestsFNum, buf[offset:], a.requests) + if err != nil { + return nil, err + } + + offset += n + + n, err = proto.UInt32Marshal(retriesFNum, buf[offset:], a.retries) + if err != nil { + return nil, err + } + + offset += n + n, err = refs.ObjectIDNestedListMarshal(passSGFNum, buf[offset:], a.passSG) if err != nil { return nil, err @@ -136,6 +152,8 @@ func (a *DataAuditResult) StableSize() (size int) { size += proto.NestedStructureSize(cidFNum, a.cid) size += proto.BytesSize(pubKeyFNum, a.pubKey) size += proto.BoolSize(completeFNum, a.complete) + size += proto.UInt32Size(requestsFNum, a.requests) + size += proto.UInt32Size(retriesFNum, a.retries) size += refs.ObjectIDNestedListSize(passSGFNum, a.passSG) size += refs.ObjectIDNestedListSize(failSGFNum, a.failSG) size += proto.UInt32Size(hitFNum, a.hit) diff --git a/v2/audit/marshal_test.go b/v2/audit/marshal_test.go index e9212edd..bac2dbe7 100644 --- a/v2/audit/marshal_test.go +++ b/v2/audit/marshal_test.go @@ -43,6 +43,8 @@ func generateDataAuditResult() *audit.DataAuditResult { a.SetContainerID(cid) a.SetPublicKey([]byte("Public key")) a.SetComplete(true) + a.SetRequests(10) + a.SetRetries(9) a.SetPassSG([]*refs.ObjectID{oid1, oid2}) a.SetFailSG([]*refs.ObjectID{oid2, oid1}) a.SetHit(1) diff --git a/v2/audit/types.go b/v2/audit/types.go index 67a6fd3c..35aa52aa 100644 --- a/v2/audit/types.go +++ b/v2/audit/types.go @@ -11,6 +11,8 @@ type DataAuditResult struct { auditEpoch uint64 + requests, retries uint32 + hit, miss, fail uint32 cid *refs.ContainerID @@ -120,6 +122,42 @@ func (a *DataAuditResult) SetFailSG(v []*refs.ObjectID) { } } +// GetRequests returns number of requests made by PoR audit check to get +// all headers of the objects inside storage groups. +func (a *DataAuditResult) GetRequests() uint32 { + if a != nil { + return a.requests + } + + return 0 +} + +// SetRequests sets number of requests made by PoR audit check to get +// all headers of the objects inside storage groups. +func (a *DataAuditResult) SetRequests(v uint32) { + if a != nil { + a.requests = v + } +} + +// GetRetries returns number of retries made by PoR audit check to get +// all headers of the objects inside storage groups. +func (a *DataAuditResult) GetRetries() uint32 { + if a != nil { + return a.retries + } + + return 0 +} + +// SetRetries sets number of retries made by PoR audit check to get +// all headers of the objects inside storage groups. +func (a *DataAuditResult) SetRetries(v uint32) { + if a != nil { + a.retries = v + } +} + // GetHit returns number of sampled objects under audit placed // in an optimal way according to the containers placement policy // when checking PoP.