frostfs-cli: Allow to use external addresses first for object nodes #1282

Merged
fyrchik merged 1 commit from dstepanov-yadro/frostfs-node:fix/object_nodes_external_priority into master 2024-08-01 06:17:41 +00:00

View file

@ -30,7 +30,8 @@ import (
)
const (
verifyPresenceAllFlag = "verify-presence-all"
verifyPresenceAllFlag = "verify-presence-all"
preferInternalAddressesFlag = "prefer-internal-addresses"

This should be the default, as object nodes is a client command and external addresses are exactly to be used by client.
I don't think we ever need to change this behaviour, it seems like a kludge.

This should be the default, as `object nodes` is a client command and external addresses are exactly to be used by client. I don't think we ever need to change this behaviour, it seems like a kludge.

I discussed this with QA. The command is most often run manually from a node and should prefer internal addresses, but external addresses are needed to run autotests from another node.

I discussed this with QA. The command is most often run manually from a node and should prefer internal addresses, but external addresses are needed to run autotests from another node.

I would like the interface of our CLI to NOT be shaped by the volatile desires of our QA team.

I would like the interface of our CLI to NOT be shaped by the volatile desires of our QA team.

Ok, flag changed

Ok, flag changed
)
var (
@ -97,6 +98,7 @@ func initObjectNodesCmd() {
flags.Bool(verifyPresenceAllFlag, false, "Verify the actual presence of the object on all netmap nodes.")
flags.Bool(commonflags.JSON, false, "Print information about the object placement as json.")
flags.Bool(preferInternalAddressesFlag, false, "Use internal addresses first to get object info.")
}
func objectNodes(cmd *cobra.Command, _ []string) {
@ -449,11 +451,20 @@ func getNodesToCheckObjectExistance(cmd *cobra.Command, netmap *netmapSDK.NetMap
func createClient(ctx context.Context, cmd *cobra.Command, candidate netmapSDK.NodeInfo, pk *ecdsa.PrivateKey) (*client.Client, error) {
var cli *client.Client
var addresses []string
candidate.IterateNetworkEndpoints(func(s string) bool {
addresses = append(addresses, s)
return false
})
addresses = append(addresses, candidate.ExternalAddresses()...)
if preferInternal, _ := cmd.Flags().GetBool(preferInternalAddressesFlag); preferInternal {
candidate.IterateNetworkEndpoints(func(s string) bool {
addresses = append(addresses, s)
return false
})
addresses = append(addresses, candidate.ExternalAddresses()...)
} else {
addresses = append(addresses, candidate.ExternalAddresses()...)
candidate.IterateNetworkEndpoints(func(s string) bool {
addresses = append(addresses, s)
return false
})
}
var lastErr error
for _, address := range addresses {
var networkAddr network.Address