adm: Refactor morph command #950

Merged
acid-ant merged 1 commit from acid-ant/frostfs-node:feature/932-nns-register-renew into master 2024-09-04 19:51:06 +00:00
Member

Move morph sub commands to separate packages.
Tested with dev-env.

Signed-off-by: Anton Nikiforov an.nikiforov@yadro.com

Move `morph` sub commands to separate packages. Tested with `dev-env`. Signed-off-by: Anton Nikiforov <an.nikiforov@yadro.com>
acid-ant force-pushed feature/932-nns-register-renew from 5611a784c3 to 9fc1f43fab 2024-02-02 05:56:48 +00:00 Compare
acid-ant changed title from WIP: adm: Refactor `morph` command to adm: Refactor `morph` command 2024-02-02 07:29:34 +00:00
acid-ant requested review from storage-core-committers 2024-02-02 07:34:50 +00:00
acid-ant requested review from storage-core-developers 2024-02-02 07:34:51 +00:00
aarifullin reviewed 2024-02-02 09:03:02 +00:00
@ -0,0 +122,4 @@
r := tar.NewReader(gr)
for h, err := r.Next(); ; h, err = r.Next() {
if err != nil {
Member

[Optional request change]

This doesn't mean everything was OK and tgz has been successully read.
How about to slightly change like that:

var h *tar.Header
var err error // or var tarErr
for h, err = r.Next(); err == nil && h != nil; h, err = r.Next() {
     // no err check here
}
if err != nil && err != io.EOF {
   return nil, fmt.Errof("ooops, tgz has not been read...")
}

WDYT? :)

[Optional request change] This doesn't mean everything was OK and `tgz` has been successully read. How about to slightly change like that: ```go var h *tar.Header var err error // or var tarErr for h, err = r.Next(); err == nil && h != nil; h, err = r.Next() { // no err check here } if err != nil && err != io.EOF { return nil, fmt.Errof("ooops, tgz has not been read...") } ``` WDYT? :)
Author
Member

Sound like Good First Issue!

Sound like `Good First Issue`!
Author
Member

Created #951 for tracking.

Created #951 for tracking.
aarifullin marked this conversation as resolved
aarifullin reviewed 2024-02-02 09:07:19 +00:00
@ -0,0 +126,4 @@
break
}
dir, _ := filepath.Split(h.Name)
Member

It seems the loop-body considers only regular files. I am sure it works fine but let's make it safer:

This check (above dir, _ := filepath.Split(h.Name)) would be OK:

if h.Typeflag != tar.TypeReg {
   continue
}
It seems the loop-body considers only regular files. I am sure it works fine but let's make it safer: This check (above `dir, _ := filepath.Split(h.Name)`) would be OK: ```go if h.Typeflag != tar.TypeReg { continue } ```
Author
Member

Created #951 for tracking.

Created #951 for tracking.
aarifullin marked this conversation as resolved
fyrchik requested changes 2024-02-02 10:53:31 +00:00
@ -0,0 +10,4 @@
"strings"
"text/tabwriter"
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/modules/morph/util"
Owner

Can we avoid having this generic package?
There are client helpers, which could be put separately, there are NNS-related routines, which could be moved too.

Can we avoid having this generic package? There are client helpers, which could be put separately, there are NNS-related routines, which could be moved too.
Author
Member

I'm planning to add these changes in the next iteration, don't want to change current implementation. Add comment here.

