morph: Iterate over endpoints when create ws client in constructor #307
No reviewers
Labels
No labels
P0
P1
P2
P3
badger
frostfs-adm
frostfs-cli
frostfs-ir
frostfs-lens
frostfs-node
good first issue
triage
Infrastructure
blocked
bug
config
discussion
documentation
duplicate
enhancement
go
help wanted
internal
invalid
kludge
observability
perfomance
question
refactoring
wontfix
No milestone
No project
No assignees
3 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: TrueCloudLab/frostfs-node#307
Loading…
Add table
Reference in a new issue
No description provided.
Delete branch "acid-ant/frostfs-node:bugfix/304-morph-client"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Close #304
Signed-off-by: Anton Nikiforov an.nikiforov@yadro.com
@ -141,2 +140,2 @@
if err != nil {
return nil, fmt.Errorf("could not create RPC client: %w", err)
for cli.endpoints.curr = range cli.endpoints.list {
cli.client, act, err = cli.newCli(ctx, cli.endpoints.list[cli.endpoints.curr].Address)
Can we log errors here? And then print which endpoint was chosen (IMO in INFO level).
Please review, in previous version also forgot to exit from loop on success.
morph: Iterate over endpoints when create ws client in constructorto WIP: morph: Iterate over endpoints when create ws client in constructor1282c0101d
to5557b4f39d
WIP: morph: Iterate over endpoints when create ws client in constructorto morph: Iterate over endpoints when create ws client in constructor@ -143,0 +142,4 @@
cli.client, act, err = cli.newCli(ctx, endpoint.Address)
if err != nil {
err = fmt.Errorf("could not create RPC client for endpoint %s: %w", endpoint.Address, err)
cli.logger.Debug(err.Error())
We usually log the message and use
zap.Error
, why have you decided toDebug(err.Error())
Because in this case, error already contains context. Also, to avoid duplication, cause in the worth case we need to return error.
Updated, please review.
@ -143,0 +143,4 @@
if err != nil {
err = fmt.Errorf("could not create RPC client for endpoint %s: %w", endpoint.Address, err)
cli.logger.Debug(err.Error())
if cli.endpoints.curr == len(cli.endpoints.list)-1 {
Can we move this line out of the loop?
The error could be defined separately -- it is not the last, but e.g.
ErrNoHealthyEndpoint
Nice suggestion, will implement it.
Updated, please review.
@ -143,0 +147,4 @@
return nil, err
}
} else {
cli.logger.Info(fmt.Sprintf("created RPC client for endpoint %s", endpoint.Address))
Again, what about
zap.String("endpoint", endpoint.Address)
?Sorry, flashbacks from java :)
Updated, please review.
5557b4f39d
to06112d683f
@ -53,2 +53,4 @@
)
var (
ErrNoHealthyEndpoint = errors.New("no healthy endpoint")
Does linter say nothing here?
Maybe add some comment to public errors.
Nothing, didn't disable anything related to pre-commit check.
Add more info about ErrNoHealthyEndpoint in help for New(...)
@ -143,0 +145,4 @@
for cli.endpoints.curr, endpoint = range cli.endpoints.list {
cli.client, act, err = cli.newCli(ctx, endpoint.Address)
if err != nil {
cli.logger.Debug("could not create RPC client for endpoint",
Use constant from
internal/logs
?Done
06112d683f
to53abcf25e2
53abcf25e2
tod2f99c4caa
d2f99c4caa
to2633bbe13e
@ -143,0 +148,4 @@
for cli.endpoints.curr, endpoint = range cli.endpoints.list {
cli.client, act, err = cli.newCli(ctx, endpoint.Address)
if err != nil {
cli.logger.Debug(logs.FrostFSIRCouldntCreateRPCClientForEndpoint,
Maybe Warn, not Debug?
Why not, updated.
2633bbe13e
to160bf151e5
Please, resolve conflicts
160bf151e5
tocedd07bbc8