Skip to content

Commit

Permalink
agent: Fix issues with re-registration. Fixes #216
Browse files Browse the repository at this point in the history
  • Loading branch information
armon committed Jun 17, 2014
1 parent ca2bbb0 commit 10c120b
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions command/agent/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,6 @@ func (a *Agent) AddService(service *structs.NodeService, chkType *CheckType) err
ServiceName: service.Service,
}
if err := a.AddCheck(check, chkType); err != nil {
a.state.RemoveService(service.ID)
return err
}
}
Expand Down Expand Up @@ -429,8 +428,8 @@ func (a *Agent) AddCheck(check *structs.HealthCheck, chkType *CheckType) error {
// Check if already registered
if chkType != nil {
if chkType.IsTTL() {
if _, ok := a.checkTTLs[check.CheckID]; ok {
return fmt.Errorf("CheckID is already registered")
if existing, ok := a.checkTTLs[check.CheckID]; ok {
existing.Stop()
}

ttl := &CheckTTL{
Expand All @@ -443,8 +442,8 @@ func (a *Agent) AddCheck(check *structs.HealthCheck, chkType *CheckType) error {
a.checkTTLs[check.CheckID] = ttl

} else {
if _, ok := a.checkMonitors[check.CheckID]; ok {
return fmt.Errorf("CheckID is already registered")
if existing, ok := a.checkMonitors[check.CheckID]; ok {
existing.Stop()
}
if chkType.Interval < MinInterval {
a.logger.Println(fmt.Sprintf("[WARN] agent: check '%s' has interval below minimum of %v",
Expand Down

0 comments on commit 10c120b

Please sign in to comment.