set service-ip-repair-controller wait time match with etcd dial timeout

This commit is contained in:
古九 2024-08-14 09:59:59 +08:00 committed by gujiu.fsd
parent 9d140b136c
commit fc07c23b73
2 changed files with 12 additions and 8 deletions

View File

@ -156,13 +156,14 @@ func (c *Repair) doRunOnce() error {
snapshotByFamily := make(map[v1.IPFamily]*api.RangeAllocation)
storedByFamily := make(map[v1.IPFamily]ipallocator.Interface)
err := wait.PollImmediate(time.Second, 10*time.Second, func() (bool, error) {
err := wait.PollUntilContextTimeout(context.Background(), time.Second, 30*time.Second, true, func(ctx context.Context) (bool, error) {
for family, allocator := range c.allocatorByFamily {
// get snapshot if it is not there
if _, ok := snapshotByFamily[family]; !ok {
snapshot, err := allocator.Get()
if err != nil {
return false, err
runtime.HandleError(fmt.Errorf("unable to refresh the service IP block: %w", err))
return false, nil
}
snapshotByFamily[family] = snapshot
@ -172,7 +173,7 @@ func (c *Repair) doRunOnce() error {
})
if err != nil {
return fmt.Errorf("unable to refresh the service IP block: %v", err)
return fmt.Errorf("unable to refresh the service IP block: %w", err)
}
// ensure that ranges are assigned

View File

@ -112,14 +112,17 @@ func (c *Repair) doRunOnce() error {
// If etcd server is not running we should wait for some time and fail only then. This is particularly
// important when we start apiserver and etcd at the same time.
var snapshot *api.RangeAllocation
err := wait.PollImmediate(time.Second, 10*time.Second, func() (bool, error) {
var err error
var err error
err = wait.PollUntilContextTimeout(context.Background(), time.Second, 30*time.Second, true, func(ctx context.Context) (bool, error) {
snapshot, err = c.alloc.Get()
return err == nil, err
if err != nil {
runtime.HandleError(fmt.Errorf("unable to refresh the port allocations: %w", err))
return false, nil
}
return true, nil
})
if err != nil {
return fmt.Errorf("unable to refresh the port allocations: %v", err)
return fmt.Errorf("unable to refresh the port allocations: %w", err)
}
// If not yet initialized.
if snapshot.Range == "" {