Validate ServiceID/CheckID when deregistering.

This commit is contained in:
foostan 2015-01-27 01:06:49 +09:00
parent 8bfc337a75
commit 401bc71cb2
1 changed files with 10 additions and 0 deletions

View File

@ -637,6 +637,11 @@ func (a *Agent) RemoveService(serviceID string, persist bool) error {
consul.ConsulServiceID)
}
// Validate ServiceID
if serviceID == "" {
return fmt.Errorf("ServiceID missing")
}
// Remove service immeidately
a.state.RemoveService(serviceID)
@ -757,6 +762,11 @@ func (a *Agent) AddCheck(check *structs.HealthCheck, chkType *CheckType, persist
// RemoveCheck is used to remove a health check.
// The agent will make a best effort to ensure it is deregistered
func (a *Agent) RemoveCheck(checkID string, persist bool) error {
// Validate CheckID
if checkID == "" {
return fmt.Errorf("CheckID missing")
}
// Add to the local state for anti-entropy
a.state.RemoveCheck(checkID)