Simplify services (part 4) #534

Merged
fyrchik merged 1 commit from fyrchik/frostfs-node:simplify-services-part4 into master 2023-07-26 21:07:59 +00:00
Owner

Port changes from #6.
Tested container creation and object put.

See also #533

Port changes from #6. Tested container creation and object put. See also #533
fyrchik requested review from storage-core-committers 2023-07-20 08:10:47 +00:00
fyrchik requested review from storage-core-developers 2023-07-20 08:10:47 +00:00
aarifullin reviewed 2023-07-20 09:30:55 +00:00
@ -76,1 +35,3 @@
// SignResponse response with private key via signature.SignServiceMessage.
// The signature error affects the result depending on the protocol version:
// - if status return is supported, panics since we cannot return the failed status, because it will not be signed.
Member

if status return is supported, panics since we cannot return the failed status

Only unsupported statuses cannot be signed?

if !statusSupported {
    return err
}

Also, I don't see that SignResponse panics itself. Is it right that not signed error causes a panic?

> if status return is supported, panics since we cannot return the failed status Only unsupported statuses cannot be signed? ``` if !statusSupported { return err } ``` Also, I don't see that `SignResponse` panics itself. Is it right that not signed error *causes* a panic?
Member

Okay, you have copy-pasted the comment from

func signResponse(key *ecdsa.PrivateKey, resp any, statusSupported bool) error {
	err := signature.SignServiceMessage(key, resp)
	if err != nil {
		err = fmt.Errorf("could not sign response: %w", err)

		if statusSupported {
			// We can't pass this error as status code since response will be unsigned.
			// Isn't expected in practice, so panic is ok here.
			panic(err)
		}
	}

	return err
}
Okay, you have copy-pasted the comment from ``` func signResponse(key *ecdsa.PrivateKey, resp any, statusSupported bool) error { err := signature.SignServiceMessage(key, resp) if err != nil { err = fmt.Errorf("could not sign response: %w", err) if statusSupported { // We can't pass this error as status code since response will be unsigned. // Isn't expected in practice, so panic is ok here. panic(err) } } return err } ```
Author
Owner

Yes, I copypasted to minimize changes, panic is removed in the next commit.

Yes, I copypasted to minimize changes, panic is removed in the next commit.
fyrchik marked this conversation as resolved
aarifullin approved these changes 2023-07-20 12:15:54 +00:00
aarifullin left a comment
Member

LGTM

LGTM
dstepanov-yadro requested changes 2023-07-21 09:08:24 +00:00
@ -208,2 +65,2 @@
if err = signResponse(s.key, resp, statusSupported); err != nil {
return nil, err
// WrapResponse creates an appropriate response struct if it is nil.
func WrapResponse[T any](resp *T, err error) (*T, error) {

util.WrapResponse doesn't say anything about what the function does.

`util.WrapResponse` doesn't say anything about what the function does.
Author
Owner

I am not sure how to name this helper. Replaced with EnsureNonNilResponse.

I am not sure how to name this helper. Replaced with `EnsureNonNilResponse`.
dstepanov-yadro marked this conversation as resolved
@ -210,3 +69,2 @@
}
return resp, nil
return new(T), nil

The error should also be returned.

The error should also be returned.
Author
Owner

fixed

fixed
dstepanov-yadro marked this conversation as resolved
@ -215,1 +73,3 @@
func isStatusSupported(req RequestMessage) bool {
// IsStatusSupported returns true iff request version implies expecting status return.
// This allows us to handle protocol versions <=2.10 (API statuses was introduced in 2.11 only).
func IsStatusSupported(req RequestMessage) bool {

Function name is IsStatusSupported, but actually the version is being checked.

Function name is `IsStatusSupported`, but actually the version is being checked.
Author
Owner

Yes, we can determine whether the status is supported from the API version. What is the problem?
Will be removed after #533 anyway.

Yes, we can determine whether the status is supported from the API version. What is the problem? Will be removed after #533 anyway.

The problem is the difference between the name of the method and what it actually does.

The problem is the difference between the name of the method and what it actually does.
dstepanov-yadro marked this conversation as resolved
fyrchik force-pushed simplify-services-part4 from 78076ea4d3 to 5ff82ff04f 2023-07-21 15:39:24 +00:00 Compare
fyrchik requested review from dstepanov-yadro 2023-07-21 15:39:48 +00:00
dstepanov-yadro approved these changes 2023-07-24 06:53:42 +00:00
fyrchik merged commit 5ff82ff04f into master 2023-07-24 16:13:37 +00:00
fyrchik deleted branch simplify-services-part4 2023-07-24 16:13:38 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
3 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: TrueCloudLab/frostfs-node#534
No description provided.