[#1917] neofs-cli: Support timeout in control
commands
Signed-off-by: Evgenii Stratonikov <evgeniy@morphbits.ru>
This commit is contained in:
parent
4c63be6629
commit
0a1530afa0
13 changed files with 22 additions and 34 deletions
|
@ -4,6 +4,8 @@ Changelog for NeoFS Node
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
- `--timeout` flag in `neofs-cli control` commands (#1917)
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
### Fixed
|
### Fixed
|
||||||
### Removed
|
### Removed
|
||||||
|
|
|
@ -3,7 +3,6 @@ package control
|
||||||
import (
|
import (
|
||||||
rawclient "github.com/nspcc-dev/neofs-api-go/v2/rpc/client"
|
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/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/cmd/neofs-cli/internal/key"
|
||||||
"github.com/nspcc-dev/neofs-node/pkg/services/control"
|
"github.com/nspcc-dev/neofs-node/pkg/services/control"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
@ -50,11 +49,9 @@ var dropObjectsCmd = &cobra.Command{
|
||||||
}
|
}
|
||||||
|
|
||||||
func initControlDropObjectsCmd() {
|
func initControlDropObjectsCmd() {
|
||||||
commonflags.InitWithoutRPC(dropObjectsCmd)
|
initControlFlags(dropObjectsCmd)
|
||||||
|
|
||||||
flags := dropObjectsCmd.Flags()
|
flags := dropObjectsCmd.Flags()
|
||||||
|
|
||||||
flags.String(controlRPC, controlRPCDefault, controlRPCUsage)
|
|
||||||
flags.StringSliceP(dropObjectsFlag, "o", nil,
|
flags.StringSliceP(dropObjectsFlag, "o", nil,
|
||||||
"List of object addresses to be removed in string format")
|
"List of object addresses to be removed in string format")
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,6 @@ package control
|
||||||
import (
|
import (
|
||||||
"github.com/nspcc-dev/neofs-api-go/v2/rpc/client"
|
"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/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/cmd/neofs-cli/internal/key"
|
||||||
"github.com/nspcc-dev/neofs-node/pkg/services/control"
|
"github.com/nspcc-dev/neofs-node/pkg/services/control"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
@ -43,10 +42,9 @@ func evacuateShard(cmd *cobra.Command, _ []string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func initControlEvacuateShardCmd() {
|
func initControlEvacuateShardCmd() {
|
||||||
commonflags.InitWithoutRPC(evacuateShardCmd)
|
initControlFlags(evacuateShardCmd)
|
||||||
|
|
||||||
flags := evacuateShardCmd.Flags()
|
flags := evacuateShardCmd.Flags()
|
||||||
flags.String(controlRPC, controlRPCDefault, controlRPCUsage)
|
|
||||||
flags.StringSlice(shardIDFlag, nil, "List of shard IDs in base58 encoding")
|
flags.StringSlice(shardIDFlag, nil, "List of shard IDs in base58 encoding")
|
||||||
flags.Bool(shardAllFlag, false, "Process all shards")
|
flags.Bool(shardAllFlag, false, "Process all shards")
|
||||||
flags.Bool(dumpIgnoreErrorsFlag, false, "Skip invalid/unreadable objects")
|
flags.Bool(dumpIgnoreErrorsFlag, false, "Skip invalid/unreadable objects")
|
||||||
|
|
|
@ -3,7 +3,6 @@ package control
|
||||||
import (
|
import (
|
||||||
"github.com/nspcc-dev/neofs-api-go/v2/rpc/client"
|
"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/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/cmd/neofs-cli/internal/key"
|
||||||
"github.com/nspcc-dev/neofs-node/pkg/services/control"
|
"github.com/nspcc-dev/neofs-node/pkg/services/control"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
@ -40,10 +39,9 @@ func flushCache(cmd *cobra.Command, _ []string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func initControlFlushCacheCmd() {
|
func initControlFlushCacheCmd() {
|
||||||
commonflags.InitWithoutRPC(flushCacheCmd)
|
initControlFlags(flushCacheCmd)
|
||||||
|
|
||||||
ff := flushCacheCmd.Flags()
|
ff := flushCacheCmd.Flags()
|
||||||
ff.String(controlRPC, controlRPCDefault, controlRPCUsage)
|
|
||||||
ff.StringSlice(shardIDFlag, nil, "List of shard IDs in base58 encoding")
|
ff.StringSlice(shardIDFlag, nil, "List of shard IDs in base58 encoding")
|
||||||
ff.Bool(shardAllFlag, false, "Process all shards")
|
ff.Bool(shardAllFlag, false, "Process all shards")
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,6 @@ import (
|
||||||
|
|
||||||
rawclient "github.com/nspcc-dev/neofs-api-go/v2/rpc/client"
|
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/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/cmd/neofs-cli/internal/key"
|
||||||
"github.com/nspcc-dev/neofs-node/pkg/services/control"
|
"github.com/nspcc-dev/neofs-node/pkg/services/control"
|
||||||
ircontrol "github.com/nspcc-dev/neofs-node/pkg/services/control/ir"
|
ircontrol "github.com/nspcc-dev/neofs-node/pkg/services/control/ir"
|
||||||
|
@ -26,11 +25,9 @@ var healthCheckCmd = &cobra.Command{
|
||||||
}
|
}
|
||||||
|
|
||||||
func initControlHealthCheckCmd() {
|
func initControlHealthCheckCmd() {
|
||||||
commonflags.InitWithoutRPC(healthCheckCmd)
|
initControlFlags(healthCheckCmd)
|
||||||
|
|
||||||
flags := healthCheckCmd.Flags()
|
flags := healthCheckCmd.Flags()
|
||||||
|
|
||||||
flags.String(controlRPC, controlRPCDefault, controlRPCUsage)
|
|
||||||
flags.Bool(healthcheckIRFlag, false, "Communicate with IR node")
|
flags.Bool(healthcheckIRFlag, false, "Communicate with IR node")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,7 @@ var Cmd = &cobra.Command{
|
||||||
_ = viper.BindPFlag(commonflags.WalletPath, ff.Lookup(commonflags.WalletPath))
|
_ = viper.BindPFlag(commonflags.WalletPath, ff.Lookup(commonflags.WalletPath))
|
||||||
_ = viper.BindPFlag(commonflags.Account, ff.Lookup(commonflags.Account))
|
_ = viper.BindPFlag(commonflags.Account, ff.Lookup(commonflags.Account))
|
||||||
_ = viper.BindPFlag(controlRPC, ff.Lookup(controlRPC))
|
_ = viper.BindPFlag(controlRPC, ff.Lookup(controlRPC))
|
||||||
|
_ = viper.BindPFlag(commonflags.Timeout, ff.Lookup(commonflags.Timeout))
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,6 @@ import (
|
||||||
|
|
||||||
rawclient "github.com/nspcc-dev/neofs-api-go/v2/rpc/client"
|
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/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/cmd/neofs-cli/internal/key"
|
||||||
"github.com/nspcc-dev/neofs-node/pkg/services/control"
|
"github.com/nspcc-dev/neofs-node/pkg/services/control"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
@ -27,11 +26,9 @@ var setNetmapStatusCmd = &cobra.Command{
|
||||||
}
|
}
|
||||||
|
|
||||||
func initControlSetNetmapStatusCmd() {
|
func initControlSetNetmapStatusCmd() {
|
||||||
commonflags.InitWithoutRPC(setNetmapStatusCmd)
|
initControlFlags(setNetmapStatusCmd)
|
||||||
|
|
||||||
flags := setNetmapStatusCmd.Flags()
|
flags := setNetmapStatusCmd.Flags()
|
||||||
|
|
||||||
flags.String(controlRPC, controlRPCDefault, controlRPCUsage)
|
|
||||||
flags.String(netmapStatusFlag, "",
|
flags.String(netmapStatusFlag, "",
|
||||||
fmt.Sprintf("New netmap status keyword ('%s', '%s', '%s')",
|
fmt.Sprintf("New netmap status keyword ('%s', '%s', '%s')",
|
||||||
netmapStatusOnline,
|
netmapStatusOnline,
|
||||||
|
|
|
@ -3,7 +3,6 @@ package control
|
||||||
import (
|
import (
|
||||||
"github.com/nspcc-dev/neofs-api-go/v2/rpc/client"
|
"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/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/cmd/neofs-cli/internal/key"
|
||||||
"github.com/nspcc-dev/neofs-node/pkg/services/control"
|
"github.com/nspcc-dev/neofs-node/pkg/services/control"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
@ -54,10 +53,9 @@ func dumpShard(cmd *cobra.Command, _ []string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func initControlDumpShardCmd() {
|
func initControlDumpShardCmd() {
|
||||||
commonflags.InitWithoutRPC(dumpShardCmd)
|
initControlFlags(dumpShardCmd)
|
||||||
|
|
||||||
flags := dumpShardCmd.Flags()
|
flags := dumpShardCmd.Flags()
|
||||||
flags.String(controlRPC, controlRPCDefault, controlRPCUsage)
|
|
||||||
flags.String(shardIDFlag, "", "Shard ID in base58 encoding")
|
flags.String(shardIDFlag, "", "Shard ID in base58 encoding")
|
||||||
flags.String(dumpFilepathFlag, "", "File to write objects to")
|
flags.String(dumpFilepathFlag, "", "File to write objects to")
|
||||||
flags.Bool(dumpIgnoreErrorsFlag, false, "Skip invalid/unreadable objects")
|
flags.Bool(dumpIgnoreErrorsFlag, false, "Skip invalid/unreadable objects")
|
||||||
|
|
|
@ -23,11 +23,9 @@ var listShardsCmd = &cobra.Command{
|
||||||
}
|
}
|
||||||
|
|
||||||
func initControlShardsListCmd() {
|
func initControlShardsListCmd() {
|
||||||
commonflags.InitWithoutRPC(listShardsCmd)
|
initControlFlags(listShardsCmd)
|
||||||
|
|
||||||
flags := listShardsCmd.Flags()
|
flags := listShardsCmd.Flags()
|
||||||
|
|
||||||
flags.String(controlRPC, controlRPCDefault, controlRPCUsage)
|
|
||||||
flags.Bool(commonflags.JSON, false, "Print shard info as a JSON array")
|
flags.Bool(commonflags.JSON, false, "Print shard info as a JSON array")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,6 @@ package control
|
||||||
import (
|
import (
|
||||||
"github.com/nspcc-dev/neofs-api-go/v2/rpc/client"
|
"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/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/cmd/neofs-cli/internal/key"
|
||||||
"github.com/nspcc-dev/neofs-node/pkg/services/control"
|
"github.com/nspcc-dev/neofs-node/pkg/services/control"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
@ -54,10 +53,9 @@ func restoreShard(cmd *cobra.Command, _ []string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func initControlRestoreShardCmd() {
|
func initControlRestoreShardCmd() {
|
||||||
commonflags.InitWithoutRPC(restoreShardCmd)
|
initControlFlags(restoreShardCmd)
|
||||||
|
|
||||||
flags := restoreShardCmd.Flags()
|
flags := restoreShardCmd.Flags()
|
||||||
flags.String(controlRPC, controlRPCDefault, controlRPCUsage)
|
|
||||||
flags.String(shardIDFlag, "", "Shard ID in base58 encoding")
|
flags.String(shardIDFlag, "", "Shard ID in base58 encoding")
|
||||||
flags.String(restoreFilepathFlag, "", "File to read objects from")
|
flags.String(restoreFilepathFlag, "", "File to read objects from")
|
||||||
flags.Bool(restoreIgnoreErrorsFlag, false, "Skip invalid/unreadable objects")
|
flags.Bool(restoreIgnoreErrorsFlag, false, "Skip invalid/unreadable objects")
|
||||||
|
|
|
@ -6,7 +6,6 @@ import (
|
||||||
"github.com/mr-tron/base58"
|
"github.com/mr-tron/base58"
|
||||||
rawclient "github.com/nspcc-dev/neofs-api-go/v2/rpc/client"
|
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/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/cmd/neofs-cli/internal/key"
|
||||||
"github.com/nspcc-dev/neofs-node/pkg/services/control"
|
"github.com/nspcc-dev/neofs-node/pkg/services/control"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
@ -32,11 +31,9 @@ var setShardModeCmd = &cobra.Command{
|
||||||
}
|
}
|
||||||
|
|
||||||
func initControlSetShardModeCmd() {
|
func initControlSetShardModeCmd() {
|
||||||
commonflags.InitWithoutRPC(setShardModeCmd)
|
initControlFlags(setShardModeCmd)
|
||||||
|
|
||||||
flags := setShardModeCmd.Flags()
|
flags := setShardModeCmd.Flags()
|
||||||
|
|
||||||
flags.String(controlRPC, controlRPCDefault, controlRPCUsage)
|
|
||||||
flags.StringSlice(shardIDFlag, nil, "List of shard IDs in base58 encoding")
|
flags.StringSlice(shardIDFlag, nil, "List of shard IDs in base58 encoding")
|
||||||
flags.Bool(shardAllFlag, false, "Process all shards")
|
flags.Bool(shardAllFlag, false, "Process all shards")
|
||||||
flags.String(shardModeFlag, "",
|
flags.String(shardModeFlag, "",
|
||||||
|
|
|
@ -6,7 +6,6 @@ import (
|
||||||
|
|
||||||
rawclient "github.com/nspcc-dev/neofs-api-go/v2/rpc/client"
|
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/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/cmd/neofs-cli/internal/key"
|
||||||
"github.com/nspcc-dev/neofs-node/pkg/services/control"
|
"github.com/nspcc-dev/neofs-node/pkg/services/control"
|
||||||
controlSvc "github.com/nspcc-dev/neofs-node/pkg/services/control/server"
|
controlSvc "github.com/nspcc-dev/neofs-node/pkg/services/control/server"
|
||||||
|
@ -27,10 +26,9 @@ var synchronizeTreeCmd = &cobra.Command{
|
||||||
}
|
}
|
||||||
|
|
||||||
func initControlSynchronizeTreeCmd() {
|
func initControlSynchronizeTreeCmd() {
|
||||||
commonflags.InitWithoutRPC(synchronizeTreeCmd)
|
initControlFlags(synchronizeTreeCmd)
|
||||||
|
|
||||||
flags := synchronizeTreeCmd.Flags()
|
flags := synchronizeTreeCmd.Flags()
|
||||||
flags.String(controlRPC, controlRPCDefault, controlRPCUsage)
|
|
||||||
flags.String("cid", "", "Container ID")
|
flags.String("cid", "", "Container ID")
|
||||||
flags.String(synchronizeTreeIDFlag, "", "Tree ID")
|
flags.String(synchronizeTreeIDFlag, "", "Tree ID")
|
||||||
flags.Uint64(synchronizeTreeHeightFlag, 0, "Starting height")
|
flags.Uint64(synchronizeTreeHeightFlag, 0, "Starting height")
|
||||||
|
|
|
@ -7,12 +7,21 @@ import (
|
||||||
"github.com/nspcc-dev/neofs-api-go/v2/refs"
|
"github.com/nspcc-dev/neofs-api-go/v2/refs"
|
||||||
internalclient "github.com/nspcc-dev/neofs-node/cmd/neofs-cli/internal/client"
|
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/common"
|
||||||
|
"github.com/nspcc-dev/neofs-node/cmd/neofs-cli/internal/commonflags"
|
||||||
controlSvc "github.com/nspcc-dev/neofs-node/pkg/services/control/server"
|
controlSvc "github.com/nspcc-dev/neofs-node/pkg/services/control/server"
|
||||||
"github.com/nspcc-dev/neofs-sdk-go/client"
|
"github.com/nspcc-dev/neofs-sdk-go/client"
|
||||||
neofscrypto "github.com/nspcc-dev/neofs-sdk-go/crypto"
|
neofscrypto "github.com/nspcc-dev/neofs-sdk-go/crypto"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func initControlFlags(cmd *cobra.Command) {
|
||||||
|
commonflags.InitWithoutRPC(cmd)
|
||||||
|
|
||||||
|
ff := cmd.Flags()
|
||||||
|
ff.String(controlRPC, controlRPCDefault, controlRPCUsage)
|
||||||
|
ff.DurationP(commonflags.Timeout, commonflags.TimeoutShorthand, commonflags.TimeoutDefault, commonflags.TimeoutUsage)
|
||||||
|
}
|
||||||
|
|
||||||
func signRequest(cmd *cobra.Command, pk *ecdsa.PrivateKey, req controlSvc.SignedMessage) {
|
func signRequest(cmd *cobra.Command, pk *ecdsa.PrivateKey, req controlSvc.SignedMessage) {
|
||||||
err := controlSvc.SignMessage(pk, req)
|
err := controlSvc.SignMessage(pk, req)
|
||||||
common.ExitOnErr(cmd, "could not sign request: %w", err)
|
common.ExitOnErr(cmd, "could not sign request: %w", err)
|
||||||
|
|
Loading…
Reference in a new issue