Skip to content

Commit

Permalink
use backoff instead of retry
Browse files Browse the repository at this point in the history
  • Loading branch information
Eslam-Nawara committed Nov 3, 2024
1 parent 63fd3d3 commit 14eb85e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
1 change: 0 additions & 1 deletion go.work.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1015,7 +1015,6 @@ github.com/tyler-smith/go-bip39 v1.1.0/go.mod h1:gUYDtqQw1JS3ZJ8UWVcGTGqqr6YIN3C
github.com/ulikunitz/xz v0.5.8/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14=
github.com/ultradns/ultradns-go-sdk v1.6.1-20231103022937-8589b6a/go.mod h1:Xwz7o+ExFtxR/i0aJDnTXuiccQJlOxDgNe6FsZC4TzQ=
github.com/urfave/cli/v2 v2.27.1/go.mod h1:8qnjx1vcq5s2/wpsqoZFndg2CE5tNFyrTvS6SinrnYQ=
github.com/vedhavyas/go-subkey/v2 v2.0.0/go.mod h1:95aZ+XDCWAUUynjlmi7BtPExjXgXxByE0WfBwbmIRH4=
github.com/vinyldns/go-vinyldns v0.9.16/go.mod h1:5qIJOdmzAnatKjurI+Tl4uTus7GJKJxb+zitufjHs3Q=
github.com/vishvananda/netlink v1.1.1-0.20201029203352-d40f9887b852/go.mod h1:twkDnbuQxJYemMlGd4JFIcuhgX83tXhKS2B/PRMpOho=
github.com/vishvananda/netns v0.0.0-20210104183010-2eb08e3e575f/go.mod h1:DD4vA1DwXk04H54A1oHXtwZmA0grkVMdPxx/VGLCah0=
Expand Down
6 changes: 3 additions & 3 deletions grid-client/deployer/deployment_deployer.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ import (
"sync"
"time"

"github.com/cenkalti/backoff/v4"
"github.com/hashicorp/go-multierror"
"github.com/pkg/errors"
"github.com/rs/zerolog/log"
"github.com/sethvargo/go-retry"
"github.com/threefoldtech/tfgrid-sdk-go/grid-client/workloads"
"github.com/threefoldtech/tfgrid-sdk-go/grid-client/zos"
)
Expand Down Expand Up @@ -278,7 +278,7 @@ func (d *DeploymentDeployer) calculateNetworksUsedIPs(ctx context.Context, dls [
wg.Add(1)
go func(dl *workloads.Deployment) {
defer wg.Done()
check := func(context.Context) error {
check := func() error {
usedHostIDs, err := d.getUsedHostIDsOfNodeWithinNetwork(ctx, dl.NodeID, dl.NetworkName)
if err != nil {
err = errors.Wrapf(err, "failed to get used host ids for network %s node %d", dl.NetworkName, dl.NodeID)
Expand All @@ -290,7 +290,7 @@ func (d *DeploymentDeployer) calculateNetworksUsedIPs(ctx context.Context, dls [
usedHosts[dl.NetworkName][dl.NodeID] = append(usedHosts[dl.NetworkName][dl.NodeID], usedHostIDs...)
return nil
}
if err := retry.Do(ctx, retry.WithMaxRetries(5, retry.NewConstant(1*time.Nanosecond)), check); err != nil {
if err := backoff.Retry(check, backoff.WithMaxRetries(backoff.NewConstantBackOff(1*time.Nanosecond), 5)); err != nil {
mu.Lock()
defer mu.Unlock()
errs = multierror.Append(errs, err)
Expand Down

0 comments on commit 14eb85e

Please sign in to comment.