I'm planning to add these changes in the next iteration, don't want to change current implementation. Add comment [here](https://git.frostfs.info/TrueCloudLab/frostfs-node/issues/932#issuecomment-32356).
fyrchik marked this conversation as resolved
@ -0,0 +4,4 @@
"fmt"
"strings"
util2 "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/modules/morph/util"
Owner

Why use alias?

Why use alias?
Author
Member

Thanks, removed.

Thanks, removed.
fyrchik marked this conversation as resolved
@ -0,0 +11,4 @@
Use: "netmap-candidates",
Short: "List netmap candidates nodes",
PreRun: func(cmd *cobra.Command, _ []string) {
_ = viper.BindPFlag(util.EndpointFlag, cmd.Flags().Lookup(util.EndpointFlag))
Owner

Again, can we move flag definitions to sth like commonflags package like we have for CLI?

Again, can we move flag definitions to sth like `commonflags` package like we have for CLI?
Author
Member

Moved flags to package adm\internal\commonflags, const to package constants. Also renamed util to helper to avoid conflicts with other imports.

Moved flags to package `adm\internal\commonflags`, `const` to package `constants`. Also renamed `util` to `helper` to avoid conflicts with other imports.
fyrchik marked this conversation as resolved
fyrchik reviewed 2024-02-02 10:56:32 +00:00
@ -0,0 +48,4 @@
testInitialize(t, 16)
})
t.Run("max nodes", func(t *testing.T) {
testInitialize(t, util.MaxAlphabetNodes)
Owner

Besides dev-env, we should run TestInitialize (remove temporarily t.Skip())

Besides dev-env, we should run `TestInitialize` (remove temporarily `t.Skip()`)
Author
Member

Thanks, missed that. All tests were passed.

...
=== RUN   TestInitialize
--- PASS: TestInitialize (237.50s)
=== RUN   TestInitialize/1_nodes
size: 1
alphabet-wallets: /tmp/TestInitialize1_nodes2496607394/001
wallet[0]: 0
Stage 1: transfer GAS to alphabet nodes.
Waiting for transactions to persist...
...
Current epoch: 0, increase to 1.
Waiting for transactions to persist...
        --- PASS: TestInitialize/max_nodes/force-new-epoch (18.24s)
=== RUN   TestInitialize/max_nodes/set-config
Waiting for transactions to persist...
        --- PASS: TestInitialize/max_nodes/set-config (17.57s)
=== RUN   TestInitialize/max_nodes/set-policy
Waiting for transactions to persist...
        --- PASS: TestInitialize/max_nodes/set-policy (20.97s)
=== RUN   TestInitialize/max_nodes/remove-node
Current epoch: 0, increase to 1.
Waiting for transactions to persist...
        --- PASS: TestInitialize/max_nodes/remove-node (18.10s)
=== RUN   TestInitialize/too_many_nodes
    --- PASS: TestInitialize/too_many_nodes (0.00s)
PASS

Process finished with the exit code 0

Thanks, missed that. All tests were passed. ``` ... === RUN TestInitialize --- PASS: TestInitialize (237.50s) === RUN TestInitialize/1_nodes size: 1 alphabet-wallets: /tmp/TestInitialize1_nodes2496607394/001 wallet[0]: 0 Stage 1: transfer GAS to alphabet nodes. Waiting for transactions to persist... ... Current epoch: 0, increase to 1. Waiting for transactions to persist... --- PASS: TestInitialize/max_nodes/force-new-epoch (18.24s) === RUN TestInitialize/max_nodes/set-config Waiting for transactions to persist... --- PASS: TestInitialize/max_nodes/set-config (17.57s) === RUN TestInitialize/max_nodes/set-policy Waiting for transactions to persist... --- PASS: TestInitialize/max_nodes/set-policy (20.97s) === RUN TestInitialize/max_nodes/remove-node Current epoch: 0, increase to 1. Waiting for transactions to persist... --- PASS: TestInitialize/max_nodes/remove-node (18.10s) === RUN TestInitialize/too_many_nodes --- PASS: TestInitialize/too_many_nodes (0.00s) PASS Process finished with the exit code 0 ```
Owner

multinodes tests too?

multinodes tests too?
Author
Member

Yes, all tests in TestInitialize were passed.

Yes, all tests in `TestInitialize` were passed.
fyrchik marked this conversation as resolved
acid-ant force-pushed feature/932-nns-register-renew from 760a2daa17 to 0dfe44b7bd 2024-02-05 10:34:55 +00:00 Compare
acid-ant requested review from fyrchik 2024-02-06 06:01:59 +00:00
aarifullin approved these changes 2024-02-06 10:45:55 +00:00
acid-ant force-pushed feature/932-nns-register-renew from 0dfe44b7bd to b8631996a7 2024-02-06 10:59:13 +00:00 Compare
acid-ant force-pushed feature/932-nns-register-renew from b8631996a7 to d90703f9b0 2024-02-07 06:34:50 +00:00 Compare
acid-ant force-pushed feature/932-nns-register-renew from d90703f9b0 to 860b548c4f 2024-02-09 06:23:04 +00:00 Compare
acid-ant force-pushed feature/932-nns-register-renew from 860b548c4f to ed5ea3d468 2024-02-09 11:33:07 +00:00 Compare
acid-ant requested review from storage-core-committers 2024-02-09 11:34:01 +00:00
acid-ant requested review from storage-core-developers 2024-02-09 11:34:04 +00:00
acid-ant force-pushed feature/932-nns-register-renew from ed5ea3d468 to b7f476f970 2024-02-09 14:04:36 +00:00 Compare
acid-ant force-pushed feature/932-nns-register-renew from b7f476f970 to 034fbf5716 2024-02-11 06:29:31 +00:00 Compare
acid-ant force-pushed feature/932-nns-register-renew from 034fbf5716 to 74cfe98a6c 2024-02-12 06:19:58 +00:00 Compare
acid-ant force-pushed feature/932-nns-register-renew from 74cfe98a6c to 08b0b1be24 2024-02-13 06:52:34 +00:00 Compare
acid-ant force-pushed feature/932-nns-register-renew from 08b0b1be24 to 802192cfef 2024-02-13 06:59:41 +00:00 Compare
fyrchik reviewed 2024-02-13 07:00:26 +00:00
@ -0,0 +9,4 @@
// MaxAlphabetNodes is the maximum number of candidates allowed, which is currently limited by the size
// of the invocation script.
// See: https://github.com/nspcc-dev/neo-go/blob/740488f7f35e367eaa99a71c0a609c315fe2b0fc/pkg/core/transaction/witness.go#L10
MaxAlphabetNodes = 22
Owner

It is used in multiple packages?

It is used in multiple packages?
Owner

It is used in multiple packages?

It is used in multiple packages?
Author
Member

Yes, it is used in helper, generate and initialize.

Yes, it is used in `helper`, `generate` and `initialize`.
fyrchik marked this conversation as resolved
@ -0,0 +154,4 @@
v.Set("credentials.contract", constants.TestContractPassword)
}
func TestNextPollInterval(t *testing.T) {
Owner

This test no longer belongs here, should be in helper package.

This test no longer belongs here, should be in `helper` package.
Author
Member

Thanks, moved to helper.

Thanks, moved to `helper`.
fyrchik marked this conversation as resolved
fyrchik approved these changes 2024-02-13 07:06:58 +00:00
@ -0,0 +8,4 @@
"github.com/nspcc-dev/neo-go/pkg/wallet"
)
func AddManifestGroup(cw *wallet.Wallet, h util.Uint160, cs *ContractState) error {
Owner

It is used in multiple packages?

It is used in multiple packages?
Author
Member

Yes, in contract and initialize

Yes, in `contract` and `initialize`
fyrchik marked this conversation as resolved
acid-ant added 1 commit 2024-02-13 07:12:10 +00:00
[#948] adm: Move TestNextPollInterval to package helper
All checks were successful
Build / Build Components (1.20) (pull_request) Successful in 3m18s
DCO action / DCO (pull_request) Successful in 3m26s
Vulncheck / Vulncheck (pull_request) Successful in 3m23s
Build / Build Components (1.21) (pull_request) Successful in 3m58s
Tests and linters / Staticcheck (pull_request) Successful in 5m14s
Tests and linters / Lint (pull_request) Successful in 5m54s
Tests and linters / Tests (1.20) (pull_request) Successful in 9m24s
Tests and linters / Tests (1.21) (pull_request) Successful in 9m33s
Tests and linters / Tests with -race (pull_request) Successful in 10m36s
35370283ba
Signed-off-by: Anton Nikiforov <an.nikiforov@yadro.com>
fyrchik requested review from dstepanov-yadro 2024-02-13 07:13:03 +00:00
acid-ant requested review from aarifullin 2024-02-13 08:33:10 +00:00
dstepanov-yadro approved these changes 2024-02-13 11:28:32 +00:00
aarifullin approved these changes 2024-02-13 11:41:42 +00:00
acid-ant merged commit 35370283ba into master 2024-02-13 11:43:48 +00:00
Sign in to join this conversation.
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#950
No description provided.