Add object nodes command #456

Merged
fyrchik merged 1 commit from dstepanov-yadro/frostfs-node:feature/object-nodes into master 2023-06-26 07:41:35 +00:00

Closes #426

Added command to list nodes where the object should be stored and where it is actually stored.

Output example:

$ frostfs-cli object nodes -r s01.frostfs.devenv:8080 --wallet ./../frostfs-dev-env/wallets/wallet.json --cid 4NMwitbdtDGCMzQFLj6yBu35ndVvs3PEEKVihNZxUo45 --oid G37cc1rp7oBQevUNoh2SgtJw7mYRSbkjxwaa5WGUjUoM --verify-presence-all
Enter password > 
                           Netmap node| Should contain object|                                           Actually contains object|
     /dns4/s01.frostfs.devenv/tcp/8080|                  true|                                                               true|
     /dns4/s03.frostfs.devenv/tcp/8080|                  true|                                                               true|
 /dns4/s04.frostfs.devenv/tcp/8082/tls|                  true|                                                               true|
     /dns4/s02.frostfs.devenv/tcp/8080|                 false| error: can't init SDK client: gRPC dial: context deadline exceeded|


$ frostfs-cli object nodes -r s01.frostfs.devenv:8080 --wallet ./../frostfs-dev-env/wallets/wallet.json --cid 4NMwitbdtDGCMzQFLj6yBu35ndVvs3PEEKVihNZxUo45 --oid G37cc1rp7oBQevUNoh2SgtJw7mYRSbkjxwaa5WGUjUoM
Enter password > 
                           Netmap node| Should contain object| Actually contains object|
     /dns4/s01.frostfs.devenv/tcp/8080|                  true|                     true|
     /dns4/s03.frostfs.devenv/tcp/8080|                  true|                     true|
 /dns4/s04.frostfs.devenv/tcp/8082/tls|                  true|                     true|
     /dns4/s02.frostfs.devenv/tcp/8080|                 false|                         |
     
