Skip to content

Commit

Permalink
Merge ffdf5f2 into 9aec291
Browse files Browse the repository at this point in the history
  • Loading branch information
serathius authored Oct 4, 2024
2 parents 9aec291 + ffdf5f2 commit 9c2335d
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 12 deletions.
6 changes: 3 additions & 3 deletions server/etcdserver/apply/apply.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ type applyFunc func(ctx context.Context, r *pb.InternalRaftRequest) *Result
type applierV3 interface {
// Apply executes the generic portion of application logic for the current applier, but
// delegates the actual execution to the applyFunc method.
Apply(ctx context.Context, r *pb.InternalRaftRequest, applyFunc applyFunc) *Result
Apply(r *pb.InternalRaftRequest, applyFunc applyFunc) *Result

Put(ctx context.Context, p *pb.PutRequest) (*pb.PutResponse, *traceutil.Trace, error)
Range(ctx context.Context, r *pb.RangeRequest) (*pb.RangeResponse, *traceutil.Trace, error)
Expand Down Expand Up @@ -146,8 +146,8 @@ func newApplierV3Backend(
txnModeWriteWithSharedBuffer: txnModeWriteWithSharedBuffer}
}

func (a *applierV3backend) Apply(ctx context.Context, r *pb.InternalRaftRequest, applyFunc applyFunc) *Result {
return applyFunc(ctx, r)
func (a *applierV3backend) Apply(r *pb.InternalRaftRequest, applyFunc applyFunc) *Result {
return applyFunc(context.TODO(), r)
}

func (a *applierV3backend) Put(ctx context.Context, p *pb.PutRequest) (resp *pb.PutResponse, trace *traceutil.Trace, err error) {
Expand Down
4 changes: 2 additions & 2 deletions server/etcdserver/apply/apply_auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func newAuthApplierV3(as auth.AuthStore, base applierV3, lessor lease.Lessor) *a
return &authApplierV3{applierV3: base, as: as, lessor: lessor}
}

func (aa *authApplierV3) Apply(ctx context.Context, r *pb.InternalRaftRequest, applyFunc applyFunc) *Result {
func (aa *authApplierV3) Apply(r *pb.InternalRaftRequest, applyFunc applyFunc) *Result {
aa.mu.Lock()
defer aa.mu.Unlock()
if r.Header != nil {
Expand All @@ -57,7 +57,7 @@ func (aa *authApplierV3) Apply(ctx context.Context, r *pb.InternalRaftRequest, a
return &Result{Err: err}
}
}
ret := aa.applierV3.Apply(ctx, r, applyFunc)
ret := aa.applierV3.Apply(r, applyFunc)
aa.authInfo.Username = ""
aa.authInfo.Revision = 0
return ret
Expand Down
8 changes: 2 additions & 6 deletions server/etcdserver/apply/apply_auth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,11 +212,9 @@ func TestAuthApplierV3_Apply(t *testing.T) {

authApplier := defaultAuthApplierV3(t)
mustCreateRolesAndEnableAuth(t, authApplier)
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()
for _, tc := range tcs {
t.Run(tc.name, func(t *testing.T) {
result := authApplier.Apply(ctx, tc.request, dummyApplyFunc)
result := authApplier.Apply(tc.request, dummyApplyFunc)
require.Equalf(t, result, tc.expectResult, "Apply: got %v, expect: %v", result, tc.expectResult)
})
}
Expand Down Expand Up @@ -380,14 +378,12 @@ func TestAuthApplierV3_AdminPermission(t *testing.T) {
}
authApplier := defaultAuthApplierV3(t)
mustCreateRolesAndEnableAuth(t, authApplier)
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()
for _, tc := range tcs {
t.Run(tc.name, func(t *testing.T) {
if tc.adminPermissionNeeded {
tc.request.Header = &pb.RequestHeader{Username: userReadOnly}
}
result := authApplier.Apply(ctx, tc.request, dummyApplyFunc)
result := authApplier.Apply(tc.request, dummyApplyFunc)
require.Equal(t, errors.Is(result.Err, auth.ErrPermissionDenied), tc.adminPermissionNeeded,
"Admin permission needed: got %v, expect: %v", errors.Is(result.Err, auth.ErrPermissionDenied), tc.adminPermissionNeeded)
})
Expand Down
2 changes: 1 addition & 1 deletion server/etcdserver/apply/uber_applier.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ func (a *uberApplier) Apply(r *pb.InternalRaftRequest) *Result {
// then dispatch() unpacks the request to a specific method (like Put),
// that gets executed down the hierarchy again:
// i.e. CorruptApplier.Put(CappedApplier.Put(...(BackendApplier.Put(...)))).
return a.applyV3.Apply(context.TODO(), r, a.dispatch)
return a.applyV3.Apply(r, a.dispatch)
}

// dispatch translates the request (r) into appropriate call (like Put) on
Expand Down

0 comments on commit 9c2335d

Please sign in to comment.