router/registry: fix expiring routes bug (#1927)

This commit is contained in:
ben-toogood 2020-08-11 16:57:04 +01:00 committed by GitHub
parent fae4151027
commit 012ec6a998
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -205,7 +205,14 @@ func (r *rtr) loadRoutes(reg registry.Registry) error {
if len(routes) > 0 { if len(routes) > 0 {
logger.Tracef("Creating routes for service %v domain: %v", service, domain) logger.Tracef("Creating routes for service %v domain: %v", service, domain)
for _, rt := range routes { for _, rt := range routes {
if err := r.table.Create(rt); err != nil { err := r.table.Create(rt)
// update the route to prevent it from expiring
if err == router.ErrDuplicateRoute {
err = r.table.Update(rt)
}
if err != nil {
logger.Errorf("Error creating route for service %v in domain %v: %v", service, domain, err) logger.Errorf("Error creating route for service %v in domain %v: %v", service, domain, err)
} }
} }
@ -228,7 +235,14 @@ func (r *rtr) loadRoutes(reg registry.Registry) error {
if len(routes) > 0 { if len(routes) > 0 {
logger.Tracef("Creating routes for service %v domain: %v", srv, domain) logger.Tracef("Creating routes for service %v domain: %v", srv, domain)
for _, rt := range routes { for _, rt := range routes {
if err := r.table.Create(rt); err != nil { err := r.table.Create(rt)
// update the route to prevent it from expiring
if err == router.ErrDuplicateRoute {
err = r.table.Update(rt)
}
if err != nil {
logger.Errorf("Error creating route for service %v in domain %v: %v", service, domain, err) logger.Errorf("Error creating route for service %v in domain %v: %v", service, domain, err)
} }
} }