object: Move target initialization to separate package #1344

Merged
fyrchik merged 1 commit from aarifullin/frostfs-node:feat/patch/refactor/1 into master 2024-09-05 13:04:00 +00:00
Member
  • Split the logic of write target initialization to different packages;
  • Refactor patch and put services: since both service initialize the target
    themselves.

Close #1310

* Split the logic of write target initialization to different packages; * Refactor patch and put services: since both service initialize the target themselves. Close #1310
aarifullin added the
refactoring
label 2024-08-30 09:10:13 +00:00
aarifullin added 1 commit 2024-08-30 09:10:19 +00:00
[#1310] object: Move target initialization to separate package
All checks were successful
Tests and linters / Run gofumpt (pull_request) Successful in 1m59s
DCO action / DCO (pull_request) Successful in 2m1s
Tests and linters / Tests (1.22) (pull_request) Successful in 3m45s
Pre-commit hooks / Pre-commit (pull_request) Successful in 3m48s
Tests and linters / Tests (1.23) (pull_request) Successful in 3m44s
Vulncheck / Vulncheck (pull_request) Successful in 3m47s
Tests and linters / Lint (pull_request) Successful in 4m3s
Tests and linters / Staticcheck (pull_request) Successful in 4m54s
Tests and linters / gopls check (pull_request) Successful in 5m16s
Tests and linters / Tests with -race (pull_request) Successful in 5m23s
Build / Build Components (1.22) (pull_request) Successful in 5m24s
Build / Build Components (1.23) (pull_request) Successful in 5m23s
3e1bd3a2f0
* Split the logic of write target initialization to different packages;
* Refactor patch and put services: since both service initialize the target
  themselves.

Signed-off-by: Airat Arifullin <a.arifullin@yadro.com>
aarifullin force-pushed feat/patch/refactor/1 from 3e1bd3a2f0 to 1d42455131 2024-08-30 09:12:45 +00:00 Compare
aarifullin changed title from [#1310] object: Move target initialization to separate package to WIP: [#1310] object: Move target initialization to separate package 2024-08-30 09:13:02 +00:00
aarifullin force-pushed feat/patch/refactor/1 from 1d42455131 to 64ba2b0b4a 2024-08-30 09:17:06 +00:00 Compare
dstepanov-yadro approved these changes 2024-08-30 10:16:36 +00:00
Dismissed
aarifullin changed title from WIP: [#1310] object: Move target initialization to separate package to [#1310] object: Move target initialization to separate package 2024-09-02 07:27:15 +00:00
aarifullin requested review from dstepanov-yadro 2024-09-02 07:30:01 +00:00
fyrchik reviewed 2024-09-02 07:43:36 +00:00
@ -0,0 +17,4 @@
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/user"
)
type Params struct {
Owner

Why is this field embedded, while the others are not?
IMO it is better to use explicit names in Params.

Why is this field embedded, while the others are not? IMO it is better to use explicit names in `Params`.
Author
Member

Config is the field in Params. Please, check this out

`Config` is the field in `Params`. Please, check this out
fyrchik marked this conversation as resolved
@ -0,0 +32,4 @@
SignRequestPrivateKey *ecdsa.PrivateKey
}
Owner

Why do we need a separate struct here, just to be able to convert it to the struct of the same shape?

Why do we need a separate struct here, just to be able to convert it to the struct of the same shape?
Author
Member

Here are highlighted points that aren't related to specifically to this question, but which help to understand why packages were refactored in this way:

  1. The Target initialization logic should be moved in a common package. Since both patch and put can reuse this
  2. I assumed that writer and target should be distingushed:
  • writer package's purpose is to create transformer.ObjectWriter
  • writer package is used in a few packages
  • target package's purpose is to create transformer.ChunkedObjectWriter
  • target is used only within put and patch streams

It looked ambiguous with me to use objectwriter.Params as an input parameter for target initialization (New). I admit that such convertation looks ugly - so, I'll remove it

Here are highlighted points that aren't related to specifically to this question, but which help to understand why packages were refactored in this way: 1. The `Target` initialization logic should be moved in a common package. Since both `patch` and `put` can reuse this 2. I assumed that `writer` and `target` should be distingushed: - `writer` package's purpose is to create `transformer.ObjectWriter` - `writer` package is used in a few packages - `target` package's purpose is to create `transformer.ChunkedObjectWriter` - `target` is used only within `put` and `patch` streams It looked ambiguous with me to use `objectwriter.Params` as an input parameter for target initialization (`New`). I admit that such convertation looks ugly - so, I'll remove it
Author
Member

Since target.New uses objectwriter.Params. Please, check this out

Since `target.New` uses `objectwriter.Params`. Please, check this out
fyrchik marked this conversation as resolved
Owner

Why is it public now?

Why is it public now?
Author
Member

The file has been moved to another package (now it's within common/writer) and we need to access some fields

The file has been moved to another package (now it's within `common/writer`) and we need to access some fields
fyrchik marked this conversation as resolved
@ -0,0 +38,4 @@
type FormatValidatorConfig interface {
VerifySessionTokenIssuer() bool
}
Owner

Why don't you use Config like in other code? "Static" is not even a noun (or doesn't have the meaning we are trying to convey here).

Why don't you use `Config` like in other code? "Static" is not even a noun (or doesn't have the meaning we are trying to convey here).
Author
Member

Ok, I'll rename it back

Ok, I'll rename it back
Author
Member

BTW, I have named it Static because I was not sure that using the word Config is appropriate for non-service package - as it was previosly in put service package.
Static - I meant that there parameters are set during initialzation only unlike field in Params

BTW, I have named it `Static` because I was not sure that using the word `Config` is appropriate for non-service package - as it was previosly in `put` service package. `Static` - I meant that there parameters are set during initialzation only unlike field in `Params`
fyrchik marked this conversation as resolved
@ -21,6 +21,7 @@ import (
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/core/object"
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/core/policy"
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/network"
Owner

PutSingle seems to differ heavily from the regular PUT, as it uses multiple exported entities from our new packages, without using more coarse chunks.
Why is it so? It seems we send the same object to some target. Optimizations?

PutSingle seems to differ heavily from the regular PUT, as it uses multiple exported entities from our new packages, without using more coarse chunks. Why is it so? It seems we send the same object to some target. Optimizations?
Author
Member

Ah... That's the hardest thing in this refactoring. The refactoring for single is not for optimization purpose. I believe that PutSingle is not related neither to writer nor to target. It still uses the config (currently it's Static that's going to be renamed) and NodeDescriptor.

Moving Static (Config) and common things like NodeDescriptor to one more separate package is not the big deal

Ah... That's the hardest thing in this refactoring. The refactoring for `single` is not for optimization purpose. I believe that `PutSingle` is not related neither to `writer` nor to `target`. It still uses the config (currently it's `Static` that's going to be renamed) and `NodeDescriptor`. Moving `Static` (`Config`) and common things like `NodeDescriptor` to one more separate package is not the big deal
Owner

If we go one step further and move NodeIterator to a separate package (together with it's config), will it help somehow? Or is the issue deeper?

If we go one step further and move `NodeIterator` to a separate package (together with it's config), will it help somehow? Or is the issue deeper?
fyrchik marked this conversation as resolved
@ -37,2 +38,3 @@
var errInvalidPayloadChecksum = errors.New("incorrect payload checksum")
var (
errInvalidPayloadChecksum = errors.New("incorrect payload checksum")
Owner

This error is still present in common/target/validation.go. Is it used there? Is is the same error as here?

This error is still present in `common/target/validation.go`. Is it used there? Is is the same error as here?
Author
Member

These two errors have been moved to common/errors package as they used in both target and put packages. I would not like to import errors from package target because that one who will reading the codebase won't get the idea how should he has guessed to import these errors from the package target

These two errors have been moved to `common/errors` package as they used in both `target` and `put` packages. I would *not* like to import errors from package `target` because that one who will reading the codebase won't get the idea how should he has guessed to import these errors from the package `target`
Owner

Frankly, I would avoid name clash with the package from stdlib.
Can we just reuse errors from target package? We are importing it anyway, so no new dependency occurs.

Frankly, I would avoid name clash with the package from `stdlib`. Can we just reuse errors from `target` package? We are importing it anyway, so no new dependency occurs.
Owner
@aarifullin
Author
Member

Fixed

Fixed
@ -55,4 +53,4 @@
// MaxObjectSize returns maximum payload size for the streaming session.
//
// Must be called after the successful Init.
func (p *Streamer) MaxObjectSize() uint64 {
Owner

Previously this method exported private field, what do we need this method for now?

Previously this method exported private field, what do we need this method for now?
Author
Member

Removed

Removed
fyrchik marked this conversation as resolved
fyrchik changed title from [#1310] object: Move target initialization to separate package to object: Move target initialization to separate package 2024-09-02 07:43:53 +00:00
fyrchik requested review from storage-core-committers 2024-09-02 07:43:58 +00:00
fyrchik requested review from storage-core-developers 2024-09-02 07:43:59 +00:00
aarifullin force-pushed feat/patch/refactor/1 from 64ba2b0b4a to a85561bf25 2024-09-02 10:03:02 +00:00 Compare
aarifullin force-pushed feat/patch/refactor/1 from a85561bf25 to 28a1208240 2024-09-02 10:13:39 +00:00 Compare
aarifullin force-pushed feat/patch/refactor/1 from 28a1208240 to 90cf89b26c 2024-09-04 07:24:47 +00:00 Compare
dstepanov-yadro approved these changes 2024-09-04 07:27:21 +00:00
Dismissed
acid-ant approved these changes 2024-09-04 08:19:58 +00:00
Dismissed
aarifullin force-pushed feat/patch/refactor/1 from 90cf89b26c to 1fe5c82667 2024-09-05 08:09:44 +00:00 Compare
aarifullin dismissed dstepanov-yadro's review 2024-09-05 08:09:44 +00:00
Reason:

New commits pushed, approval review dismissed automatically according to repository settings

aarifullin dismissed dstepanov-yadro's review 2024-09-05 08:09:44 +00:00
Reason:

New commits pushed, approval review dismissed automatically according to repository settings

aarifullin dismissed acid-ant's review 2024-09-05 08:09:45 +00:00
Reason:

New commits pushed, approval review dismissed automatically according to repository settings

fyrchik reviewed 2024-09-05 08:30:49 +00:00
@ -21,6 +21,8 @@ import (
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/core/object"
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/core/policy"
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/network"
targeterrors "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/services/object/common/target"
Owner

Why use different alias here?

Why use different alias here?
Author
Member

Oh, sorry. That was left after multiple renamings.
I have removed all aliases for common/target package because this package's name seems unambiguous

Oh, sorry. That was left after multiple renamings. I have removed all aliases for `common/target` package because this package's name seems unambiguous
aarifullin force-pushed feat/patch/refactor/1 from 1fe5c82667 to 18220985bf 2024-09-05 09:14:37 +00:00 Compare
fyrchik merged commit b3deb893ba into master 2024-09-05 13:04:00 +00:00
Sign in to join this conversation.
No reviewers
TrueCloudLab/storage-core-developers
No milestone
No project
No assignees
4 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#1344
No description provided.