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)
|
||||
require.NoError(t, err)
|
||||
|
||||
require.Len(t, verifiedNodes.SuccessNodeIDs, 4)
|
||||
require.Len(t, verifiedNodes.FailNodeIDs, 0)
|
||||
require.Len(t, verifiedNodes.Successes, 4)
|
||||
require.Len(t, verifiedNodes.Fails, 0)
|
||||
})
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ import (
|
||||
)
|
||||
|
||||
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
|
||||
@ -23,12 +23,12 @@ type Reporter struct {
|
||||
maxRetries int
|
||||
}
|
||||
|
||||
// RecordAuditsInfo is a struct containing arguments/return values for RecordAudits()
|
||||
type RecordAuditsInfo struct {
|
||||
SuccessNodeIDs storj.NodeIDList
|
||||
FailNodeIDs storj.NodeIDList
|
||||
OfflineNodeIDs storj.NodeIDList
|
||||
PendingAudits []*PendingAudit
|
||||
// Report contains audit result lists for nodes that succeeded, failed, were offline, or have pending audits
|
||||
type Report struct {
|
||||
Successes storj.NodeIDList
|
||||
Fails storj.NodeIDList
|
||||
Offlines storj.NodeIDList
|
||||
PendingAudits []*PendingAudit
|
||||
}
|
||||
|
||||
// NewReporter instantiates a reporter
|
||||
@ -36,37 +36,37 @@ func NewReporter(overlay *overlay.Cache, containment Containment, maxRetries int
|
||||
return &Reporter{overlay: overlay, containment: containment, maxRetries: maxRetries}
|
||||
}
|
||||
|
||||
// RecordAudits saves failed audit details to overlay
|
||||
func (reporter *Reporter) RecordAudits(ctx context.Context, req *RecordAuditsInfo) (failed *RecordAuditsInfo, err error) {
|
||||
successNodeIDs := req.SuccessNodeIDs
|
||||
failNodeIDs := req.FailNodeIDs
|
||||
offlineNodeIDs := req.OfflineNodeIDs
|
||||
// RecordAudits saves audit details to overlay
|
||||
func (reporter *Reporter) RecordAudits(ctx context.Context, req *Report) (failed *Report, err error) {
|
||||
successes := req.Successes
|
||||
fails := req.Fails
|
||||
offlines := req.Offlines
|
||||
pendingAudits := req.PendingAudits
|
||||
|
||||
var errlist errs.Group
|
||||
|
||||
retries := 0
|
||||
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
|
||||
}
|
||||
|
||||
errlist = errs.Group{}
|
||||
|
||||
if len(successNodeIDs) > 0 {
|
||||
successNodeIDs, err = reporter.recordAuditSuccessStatus(ctx, successNodeIDs)
|
||||
if len(successes) > 0 {
|
||||
successes, err = reporter.recordAuditSuccessStatus(ctx, successes)
|
||||
if err != nil {
|
||||
errlist.Add(err)
|
||||
}
|
||||
}
|
||||
if len(failNodeIDs) > 0 {
|
||||
failNodeIDs, err = reporter.recordAuditFailStatus(ctx, failNodeIDs)
|
||||
if len(fails) > 0 {
|
||||
fails, err = reporter.recordAuditFailStatus(ctx, fails)
|
||||
if err != nil {
|
||||
errlist.Add(err)
|
||||
}
|
||||
}
|
||||
if len(offlineNodeIDs) > 0 {
|
||||
offlineNodeIDs, err = reporter.recordOfflineStatus(ctx, offlineNodeIDs)
|
||||
if len(offlines) > 0 {
|
||||
offlines, err = reporter.recordOfflineStatus(ctx, offlines)
|
||||
if err != nil {
|
||||
errlist.Add(err)
|
||||
}
|
||||
@ -83,11 +83,11 @@ func (reporter *Reporter) RecordAudits(ctx context.Context, req *RecordAuditsInf
|
||||
|
||||
err = errlist.Err()
|
||||
if retries >= reporter.maxRetries && err != nil {
|
||||
return &RecordAuditsInfo{
|
||||
SuccessNodeIDs: successNodeIDs,
|
||||
FailNodeIDs: failNodeIDs,
|
||||
OfflineNodeIDs: offlineNodeIDs,
|
||||
PendingAudits: pendingAudits,
|
||||
return &Report{
|
||||
Successes: successes,
|
||||
Fails: fails,
|
||||
Offlines: offlines,
|
||||
PendingAudits: pendingAudits,
|
||||
}, errs.Combine(Error.New("some nodes failed to be updated in overlay"), err)
|
||||
}
|
||||
return nil, nil
|
||||
|
@ -82,7 +82,7 @@ func TestGetShareTimeout(t *testing.T) {
|
||||
assert.Error(t, err)
|
||||
assert.NotNil(t, verifiedNodes)
|
||||
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
|
||||
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)
|
||||
|
||||
pointer := stripe.Segment
|
||||
@ -92,15 +92,15 @@ func (verifier *Verifier) Verify(ctx context.Context, stripe *Stripe) (verifiedN
|
||||
total := int(pointer.Remote.Redundancy.GetTotal())
|
||||
|
||||
if len(sharesToAudit) < required {
|
||||
return &RecordAuditsInfo{
|
||||
OfflineNodeIDs: offlineNodes,
|
||||
return &Report{
|
||||
Offlines: offlineNodes,
|
||||
}, Error.New("not enough shares for successful audit: got %d, required %d", len(sharesToAudit), required)
|
||||
}
|
||||
|
||||
pieceNums, correctedShares, err := auditShares(ctx, required, total, sharesToAudit)
|
||||
if err != nil {
|
||||
return &RecordAuditsInfo{
|
||||
OfflineNodeIDs: offlineNodes,
|
||||
return &Report{
|
||||
Offlines: offlineNodes,
|
||||
}, err
|
||||
}
|
||||
|
||||
@ -112,18 +112,18 @@ func (verifier *Verifier) Verify(ctx context.Context, stripe *Stripe) (verifiedN
|
||||
|
||||
pendingAudits, err := createPendingAudits(containedNodes, correctedShares, stripe)
|
||||
if err != nil {
|
||||
return &RecordAuditsInfo{
|
||||
SuccessNodeIDs: successNodes,
|
||||
FailNodeIDs: failedNodes,
|
||||
OfflineNodeIDs: offlineNodes,
|
||||
return &Report{
|
||||
Successes: successNodes,
|
||||
Fails: failedNodes,
|
||||
Offlines: offlineNodes,
|
||||
}, err
|
||||
}
|
||||
|
||||
return &RecordAuditsInfo{
|
||||
SuccessNodeIDs: successNodes,
|
||||
FailNodeIDs: failedNodes,
|
||||
OfflineNodeIDs: offlineNodes,
|
||||
PendingAudits: pendingAudits,
|
||||
return &Report{
|
||||
Successes: successNodes,
|
||||
Fails: failedNodes,
|
||||
Offlines: offlineNodes,
|
||||
PendingAudits: pendingAudits,
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user