From 485a5418d287071076bbf3e23720f7f324b59071 Mon Sep 17 00:00:00 2001 From: Leonard Lyubich Date: Sat, 17 Sep 2022 16:37:01 +0400 Subject: [PATCH] [#1793] node: Serve `NetmapService.NetmapSnapshot` RPC There is no more need to serve the same request on Control API. Signed-off-by: Leonard Lyubich --- CHANGELOG.md | 5 + .../modules/morph/internal/types.pb.go | Bin 6465 -> 6465 bytes cmd/neofs-cli/internal/client/client.go | 23 +++++ cmd/neofs-cli/modules/control/root.go | 2 - cmd/neofs-cli/modules/control/snapshot.go | 74 -------------- cmd/neofs-cli/modules/netmap/root.go | 2 + cmd/neofs-cli/modules/netmap/snapshot.go | 63 ++++++++++++ cmd/neofs-node/config.go | 8 ++ cmd/neofs-node/netmap.go | 2 + go.mod | 4 +- go.sum | Bin 116646 -> 116646 bytes pkg/morph/client/netmap/netmap.go | 7 +- pkg/network/transport/netmap/grpc/service.go | 15 +++ pkg/services/control/convert.go | 20 ---- pkg/services/control/ir/service.pb.go | Bin 14528 -> 14529 bytes pkg/services/control/ir/service_grpc.pb.go | Bin 3853 -> 3854 bytes pkg/services/control/ir/types.pb.go | Bin 7733 -> 7734 bytes pkg/services/control/rpc.go | 23 ----- .../control/server/netmap_snapshot.go | 91 ------------------ pkg/services/control/service.go | 21 ---- pkg/services/control/service.pb.go | Bin 111461 -> 100929 bytes pkg/services/control/service.proto | 31 ------ pkg/services/control/service_grpc.pb.go | Bin 18306 -> 16645 bytes pkg/services/control/service_neofs.pb.go | Bin 52696 -> 47539 bytes pkg/services/control/service_test.go | 24 ----- pkg/services/control/types.pb.go | Bin 27108 -> 27109 bytes pkg/services/netmap/executor.go | 20 ++++ pkg/services/netmap/response.go | 13 +++ pkg/services/netmap/server.go | 1 + pkg/services/netmap/sign.go | 16 +++ pkg/services/tree/service.pb.go | Bin 99802 -> 99802 bytes pkg/services/tree/service_grpc.pb.go | Bin 15167 -> 15167 bytes pkg/services/tree/types.pb.go | Bin 9844 -> 9844 bytes 33 files changed, 176 insertions(+), 289 deletions(-) delete mode 100644 cmd/neofs-cli/modules/control/snapshot.go create mode 100644 cmd/neofs-cli/modules/netmap/snapshot.go delete mode 100644 pkg/services/control/server/netmap_snapshot.go diff --git a/CHANGELOG.md b/CHANGELOG.md index 0578b3097..502981d05 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,8 @@ Changelog for NeoFS Node ## [Unreleased] - Anmado (안마도, 鞍馬島) ### Added +- Serving `NetmapService.NetmapSnapshot` RPC (#1793) +- `netmap snapshot` command of NeoFS CLI (#1793) - Changelog updates CI step (#1808) - Validate storage node configuration before node startup (#1805) @@ -18,10 +20,13 @@ Changelog for NeoFS Node ### Removed - Remove WIF and NEP2 support in `neofs-cli`'s --wallet flag (#1128) - Remove --generate-key option in `neofs-cli container delete` (#1692) +- Serving `ControlService.NetmapSnapshot` RPC (#1793) +- `control netmap-snapshot` command of NeoFS CLI (#1793) ### Updated ### Updating from v0.32.0 +Replace using the `control netmap-snapshot` command with `netmap snapshot` one in NeoFS CLI. ## [0.32.0] - 2022-09-14 - Pungdo (풍도, 楓島) diff --git a/cmd/neofs-adm/internal/modules/morph/internal/types.pb.go b/cmd/neofs-adm/internal/modules/morph/internal/types.pb.go index ab8c5959a6404bc50cde6b38ad5f8a270b6c3611..26409987b9e6f3b89a51ab0a9a632942bcc85f23 100644 GIT binary patch delta 12 TcmX?TbkJx*0i)T*!V3}rBK-v@ delta 12 TcmX?TbkJx*0i)5z!V3}rBIyMr diff --git a/cmd/neofs-cli/internal/client/client.go b/cmd/neofs-cli/internal/client/client.go index c94856376..90056d9f5 100644 --- a/cmd/neofs-cli/internal/client/client.go +++ b/cmd/neofs-cli/internal/client/client.go @@ -272,6 +272,29 @@ func NodeInfo(prm NodeInfoPrm) (res NodeInfoRes, err error) { return } +// NetMapSnapshotPrm groups parameters of NetMapSnapshot operation. +type NetMapSnapshotPrm struct { + commonPrm +} + +// NetMapSnapshotRes groups the resulting values of NetMapSnapshot operation. +type NetMapSnapshotRes struct { + cliRes *client.ResNetMapSnapshot +} + +// NetMap returns current local snapshot of the NeoFS network map. +func (x NetMapSnapshotRes) NetMap() netmap.NetMap { + return x.cliRes.NetMap() +} + +// NetMapSnapshot requests current network view of the remote server. +// +// Returns any error which prevented the operation from completing correctly in error return. +func NetMapSnapshot(prm NetMapSnapshotPrm) (res NetMapSnapshotRes, err error) { + res.cliRes, err = prm.cli.NetMapSnapshot(context.Background(), client.PrmNetMapSnapshot{}) + return +} + // CreateSessionPrm groups parameters of CreateSession operation. type CreateSessionPrm struct { commonPrm diff --git a/cmd/neofs-cli/modules/control/root.go b/cmd/neofs-cli/modules/control/root.go index 31459d030..515b60cab 100644 --- a/cmd/neofs-cli/modules/control/root.go +++ b/cmd/neofs-cli/modules/control/root.go @@ -30,7 +30,6 @@ func init() { healthCheckCmd, setNetmapStatusCmd, dropObjectsCmd, - snapshotCmd, shardsCmd, synchronizeTreeCmd, ) @@ -38,7 +37,6 @@ func init() { initControlHealthCheckCmd() initControlSetNetmapStatusCmd() initControlDropObjectsCmd() - initControlSnapshotCmd() initControlShardsCmd() initControlSynchronizeTreeCmd() } diff --git a/cmd/neofs-cli/modules/control/snapshot.go b/cmd/neofs-cli/modules/control/snapshot.go deleted file mode 100644 index 49345d787..000000000 --- a/cmd/neofs-cli/modules/control/snapshot.go +++ /dev/null @@ -1,74 +0,0 @@ -package control - -import ( - "github.com/mr-tron/base58" - rawclient "github.com/nspcc-dev/neofs-api-go/v2/rpc/client" - "github.com/nspcc-dev/neofs-node/cmd/neofs-cli/internal/common" - "github.com/nspcc-dev/neofs-node/cmd/neofs-cli/internal/commonflags" - "github.com/nspcc-dev/neofs-node/cmd/neofs-cli/internal/key" - "github.com/nspcc-dev/neofs-node/pkg/services/control" - "github.com/spf13/cobra" -) - -const ( - netmapSnapshotJSONFlag = commonflags.JSON -) - -var snapshotCmd = &cobra.Command{ - Use: "netmap-snapshot", - Short: "Get network map snapshot", - Long: "Get network map snapshot", - Run: func(cmd *cobra.Command, args []string) { - pk := key.Get(cmd) - - req := new(control.NetmapSnapshotRequest) - req.SetBody(new(control.NetmapSnapshotRequest_Body)) - - signRequest(cmd, pk, req) - - cli := getClient(cmd, pk) - - var resp *control.NetmapSnapshotResponse - var err error - err = cli.ExecRaw(func(client *rawclient.Client) error { - resp, err = control.NetmapSnapshot(client, req) - return err - }) - common.ExitOnErr(cmd, "rpc error: %w", err) - - verifyResponse(cmd, resp.GetSignature(), resp.GetBody()) - - isJSON, _ := cmd.Flags().GetBool(netmapSnapshotJSONFlag) - prettyPrintNetmap(cmd, resp.GetBody().GetNetmap(), isJSON) - }, -} - -func initControlSnapshotCmd() { - commonflags.InitWithoutRPC(snapshotCmd) - - flags := snapshotCmd.Flags() - - flags.String(controlRPC, controlRPCDefault, controlRPCUsage) - flags.Bool(netmapSnapshotJSONFlag, false, "print netmap structure in JSON format") -} - -func prettyPrintNetmap(cmd *cobra.Command, nm *control.Netmap, jsonEncoding bool) { - if jsonEncoding { - common.PrettyPrintJSON(cmd, nm, "netmap") - return - } - - cmd.Println("Epoch:", nm.GetEpoch()) - - for i, node := range nm.GetNodes() { - cmd.Printf("Node %d: %s %s %v\n", i+1, - base58.Encode(node.GetPublicKey()), - node.GetState(), - node.GetAddresses(), - ) - - for _, attr := range node.GetAttributes() { - cmd.Printf("\t%s: %s\n", attr.GetKey(), attr.GetValue()) - } - } -} diff --git a/cmd/neofs-cli/modules/netmap/root.go b/cmd/neofs-cli/modules/netmap/root.go index 89e2e34d4..45a2075f0 100644 --- a/cmd/neofs-cli/modules/netmap/root.go +++ b/cmd/neofs-cli/modules/netmap/root.go @@ -22,9 +22,11 @@ func init() { getEpochCmd, nodeInfoCmd, netInfoCmd, + snapshotCmd, ) initGetEpochCmd() initNetInfoCmd() initNodeInfoCmd() + initSnapshotCmd() } diff --git a/cmd/neofs-cli/modules/netmap/snapshot.go b/cmd/neofs-cli/modules/netmap/snapshot.go new file mode 100644 index 000000000..bb4a6cd2b --- /dev/null +++ b/cmd/neofs-cli/modules/netmap/snapshot.go @@ -0,0 +1,63 @@ +package netmap + +import ( + "encoding/hex" + + internalclient "github.com/nspcc-dev/neofs-node/cmd/neofs-cli/internal/client" + "github.com/nspcc-dev/neofs-node/cmd/neofs-cli/internal/common" + "github.com/nspcc-dev/neofs-node/cmd/neofs-cli/internal/commonflags" + "github.com/nspcc-dev/neofs-node/cmd/neofs-cli/internal/key" + "github.com/nspcc-dev/neofs-sdk-go/netmap" + "github.com/spf13/cobra" +) + +var snapshotCmd = &cobra.Command{ + Use: "snapshot", + Short: "Request current local snapshot of the network map", + Long: `Request current local snapshot of the network map`, + Run: func(cmd *cobra.Command, args []string) { + p := key.GetOrGenerate(cmd) + cli := internalclient.GetSDKClientByFlag(cmd, p, commonflags.RPC) + + var prm internalclient.NetMapSnapshotPrm + prm.SetClient(cli) + + res, err := internalclient.NetMapSnapshot(prm) + common.ExitOnErr(cmd, "rpc error: %w", err) + + prettyPrintNetMap(cmd, res.NetMap()) + }, +} + +func initSnapshotCmd() { + commonflags.Init(snapshotCmd) + commonflags.InitAPI(snapshotCmd) +} + +func prettyPrintNetMap(cmd *cobra.Command, nm netmap.NetMap) { + cmd.Println("Epoch:", nm.Epoch()) + + nodes := nm.Nodes() + for i := range nodes { + var strState string + + switch { + case nodes[i].IsOnline(): + strState = "ONLINE" + case nodes[i].IsOffline(): + strState = "OFFLINE" + } + + cmd.Printf("Node %d: %s %s ", i+1, hex.EncodeToString(nodes[i].PublicKey()), strState) + + netmap.IterateNetworkEndpoints(nodes[i], func(endpoint string) { + cmd.Printf("%s ", endpoint) + }) + + cmd.Println() + + nodes[i].IterateAttributes(func(key, value string) { + cmd.Printf("\t%s: %s\n", key, value) + }) + } +} diff --git a/cmd/neofs-node/config.go b/cmd/neofs-node/config.go index da027bf5e..ac3ed7bd2 100644 --- a/cmd/neofs-node/config.go +++ b/cmd/neofs-node/config.go @@ -6,6 +6,7 @@ import ( "net" "path/filepath" "sync" + atomicstd "sync/atomic" "time" "github.com/nspcc-dev/neo-go/pkg/crypto/keys" @@ -134,6 +135,13 @@ type cfg struct { persistate *state.PersistentStorage netMapSource netmapCore.Source + + // current network map + netMap atomicstd.Value // type netmap.NetMap +} + +func (c *cfg) ProcessCurrentNetMap(f func(netmap.NetMap)) { + f(c.netMap.Load().(netmap.NetMap)) } type cfgGRPC struct { diff --git a/cmd/neofs-node/netmap.go b/cmd/neofs-node/netmap.go index 86dc397c7..1fd522c0f 100644 --- a/cmd/neofs-node/netmap.go +++ b/cmd/neofs-node/netmap.go @@ -286,6 +286,8 @@ func (c *cfg) netmapLocalNodeState(epoch uint64) (*netmapSDK.NodeInfo, error) { return nil, err } + c.netMap.Store(*nm) + nmNodes := nm.Nodes() for i := range nmNodes { if bytes.Equal(nmNodes[i].PublicKey(), c.binPublicKey) { diff --git a/go.mod b/go.mod index 1d0119e41..8357f6e74 100644 --- a/go.mod +++ b/go.mod @@ -17,9 +17,9 @@ require ( github.com/nspcc-dev/hrw v1.0.9 github.com/nspcc-dev/neo-go v0.99.2 github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220809123759-3094d3e0c14b // indirect - github.com/nspcc-dev/neofs-api-go/v2 v2.13.2-0.20220827080658-9e17cdfc7647 + github.com/nspcc-dev/neofs-api-go/v2 v2.13.2-0.20220919124434-cf868188ef9c github.com/nspcc-dev/neofs-contract v0.15.5 - github.com/nspcc-dev/neofs-sdk-go v1.0.0-rc.6.0.20220914073456-f75a5feba335 + github.com/nspcc-dev/neofs-sdk-go v1.0.0-rc.6.0.20220922065107-8e3173eacd23 github.com/nspcc-dev/tzhash v1.6.1 github.com/panjf2000/ants/v2 v2.4.0 github.com/paulmach/orb v0.2.2 diff --git a/go.sum b/go.sum index 54e5c031da5811818056f5420805fa4b93ed5880..f1475e838d0634c226c52900d2182e6dbcf9ca8c 100644 GIT binary patch delta 357 zcmZwBu};E3007V!2L~`}jBzj~4sHb6yDRP0O$x+=wh540%T}%}r4|ab2)OzI#N6g) zOh}B9AP#<>!sfsayuA5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)f+27X7|j$s z8%5IY`F*i)PGVr0dM8a`v{uaFMN-S>FBgp zc@s{%yv~-{kgee*gf)jOGSBCwugvD&Ba2Grv7rfbV2r%25!5~h9Hg2*bZ^J!fhp$J z+@upBD6Mc~a|K!sB}vw|ukyJZb{q{t=CaVvxlpRH%BSn1vYEW|u36kgM9+itzLep& z4~$40t(nKv-8+xp7rJh2%7;z}O*vj&H+D8!BS)OeDQ}kd#w0c$G7K^Z^PR37my2o_ zFl=Y$LvX*?;mUFLiA@V2=q9m45}Rqx0x%2_I~g}&>)W@W zb}oeu+ED=$=}@lyHrQ>wj-U+au~fcvU{RD)4Q7^-1n%L+J2Nj1`i_%()_E-mAU(`s3>xEfB=nw9dEzxYx`kJPZ4 z)>SNO+{`J~Udy*{)ycOa&!y>a(B*n|rF0>GXyKnmwA8V|sC#7zAACK0K$BMw#p;R8 zJaEq%DE35mFK?(d@#~z;btgiIK@Xy)xq7H!5{ced})-&xw~Z#i)m6dKiV|>mD}n~@TO>| s)I)(1b6tsqmo* zO=K6FTqEW_*_u0RvVbJ(<_Rpb*wEDwZ<>I-$m9ot+~@{0@Y|pZO%%@Cti>J3O+7y! z6cbiQ^;}SDVQFe{iKc=EdO!euy}3s0EGxRJNHIe|-Wx-^tlef$88!_6E9g&0SE^`L zgD%vsk&Z4jPrE_`)lVA9B^5dfMX7~)7@oRs9JtwEy;BU`kOg*1=t2$l%A0T4>M{cW DDuV9c diff --git a/pkg/services/control/service_neofs.pb.go b/pkg/services/control/service_neofs.pb.go index e5aa50fea5ac28ed81e5d339b5d65bf5ca307e6d..70616a79801049d18ce3b127dc869ea3212ce2dc 100644 GIT binary patch delta 18 acmcaHn|bqRrVWjvljU^9Ht*4tSpoo0+Xt}# delta 351 zcmdn|nd!!C<_(Rae154VxrqhAd5HzZ8TloXCx~ipeqcM15mQ`b@`hTu$qHuE(4;o6 zV-{mV7i*k01zl|N1=+i3$|eiU%0m}A&v^`8D9}@MvcJ3NWPxmTHi&aK8?a2laAKh6 zg2^BBt)NOKf8?EsX3*w?X5#3s+MKg>D!SO@bBpewX`SpKl8-Lr*MDM?g1}^bY1YX- U;=Ggp1u9Rz!6mZ!w&;z;0E8fmssI20 diff --git a/pkg/services/control/service_test.go b/pkg/services/control/service_test.go index 8dbfffa4d..b64e67d7b 100644 --- a/pkg/services/control/service_test.go +++ b/pkg/services/control/service_test.go @@ -33,30 +33,6 @@ func equalHealthCheckResponseBodies(b1, b2 *control.HealthCheckResponse_Body) bo b1.GetHealthStatus() == b2.GetHealthStatus() } -func TestNetmapSnapshotResponse_Body_StableMarshal(t *testing.T) { - testStableMarshal(t, - generateNetmapSnapshotResponseBody(), - new(control.NetmapSnapshotResponse_Body), - func(m1, m2 protoMessage) bool { - return equalNetmapSnapshotResponseBodies( - m1.(*control.NetmapSnapshotResponse_Body), - m2.(*control.NetmapSnapshotResponse_Body), - ) - }, - ) -} - -func generateNetmapSnapshotResponseBody() *control.NetmapSnapshotResponse_Body { - body := new(control.NetmapSnapshotResponse_Body) - body.SetNetmap(generateNetmap()) - - return body -} - -func equalNetmapSnapshotResponseBodies(b1, b2 *control.NetmapSnapshotResponse_Body) bool { - return equalNetmaps(b1.GetNetmap(), b2.GetNetmap()) -} - func TestSetNetmapStatusRequest_Body_StableMarshal(t *testing.T) { testStableMarshal(t, generateSetNetmapStatusRequestBody(), diff --git a/pkg/services/control/types.pb.go b/pkg/services/control/types.pb.go index b1962abce644bcca924c4c4abe6b1a204158c74a..4f95fa12ae37384f0212aa292d14c02e35e3ca28 100644 GIT binary patch delta 53 zcmaEInepjm#t8+CW)llN<%?3&a#E8^6qKM0B`(h5%DiL+B@n5^HE~Dv=3vH&82~j1 B6aWAK delta 24 gcmaEQneoYG#t8+CrV|T2C*H1{xKm+s2;;;I0F`YELjV8( diff --git a/pkg/services/netmap/executor.go b/pkg/services/netmap/executor.go index 797478090..c4453327f 100644 --- a/pkg/services/netmap/executor.go +++ b/pkg/services/netmap/executor.go @@ -26,6 +26,10 @@ type NodeState interface { // Must return current node state // in NeoFS API v2 NodeInfo structure. LocalNodeInfo() (*netmap.NodeInfo, error) + + // ProcessCurrentNetMap passes current local network map of the storage node + // into the given handler. + ProcessCurrentNetMap(func(netmapSDK.NetMap)) } // NetworkInfo encapsulates source of the @@ -123,3 +127,19 @@ func (s *executorSvc) NetworkInfo( return resp, nil } + +func (s *executorSvc) Snapshot(_ context.Context, req *netmap.SnapshotRequest) (*netmap.SnapshotResponse, error) { + var nmV2 netmap.NetMap + + s.state.ProcessCurrentNetMap(func(netMap netmapSDK.NetMap) { + netMap.WriteToV2(&nmV2) + }) + + body := new(netmap.SnapshotResponseBody) + body.SetNetMap(&nmV2) + + resp := new(netmap.SnapshotResponse) + resp.SetBody(body) + + return resp, nil +} diff --git a/pkg/services/netmap/response.go b/pkg/services/netmap/response.go index 81d9f52a3..c0e81b7c7 100644 --- a/pkg/services/netmap/response.go +++ b/pkg/services/netmap/response.go @@ -48,3 +48,16 @@ func (s *responseService) NetworkInfo(ctx context.Context, req *netmap.NetworkIn return resp.(*netmap.NetworkInfoResponse), nil } + +func (s *responseService) Snapshot(ctx context.Context, req *netmap.SnapshotRequest) (*netmap.SnapshotResponse, error) { + resp, err := s.respSvc.HandleUnaryRequest(ctx, req, + func(ctx context.Context, req interface{}) (util.ResponseMessage, error) { + return s.svc.Snapshot(ctx, req.(*netmap.SnapshotRequest)) + }, + ) + if err != nil { + return nil, err + } + + return resp.(*netmap.SnapshotResponse), nil +} diff --git a/pkg/services/netmap/server.go b/pkg/services/netmap/server.go index 359d2ac90..cbd668396 100644 --- a/pkg/services/netmap/server.go +++ b/pkg/services/netmap/server.go @@ -10,4 +10,5 @@ import ( type Server interface { LocalNodeInfo(context.Context, *netmap.LocalNodeInfoRequest) (*netmap.LocalNodeInfoResponse, error) NetworkInfo(context.Context, *netmap.NetworkInfoRequest) (*netmap.NetworkInfoResponse, error) + Snapshot(context.Context, *netmap.SnapshotRequest) (*netmap.SnapshotResponse, error) } diff --git a/pkg/services/netmap/sign.go b/pkg/services/netmap/sign.go index 13473c441..73df0528d 100644 --- a/pkg/services/netmap/sign.go +++ b/pkg/services/netmap/sign.go @@ -54,3 +54,19 @@ func (s *signService) NetworkInfo(ctx context.Context, req *netmap.NetworkInfoRe return resp.(*netmap.NetworkInfoResponse), nil } + +func (s *signService) Snapshot(ctx context.Context, req *netmap.SnapshotRequest) (*netmap.SnapshotResponse, error) { + resp, err := s.sigSvc.HandleUnaryRequest(ctx, req, + func(ctx context.Context, req interface{}) (util.ResponseMessage, error) { + return s.svc.Snapshot(ctx, req.(*netmap.SnapshotRequest)) + }, + func() util.ResponseMessage { + return new(netmap.SnapshotResponse) + }, + ) + if err != nil { + return nil, err + } + + return resp.(*netmap.SnapshotResponse), nil +} diff --git a/pkg/services/tree/service.pb.go b/pkg/services/tree/service.pb.go index 3beaf2c9d1a27a9e6e7573fa8b95b5656cfe16b7..2d30dce79d333809016de7a60413f11948ff8500 100644 GIT binary patch delta 17 ZcmccB&33DsZNeNzv&Okw=Q7&10su!12WMlE6%6_04s