Closes #426 Added command to list nodes where the object should be stored and where it is actually stored. Output example: ``` $ frostfs-cli object nodes -r s01.frostfs.devenv:8080 --wallet ./../frostfs-dev-env/wallets/wallet.json --cid 4NMwitbdtDGCMzQFLj6yBu35ndVvs3PEEKVihNZxUo45 --oid G37cc1rp7oBQevUNoh2SgtJw7mYRSbkjxwaa5WGUjUoM --verify-presence-all Enter password > Netmap node| Should contain object| Actually contains object| /dns4/s01.frostfs.devenv/tcp/8080| true| true| /dns4/s03.frostfs.devenv/tcp/8080| true| true| /dns4/s04.frostfs.devenv/tcp/8082/tls| true| true| /dns4/s02.frostfs.devenv/tcp/8080| false| error: can't init SDK client: gRPC dial: context deadline exceeded| $ frostfs-cli object nodes -r s01.frostfs.devenv:8080 --wallet ./../frostfs-dev-env/wallets/wallet.json --cid 4NMwitbdtDGCMzQFLj6yBu35ndVvs3PEEKVihNZxUo45 --oid G37cc1rp7oBQevUNoh2SgtJw7mYRSbkjxwaa5WGUjUoM Enter password > Netmap node| Should contain object| Actually contains object| /dns4/s01.frostfs.devenv/tcp/8080| true| true| /dns4/s03.frostfs.devenv/tcp/8080| true| true| /dns4/s04.frostfs.devenv/tcp/8082/tls| true| true| /dns4/s02.frostfs.devenv/tcp/8080| false| | ```
dstepanov-yadro reviewed 2023-06-20 13:36:40 +00:00
@ -0,0 +44,4 @@
var objectNodesCmd = &cobra.Command{
Use: "nodes",
Short: "List of nodes where the object is stored",
Long: `List of nodes where the object should be stored and where it is actually stored.
Author
Member

Command description

Command description
dstepanov-yadro requested review from storage-core-committers 2023-06-20 13:36:59 +00:00
dstepanov-yadro requested review from storage-core-developers 2023-06-20 13:36:59 +00:00
aarifullin reviewed 2023-06-20 14:11:23 +00:00
@ -0,0 +149,4 @@
netmap, e = getNetMap(egCtx, cli)
return
})
if err := eg.Wait(); err != nil {
Member

Just:

err := eg.Wait()
commonCmd.ExitOnErr(cmd, "rpc error: %w", err)

:)

Just: ``` err := eg.Wait() commonCmd.ExitOnErr(cmd, "rpc error: %w", err) ``` :)
Author
Member

fixed

fixed
aarifullin reviewed 2023-06-20 14:15:17 +00:00
@ -0,0 +338,4 @@
}
func printPlacement(cmd *cobra.Command, netmap *netmapSDK.NetMap, requiredPlacement map[uint64]netmapSDK.NodeInfo, actualPlacement map[uint64]boolError) {
w := tabwriter.NewWriter(cmd.OutOrStdout(), 0, 0, 1, ' ', tabwriter.AlignRight|tabwriter.Debug)
Member

Nice! Using tabwriter is really good practice 👍

Nice! Using `tabwriter` is really good practice 👍
aarifullin reviewed 2023-06-20 14:16:04 +00:00
@ -0,0 +341,4 @@
w := tabwriter.NewWriter(cmd.OutOrStdout(), 0, 0, 1, ' ', tabwriter.AlignRight|tabwriter.Debug)
defer func() {
err := w.Flush()
if err != nil {
Member

The same: we can avoid err != nil check if we use ExitOnErr :)

The same: we can avoid `err != nil` check if we use `ExitOnErr` :)
Author
Member

fixed

fixed
dstepanov-yadro force-pushed feature/object-nodes from a7239f748a to d6d191c9c9 2023-06-20 14:25:05 +00:00 Compare
aarifullin reviewed 2023-06-20 14:27:52 +00:00
@ -0,0 +306,4 @@
}
if cli == nil {
return nil, fmt.Errorf("failed to create client: no available endpoint")
}
Member

How come? Can be cli is nil if lastErr == nil?

fmt.Errorf("failed to create client: no available endpoint") looks unexpectedly...

How come? Can be `cli` is `nil` if `lastErr == nil`? `fmt.Errorf("failed to create client: no available endpoint")` looks unexpectedly...
Author
Member

It could happen if len(addresses) == 0. Just fool-proof.

It could happen if `len(addresses) == 0`. Just fool-proof.
Member

Got it, you're right

Got it, you're right
aarifullin approved these changes 2023-06-20 15:10:50 +00:00
fyrchik reviewed 2023-06-21 13:44:19 +00:00
@ -0,0 +45,4 @@
Use: "nodes",
Short: "List of nodes where the object is stored",
Long: `List of nodes where the object should be stored and where it is actually stored.
Lock objects must exist on all nodes of the container.
Owner

There will be a space in the frostfs-cli output, is this intentional?

There will be a space in the `frostfs-cli` output, is this intentional?
Author
Member

I didn't understand what space you were talking about.

I didn't understand what space you were talking about.
Author
Member

image

![image](/attachments/f62c7af3-6806-49a9-923d-c362ee2487a4)
@ -0,0 +199,4 @@
for _, relatedObjID := range objInfo.relatedObjectIDs {
placement, err = placementBuilder.BuildPlacement(objInfo.containerID, &relatedObjID, placementPolicy)
if err != nil {
Owner

Do we need this check?

Do we need this check?
Author
Member

Why not?

Why not?
Owner

Because ExitOnErr already checks the error?

Because `ExitOnErr` already checks the error?
Author
Member

Oh, i see, fixed

Oh, i see, fixed
fyrchik marked this conversation as resolved
@ -0,0 +220,4 @@
var candidates []netmapSDK.NodeInfo
checkAllNodes, _ := cmd.Flags().GetBool(verifyPresenceAllFlag)
if checkAllNodes {
candidates = append(candidates, netmap.Nodes()...)
Owner

Why append and not just replace. Will we have duplicates?

Why `append` and not just replace. Will we have duplicates?
Author
Member

fixed

fixed
fyrchik marked this conversation as resolved
dstepanov-yadro force-pushed feature/object-nodes from d6d191c9c9 to 54dfa153c6 2023-06-22 12:35:54 +00:00 Compare
acid-ant approved these changes 2023-06-22 13:43:21 +00:00
fyrchik requested review from anikeev-yadro 2023-06-23 08:04:33 +00:00
dstepanov-yadro force-pushed feature/object-nodes from 54dfa153c6 to 9d90af801c 2023-06-23 11:19:30 +00:00 Compare
dstepanov-yadro force-pushed feature/object-nodes from 9d90af801c to e0ed3825a2 2023-06-23 11:20:53 +00:00 Compare
anikeev-yadro approved these changes 2023-06-23 12:45:33 +00:00
fyrchik merged commit 72fedff7ad into master 2023-06-26 07:41:35 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
5 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#456
No description provided.