mirror of
https://github.com/kubernetes-sigs/external-dns.git
synced 2025-08-07 10:06:57 +02:00
Merge pull request #2609 from claudiumocanu/fix-reconcile-blocker
Do not reschedule, if already scheduled in the next MinInterval
This commit is contained in:
commit
03e3d22298
@ -268,8 +268,12 @@ func filterARecords(endpoints []*endpoint.Endpoint) []string {
|
|||||||
func (c *Controller) ScheduleRunOnce(now time.Time) {
|
func (c *Controller) ScheduleRunOnce(now time.Time) {
|
||||||
c.nextRunAtMux.Lock()
|
c.nextRunAtMux.Lock()
|
||||||
defer c.nextRunAtMux.Unlock()
|
defer c.nextRunAtMux.Unlock()
|
||||||
|
// schedule only if a reconciliation is not already planned
|
||||||
|
// to happen in the following c.MinEventSyncInterval
|
||||||
|
if !c.nextRunAt.Before(now.Add(c.MinEventSyncInterval)) {
|
||||||
c.nextRunAt = now.Add(c.MinEventSyncInterval)
|
c.nextRunAt = now.Add(c.MinEventSyncInterval)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (c *Controller) ShouldRunOnce(now time.Time) bool {
|
func (c *Controller) ShouldRunOnce(now time.Time) bool {
|
||||||
c.nextRunAtMux.Lock()
|
c.nextRunAtMux.Lock()
|
||||||
|
@ -19,12 +19,13 @@ package controller
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
"github.com/prometheus/client_golang/prometheus"
|
|
||||||
"math"
|
"math"
|
||||||
"reflect"
|
"reflect"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
|
|
||||||
"sigs.k8s.io/external-dns/endpoint"
|
"sigs.k8s.io/external-dns/endpoint"
|
||||||
"sigs.k8s.io/external-dns/internal/testutils"
|
"sigs.k8s.io/external-dns/internal/testutils"
|
||||||
"sigs.k8s.io/external-dns/pkg/apis/externaldns"
|
"sigs.k8s.io/external-dns/pkg/apis/externaldns"
|
||||||
@ -236,6 +237,17 @@ func TestShouldRunOnce(t *testing.T) {
|
|||||||
|
|
||||||
// But not two times
|
// But not two times
|
||||||
assert.False(t, ctrl.ShouldRunOnce(now))
|
assert.False(t, ctrl.ShouldRunOnce(now))
|
||||||
|
|
||||||
|
// Multiple ingresses or services changes, closer than MinInterval from each other
|
||||||
|
firstChangeTime := now
|
||||||
|
secondChangeTime := firstChangeTime.Add(time.Second)
|
||||||
|
// First change
|
||||||
|
ctrl.ScheduleRunOnce(firstChangeTime)
|
||||||
|
// Second change
|
||||||
|
ctrl.ScheduleRunOnce(secondChangeTime)
|
||||||
|
// Should not postpone the reconciliation further than firstChangeTime + MinInterval
|
||||||
|
now = now.Add(ctrl.MinEventSyncInterval)
|
||||||
|
assert.True(t, ctrl.ShouldRunOnce(now))
|
||||||
}
|
}
|
||||||
|
|
||||||
func testControllerFiltersDomains(t *testing.T, configuredEndpoints []*endpoint.Endpoint, domainFilter endpoint.DomainFilterInterface, providerEndpoints []*endpoint.Endpoint, expectedChanges []*plan.Changes) {
|
func testControllerFiltersDomains(t *testing.T, configuredEndpoints []*endpoint.Endpoint, domainFilter endpoint.DomainFilterInterface, providerEndpoints []*endpoint.Endpoint, expectedChanges []*plan.Changes) {
|
||||||
|
Loading…
Reference in New Issue
Block a user