Skip to content

Commit

Permalink
schedule recheck of DNS provider if error cause is external
Browse files Browse the repository at this point in the history
```improvement operator
schedule recheck of DNS provider if error cause is external
```

Co-authored-by: Uwe Krueger <[email protected]>
  • Loading branch information
MartinWeindel and mandelsoft committed Jul 24, 2019
1 parent 4fcbf7f commit 7121962
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 5 deletions.
4 changes: 2 additions & 2 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 21 additions & 3 deletions pkg/dns/provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ func updateDNSProvider(logger logger.LogContext, state *state, provider *dnsutil
}

if len(zones) > 0 && len(this.zones) == 0 {
return this, this.failed(logger, false, fmt.Errorf("no zone available in account matches zone filter"), false)
return this, this.failedButRecheck(logger, fmt.Errorf("no zone available in account matches zone filter"))
}

included, err := filterByZones(this.def_include, this.zones)
Expand All @@ -364,14 +364,14 @@ func updateDNSProvider(logger logger.LogContext, state *state, provider *dnsutil

if len(this.def_include) == 0 {
if len(this.zones) == 0 {
return this, this.failed(logger, false, fmt.Errorf("no hosted zones found"), false)
return this, this.failedButRecheck(logger, fmt.Errorf("no hosted zones found"))
}
for _, z := range this.zones {
included.Add(z.Domain())
}
} else {
if len(included) == 0 {
return this, this.failed(logger, false, fmt.Errorf("no domain matching hosting zones"), false)
return this, this.failedButRecheck(logger, fmt.Errorf("no domain matching hosting zones"))
}
}
for _, zone := range this.zones {
Expand Down Expand Up @@ -470,6 +470,24 @@ func (this *dnsProviderVersion) failed(logger logger.LogContext, modified bool,
return reconcile.Delay(logger, err)
}

func maxDuration(x, y time.Duration) time.Duration {
if x < y {
return y
}
return x
}

func (this *dnsProviderVersion) failedButRecheck(logger logger.LogContext, err error) reconcile.Status {
uerr := this.setError(false, err)
if uerr != nil {
logger.Error(err)
if errors.IsConflict(uerr) {
return reconcile.Repeat(logger, fmt.Errorf("cannot update provider %q: %s", this.ObjectName(), uerr))
}
}
return reconcile.Recheck(logger, err, maxDuration(this.state.config.CacheTTL, 30*time.Minute))
}

func (this *dnsProviderVersion) succeeded(logger logger.LogContext, modified bool) reconcile.Status {
status := &this.object.DNSProvider().Status
mod := resources.NewModificationState(this.object, modified)
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 7121962

Please sign in to comment.