diff --git a/server/etcdserver/apply/apply.go b/server/etcdserver/apply/apply.go index abf827fb261..432116c721b 100644 --- a/server/etcdserver/apply/apply.go +++ b/server/etcdserver/apply/apply.go @@ -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) @@ -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) { diff --git a/server/etcdserver/apply/apply_auth.go b/server/etcdserver/apply/apply_auth.go index d650c02709e..974ec283141 100644 --- a/server/etcdserver/apply/apply_auth.go +++ b/server/etcdserver/apply/apply_auth.go @@ -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 { @@ -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 diff --git a/server/etcdserver/apply/apply_auth_test.go b/server/etcdserver/apply/apply_auth_test.go index e7445a10aa9..707c1fa9f93 100644 --- a/server/etcdserver/apply/apply_auth_test.go +++ b/server/etcdserver/apply/apply_auth_test.go @@ -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) }) } @@ -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) }) diff --git a/server/etcdserver/apply/uber_applier.go b/server/etcdserver/apply/uber_applier.go index 82b7a627669..d8e9503669a 100644 --- a/server/etcdserver/apply/uber_applier.go +++ b/server/etcdserver/apply/uber_applier.go @@ -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