Skip to content
This repository has been archived by the owner on Mar 19, 2024. It is now read-only.

Add fix for re-registration when Consul K8s rolling restarts agent nodes #227

Merged
merged 3 commits into from
Jun 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changelog/227.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
Properly handle re-registration of deployed gateways when an agent no longer has the gateway in its catalog
```
6 changes: 5 additions & 1 deletion internal/consul/registration.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,17 @@ func (s *ServiceRegistry) ensureRegistration(ctx context.Context) {
return
}

var statusError *api.StatusError
var statusError api.StatusError
if errors.As(err, &statusError) {
if statusError.Code == http.StatusNotFound {
if err := s.retryRegistration(ctx); err != nil {
s.logger.Error("error registering service", "error", err)
return
}
s.logger.Info("successfully registered agent service")
// early return here because we had no error
// re-registering, so don't log
return
}
}
s.logger.Error("error fetching service", "error", err)
Expand Down