rename audit.RecordAuditsInfo to audit.Report (#2044)
* rename RecordAuditsInfo to Report * change comment
This commit is contained in:
parent
de8070730a
commit
e862382a6f
@ -66,7 +66,7 @@ func TestVerifierHappyPath(t *testing.T) {
|
|||||||
verifiedNodes, err := verifier.Verify(ctx, stripe)
|
verifiedNodes, err := verifier.Verify(ctx, stripe)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
require.Len(t, verifiedNodes.SuccessNodeIDs, 4)
|
require.Len(t, verifiedNodes.Successes, 4)
|
||||||
require.Len(t, verifiedNodes.FailNodeIDs, 0)
|
require.Len(t, verifiedNodes.Fails, 0)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type reporter interface {
|
type reporter interface {
|
||||||
RecordAudits(ctx context.Context, req *RecordAuditsInfo) (failed *RecordAuditsInfo, err error)
|
RecordAudits(ctx context.Context, req *Report) (failed *Report, err error)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reporter records audit reports in overlay and implements the reporter interface
|
// Reporter records audit reports in overlay and implements the reporter interface
|
||||||
@ -23,11 +23,11 @@ type Reporter struct {
|
|||||||
maxRetries int
|
maxRetries int
|
||||||
}
|
}
|
||||||
|
|
||||||
// RecordAuditsInfo is a struct containing arguments/return values for RecordAudits()
|
// Report contains audit result lists for nodes that succeeded, failed, were offline, or have pending audits
|
||||||
type RecordAuditsInfo struct {
|
type Report struct {
|
||||||
SuccessNodeIDs storj.NodeIDList
|
Successes storj.NodeIDList
|
||||||
FailNodeIDs storj.NodeIDList
|
Fails storj.NodeIDList
|
||||||
OfflineNodeIDs storj.NodeIDList
|
Offlines storj.NodeIDList
|
||||||
PendingAudits []*PendingAudit
|
PendingAudits []*PendingAudit
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -36,37 +36,37 @@ func NewReporter(overlay *overlay.Cache, containment Containment, maxRetries int
|
|||||||
return &Reporter{overlay: overlay, containment: containment, maxRetries: maxRetries}
|
return &Reporter{overlay: overlay, containment: containment, maxRetries: maxRetries}
|
||||||
}
|
}
|
||||||
|
|
||||||
// RecordAudits saves failed audit details to overlay
|
// RecordAudits saves audit details to overlay
|
||||||
func (reporter *Reporter) RecordAudits(ctx context.Context, req *RecordAuditsInfo) (failed *RecordAuditsInfo, err error) {
|
func (reporter *Reporter) RecordAudits(ctx context.Context, req *Report) (failed *Report, err error) {
|
||||||
successNodeIDs := req.SuccessNodeIDs
|
successes := req.Successes
|
||||||
failNodeIDs := req.FailNodeIDs
|
fails := req.Fails
|
||||||
offlineNodeIDs := req.OfflineNodeIDs
|
offlines := req.Offlines
|
||||||
pendingAudits := req.PendingAudits
|
pendingAudits := req.PendingAudits
|
||||||
|
|
||||||
var errlist errs.Group
|
var errlist errs.Group
|
||||||
|
|
||||||
retries := 0
|
retries := 0
|
||||||
for retries < reporter.maxRetries {
|
for retries < reporter.maxRetries {
|
||||||
if len(successNodeIDs) == 0 && len(failNodeIDs) == 0 && len(offlineNodeIDs) == 0 {
|
if len(successes) == 0 && len(fails) == 0 && len(offlines) == 0 {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
errlist = errs.Group{}
|
errlist = errs.Group{}
|
||||||
|
|
||||||
if len(successNodeIDs) > 0 {
|
if len(successes) > 0 {
|
||||||
successNodeIDs, err = reporter.recordAuditSuccessStatus(ctx, successNodeIDs)
|
successes, err = reporter.recordAuditSuccessStatus(ctx, successes)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
errlist.Add(err)
|
errlist.Add(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if len(failNodeIDs) > 0 {
|
if len(fails) > 0 {
|
||||||
failNodeIDs, err = reporter.recordAuditFailStatus(ctx, failNodeIDs)
|
fails, err = reporter.recordAuditFailStatus(ctx, fails)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
errlist.Add(err)
|
errlist.Add(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if len(offlineNodeIDs) > 0 {
|
if len(offlines) > 0 {
|
||||||
offlineNodeIDs, err = reporter.recordOfflineStatus(ctx, offlineNodeIDs)
|
offlines, err = reporter.recordOfflineStatus(ctx, offlines)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
errlist.Add(err)
|
errlist.Add(err)
|
||||||
}
|
}
|
||||||
@ -83,10 +83,10 @@ func (reporter *Reporter) RecordAudits(ctx context.Context, req *RecordAuditsInf
|
|||||||
|
|
||||||
err = errlist.Err()
|
err = errlist.Err()
|
||||||
if retries >= reporter.maxRetries && err != nil {
|
if retries >= reporter.maxRetries && err != nil {
|
||||||
return &RecordAuditsInfo{
|
return &Report{
|
||||||
SuccessNodeIDs: successNodeIDs,
|
Successes: successes,
|
||||||
FailNodeIDs: failNodeIDs,
|
Fails: fails,
|
||||||
OfflineNodeIDs: offlineNodeIDs,
|
Offlines: offlines,
|
||||||
PendingAudits: pendingAudits,
|
PendingAudits: pendingAudits,
|
||||||
}, errs.Combine(Error.New("some nodes failed to be updated in overlay"), err)
|
}, errs.Combine(Error.New("some nodes failed to be updated in overlay"), err)
|
||||||
}
|
}
|
||||||
|
@ -82,7 +82,7 @@ func TestGetShareTimeout(t *testing.T) {
|
|||||||
assert.Error(t, err)
|
assert.Error(t, err)
|
||||||
assert.NotNil(t, verifiedNodes)
|
assert.NotNil(t, verifiedNodes)
|
||||||
for i := 0; i < k; i++ {
|
for i := 0; i < k; i++ {
|
||||||
assert.True(t, contains(verifiedNodes.OfflineNodeIDs, pieces[i].NodeId))
|
assert.True(t, contains(verifiedNodes.Offlines, pieces[i].NodeId))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -53,7 +53,7 @@ func NewVerifier(log *zap.Logger, transport transport.Client, overlay *overlay.C
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Verify downloads shares then verifies the data correctness at the given stripe
|
// Verify downloads shares then verifies the data correctness at the given stripe
|
||||||
func (verifier *Verifier) Verify(ctx context.Context, stripe *Stripe) (verifiedNodes *RecordAuditsInfo, err error) {
|
func (verifier *Verifier) Verify(ctx context.Context, stripe *Stripe) (verifiedNodes *Report, err error) {
|
||||||
defer mon.Task()(&ctx)(&err)
|
defer mon.Task()(&ctx)(&err)
|
||||||
|
|
||||||
pointer := stripe.Segment
|
pointer := stripe.Segment
|
||||||
@ -92,15 +92,15 @@ func (verifier *Verifier) Verify(ctx context.Context, stripe *Stripe) (verifiedN
|
|||||||
total := int(pointer.Remote.Redundancy.GetTotal())
|
total := int(pointer.Remote.Redundancy.GetTotal())
|
||||||
|
|
||||||
if len(sharesToAudit) < required {
|
if len(sharesToAudit) < required {
|
||||||
return &RecordAuditsInfo{
|
return &Report{
|
||||||
OfflineNodeIDs: offlineNodes,
|
Offlines: offlineNodes,
|
||||||
}, Error.New("not enough shares for successful audit: got %d, required %d", len(sharesToAudit), required)
|
}, Error.New("not enough shares for successful audit: got %d, required %d", len(sharesToAudit), required)
|
||||||
}
|
}
|
||||||
|
|
||||||
pieceNums, correctedShares, err := auditShares(ctx, required, total, sharesToAudit)
|
pieceNums, correctedShares, err := auditShares(ctx, required, total, sharesToAudit)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return &RecordAuditsInfo{
|
return &Report{
|
||||||
OfflineNodeIDs: offlineNodes,
|
Offlines: offlineNodes,
|
||||||
}, err
|
}, err
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -112,17 +112,17 @@ func (verifier *Verifier) Verify(ctx context.Context, stripe *Stripe) (verifiedN
|
|||||||
|
|
||||||
pendingAudits, err := createPendingAudits(containedNodes, correctedShares, stripe)
|
pendingAudits, err := createPendingAudits(containedNodes, correctedShares, stripe)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return &RecordAuditsInfo{
|
return &Report{
|
||||||
SuccessNodeIDs: successNodes,
|
Successes: successNodes,
|
||||||
FailNodeIDs: failedNodes,
|
Fails: failedNodes,
|
||||||
OfflineNodeIDs: offlineNodes,
|
Offlines: offlineNodes,
|
||||||
}, err
|
}, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return &RecordAuditsInfo{
|
return &Report{
|
||||||
SuccessNodeIDs: successNodes,
|
Successes: successNodes,
|
||||||
FailNodeIDs: failedNodes,
|
Fails: failedNodes,
|
||||||
OfflineNodeIDs: offlineNodes,
|
Offlines: offlineNodes,
|
||||||
PendingAudits: pendingAudits,
|
PendingAudits: pendingAudits,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user