mirror of
https://github.com/pgsty/minio.git
synced 2026-11-09 17:21:51 +03:00
chore: satisfy review-fix formatting and unused-code checks
Signed-off-by: Feng Ruohang <rh@vonng.com>
This commit is contained in:
@@ -269,7 +269,6 @@ func TestBatchReviewRotationLeavesMovingSource(t *testing.T) {
|
||||
if !ri.Complete || ri.Failed || ri.PausedReason != "" || ri.Objects != 1 {
|
||||
t.Fatalf("resumed rotation: %+v", ri)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Once a move copied a version, the rotation leaves it to a later run, so the
|
||||
|
||||
+10
-2
@@ -33,10 +33,13 @@ func batchUnavailable(reason string, err error) error {
|
||||
}
|
||||
return batchJobUnavailableError{reason: reason, err: err}
|
||||
}
|
||||
|
||||
func isBatchJobUnavailable(err error) bool { var e batchJobUnavailableError; return errors.As(err, &e) }
|
||||
|
||||
func isBatchJobStopped(err error) bool {
|
||||
return isBatchJobAuthzError(err) || isBatchJobUnavailable(err)
|
||||
}
|
||||
|
||||
func batchListingError(err error) error {
|
||||
if isErrBucketNotFound(err) {
|
||||
return err
|
||||
@@ -54,6 +57,7 @@ func (ri *batchJobInfo) pause(err error) {
|
||||
ri.Complete, ri.Failed = false, false
|
||||
ri.PausedReason = err.Error()
|
||||
}
|
||||
|
||||
func (ri *batchJobInfo) savePaused(ctx context.Context, api ObjectLayer, job BatchJobRequest, err error) error {
|
||||
ri.pause(err)
|
||||
globalBatchJobsMetrics.save(job.ID, ri)
|
||||
@@ -83,8 +87,10 @@ func validateBatchJobAdminReq(ctx context.Context, w http.ResponseWriter, r *htt
|
||||
var principal batchJobPrincipal
|
||||
principal, err = submitter.principal(ctx)
|
||||
if err == nil {
|
||||
err = principal.authorizeArgs(policy.Args{AccountName: cred.AccessKey, Groups: cred.Groups,
|
||||
Action: policy.Action(policy.StartBatchJobAction), ConditionValues: getConditionValues(r, "", cred), IsOwner: owner, Claims: principal.claims}, nil)
|
||||
err = principal.authorizeArgs(policy.Args{
|
||||
AccountName: cred.AccessKey, Groups: cred.Groups,
|
||||
Action: policy.Action(policy.StartBatchJobAction), ConditionValues: getConditionValues(r, "", cred), IsOwner: owner, Claims: principal.claims,
|
||||
}, nil)
|
||||
}
|
||||
}
|
||||
if err != nil {
|
||||
@@ -119,6 +125,7 @@ func (j *BatchJobPool) beginJob(job *BatchJobRequest) bool {
|
||||
o.state = "running"
|
||||
return true
|
||||
}
|
||||
|
||||
func (j *BatchJobPool) finishJob(job *BatchJobRequest, err error) {
|
||||
j.jmu.Lock()
|
||||
defer j.jmu.Unlock()
|
||||
@@ -156,6 +163,7 @@ func (j *BatchJobPool) retryDue(now time.Time) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (j *BatchJobPool) retryLoop() {
|
||||
ticker := time.NewTicker(time.Second)
|
||||
defer ticker.Stop()
|
||||
|
||||
@@ -634,7 +634,6 @@ func TestPoolsLifecycleMissingVersion(t *testing.T) {
|
||||
// The completeness checks also hold where a set has fewer answering drives
|
||||
// than a read quorum or no version reaches one.
|
||||
func TestPoolsLifecycleHistoryEarlyReturns(t *testing.T) {
|
||||
|
||||
// Seven drives hold the key, the other nine do not have it at all.
|
||||
t.Run("minority-copy-only", func(t *testing.T) {
|
||||
s := newSplitILM(t, versioning.Enabled, splitILMRules)
|
||||
@@ -1245,14 +1244,6 @@ func TestPoolsLifecycleNullGenerations(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// authoritySideEffects collects the version IDs that removal notifications
|
||||
// and ILM expiry audit traces report.
|
||||
func authoritySideEffects(t *testing.T, run func()) (notified, traced []string) {
|
||||
t.Helper()
|
||||
notified, traced, _ = authoritySideEffectsAll(t, run)
|
||||
return notified, traced
|
||||
}
|
||||
|
||||
// authoritySideEffectsAll also returns, by version ID, the result an ILM
|
||||
// trace reports for an expiry that did not remove its version: "refused" or
|
||||
// "failed". Such traces are not removal traces.
|
||||
|
||||
@@ -195,9 +195,11 @@ func (z *erasureServerPools) deleteTierTupleLocked(ctx context.Context, bucket,
|
||||
// also checks the free marker and tuple, so a stale cleanup cannot remove
|
||||
// a different revision with the same local version ID.
|
||||
for _, record := range records {
|
||||
fi := FileInfo{VersionID: record.info.VersionID,
|
||||
fi := FileInfo{
|
||||
VersionID: record.info.VersionID,
|
||||
TransitionTier: tuple.Tier, TransitionedObjName: tuple.Object,
|
||||
TransitionVersionID: tuple.VersionID}
|
||||
TransitionVersionID: tuple.VersionID,
|
||||
}
|
||||
fi.SetTierFreeVersion()
|
||||
err := record.disk.DeleteVersion(ctx, bucket, object, fi, false, DeleteOptions{})
|
||||
if err != nil && !errors.Is(err, errFileNotFound) && !errors.Is(err, errFileVersionNotFound) {
|
||||
|
||||
@@ -140,10 +140,6 @@ func scannerLogOnceIf(ctx context.Context, err error, id string, errKind ...any)
|
||||
logger.LogOnceIf(ctx, "scanner", err, id, errKind...)
|
||||
}
|
||||
|
||||
func ilmLogIf(ctx context.Context, err error, errKind ...any) {
|
||||
logger.LogIf(ctx, "ilm", err, errKind...)
|
||||
}
|
||||
|
||||
func ilmLogOnceIf(ctx context.Context, err error, id string, errKind ...any) {
|
||||
logger.LogOnceIf(ctx, "ilm", err, id, errKind...)
|
||||
}
|
||||
|
||||
@@ -19,11 +19,18 @@ func TestAuthZPluginExplicitDecision(t *testing.T) {
|
||||
status int
|
||||
allow, fail bool
|
||||
}{
|
||||
{`{"result":true}`, 200, true, false}, {`{"result":false}`, 200, false, false},
|
||||
{`{"result":{"allow":true}}`, 200, true, false}, {`{"result":{"allow":false}}`, 200, false, false},
|
||||
{`{"result":true}`, 503, false, true}, {`{"result":true}`, 403, false, true},
|
||||
{`{}`, 200, false, true}, {`{"error":"unavailable"}`, 200, false, true}, {`{"result":null}`, 200, false, true},
|
||||
{`{"result":{}}`, 200, false, true}, {`{"result":{"allow":null}}`, 200, false, true}, {`{"result":"true"}`, 200, false, true},
|
||||
{`{"result":true}`, 200, true, false},
|
||||
{`{"result":false}`, 200, false, false},
|
||||
{`{"result":{"allow":true}}`, 200, true, false},
|
||||
{`{"result":{"allow":false}}`, 200, false, false},
|
||||
{`{"result":true}`, 503, false, true},
|
||||
{`{"result":true}`, 403, false, true},
|
||||
{`{}`, 200, false, true},
|
||||
{`{"error":"unavailable"}`, 200, false, true},
|
||||
{`{"result":null}`, 200, false, true},
|
||||
{`{"result":{}}`, 200, false, true},
|
||||
{`{"result":{"allow":null}}`, 200, false, true},
|
||||
{`{"result":"true"}`, 200, false, true},
|
||||
{`{"result":true} garbage`, 200, false, true},
|
||||
} {
|
||||
t.Run(tc.body+http.StatusText(tc.status), func(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user