Skip to content

Commit e8e907b

Browse files
authored
GRPC Unwrap: Make sa.SetOrderProcessing passthrough (letsencrypt#5604)
* Make sa.SetOrderProcessing GRPC wrapper passthrough. Also, change the server method to accept an `*sapb.OrderRequest{}` (essentially just an order ID) as the parameter instead of a whole order. Part of: letsencrypt#5533
1 parent 1bf857a commit e8e907b

File tree

9 files changed

+80
-83
lines changed

9 files changed

+80
-83
lines changed

core/interfaces.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ type StorageAdder interface {
129129
AddSerial(ctx context.Context, req *sapb.AddSerialRequest) (*emptypb.Empty, error)
130130
DeactivateRegistration(ctx context.Context, req *sapb.RegistrationID) (*emptypb.Empty, error)
131131
NewOrder(ctx context.Context, order *corepb.Order) (*corepb.Order, error)
132-
SetOrderProcessing(ctx context.Context, order *corepb.Order) error
132+
SetOrderProcessing(ctx context.Context, req *sapb.OrderRequest) (*emptypb.Empty, error)
133133
FinalizeOrder(ctx context.Context, order *corepb.Order) error
134134
SetOrderError(ctx context.Context, order *corepb.Order) error
135135
RevokeCertificate(ctx context.Context, req *sapb.RevokeCertificateRequest) (*emptypb.Empty, error)

grpc/sa-wrappers.go

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -108,11 +108,8 @@ func (sas StorageAuthorityClientWrapper) NewOrder(ctx context.Context, request *
108108
return resp, nil
109109
}
110110

111-
func (sac StorageAuthorityClientWrapper) SetOrderProcessing(ctx context.Context, order *corepb.Order) error {
112-
if _, err := sac.inner.SetOrderProcessing(ctx, order); err != nil {
113-
return err
114-
}
115-
return nil
111+
func (sac StorageAuthorityClientWrapper) SetOrderProcessing(ctx context.Context, req *sapb.OrderRequest) (*emptypb.Empty, error) {
112+
return sac.inner.SetOrderProcessing(ctx, req)
116113
}
117114

118115
func (sac StorageAuthorityClientWrapper) SetOrderError(ctx context.Context, order *corepb.Order) error {
@@ -279,16 +276,8 @@ func (sas StorageAuthorityServerWrapper) NewOrder(ctx context.Context, request *
279276
return sas.inner.NewOrder(ctx, request)
280277
}
281278

282-
func (sas StorageAuthorityServerWrapper) SetOrderProcessing(ctx context.Context, order *corepb.Order) (*emptypb.Empty, error) {
283-
if order == nil || !orderValid(order) {
284-
return nil, errIncompleteRequest
285-
}
286-
287-
if err := sas.inner.SetOrderProcessing(ctx, order); err != nil {
288-
return nil, err
289-
}
290-
291-
return &emptypb.Empty{}, nil
279+
func (sas StorageAuthorityServerWrapper) SetOrderProcessing(ctx context.Context, req *sapb.OrderRequest) (*emptypb.Empty, error) {
280+
return sas.inner.SetOrderProcessing(ctx, req)
292281
}
293282

294283
func (sas StorageAuthorityServerWrapper) SetOrderError(ctx context.Context, order *corepb.Order) (*emptypb.Empty, error) {

mocks/mocks.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -407,8 +407,8 @@ func (sa *StorageAuthority) NewOrder(_ context.Context, order *corepb.Order) (*c
407407
}
408408

409409
// SetOrderProcessing is a mock
410-
func (sa *StorageAuthority) SetOrderProcessing(_ context.Context, order *corepb.Order) error {
411-
return nil
410+
func (sa *StorageAuthority) SetOrderProcessing(_ context.Context, req *sapb.OrderRequest) (*emptypb.Empty, error) {
411+
return &emptypb.Empty{}, nil
412412
}
413413

414414
// SetOrderError is a mock

ra/ra.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1032,7 +1032,8 @@ func (ra *RegistrationAuthorityImpl) FinalizeOrder(ctx context.Context, req *rap
10321032
// Otherwise the order will be "stuck" in processing state. It can not be
10331033
// finalized because it isn't pending, but we aren't going to process it
10341034
// further because we already did and encountered an error.
1035-
if err := ra.SA.SetOrderProcessing(ctx, order); err != nil {
1035+
_, err = ra.SA.SetOrderProcessing(ctx, &sapb.OrderRequest{Id: order.Id})
1036+
if err != nil {
10361037
// Fail the order with a server internal error - we weren't able to set the
10371038
// status to processing and that's unexpected & weird.
10381039
ra.failOrder(ctx, order, probs.ServerInternal("Error setting order processing"))

sa/proto/sa.pb.go

Lines changed: 48 additions & 47 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sa/proto/sa.proto

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ service StorageAuthority {
3838
rpc AddSerial(AddSerialRequest) returns (google.protobuf.Empty) {}
3939
rpc DeactivateRegistration(RegistrationID) returns (google.protobuf.Empty) {}
4040
rpc NewOrder(core.Order) returns (core.Order) {}
41-
rpc SetOrderProcessing(core.Order) returns (google.protobuf.Empty) {}
41+
rpc SetOrderProcessing(OrderRequest) returns (google.protobuf.Empty) {}
4242
rpc SetOrderError(core.Order) returns (google.protobuf.Empty) {}
4343
rpc FinalizeOrder(core.Order) returns (google.protobuf.Empty) {}
4444
rpc GetOrder(OrderRequest) returns (core.Order) {}

sa/proto/sa_grpc.pb.go

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sa/sa.go

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -991,10 +991,13 @@ func (ssa *SQLStorageAuthority) NewOrder(ctx context.Context, req *corepb.Order)
991991
return res, nil
992992
}
993993

994-
// SetOrderProcessing updates a provided *corepb.Order in pending status to be
995-
// in processing status by updating the `beganProcessing` field of the
996-
// corresponding Order table row in the DB.
997-
func (ssa *SQLStorageAuthority) SetOrderProcessing(ctx context.Context, req *corepb.Order) error {
994+
// SetOrderProcessing updates an order from pending status to processing
995+
// status by updating the `beganProcessing` field of the corresponding
996+
// Order table row in the DB.
997+
func (ssa *SQLStorageAuthority) SetOrderProcessing(ctx context.Context, req *sapb.OrderRequest) (*emptypb.Empty, error) {
998+
if req.Id == 0 {
999+
return nil, errIncompleteRequest
1000+
}
9981001
_, overallError := db.WithTransaction(ctx, ssa.dbMap, func(txWithCtx db.Executor) (interface{}, error) {
9991002
result, err := txWithCtx.Exec(`
10001003
UPDATE orders
@@ -1015,7 +1018,10 @@ func (ssa *SQLStorageAuthority) SetOrderProcessing(ctx context.Context, req *cor
10151018

10161019
return nil, nil
10171020
})
1018-
return overallError
1021+
if overallError != nil {
1022+
return nil, overallError
1023+
}
1024+
return &emptypb.Empty{}, nil
10191025
}
10201026

10211027
// SetOrderError updates a provided Order's error field.

0 commit comments

Comments
 (0)