From 401bc71cb23cbc49b714d2316b05763e1891f20c Mon Sep 17 00:00:00 2001 From: foostan Date: Tue, 27 Jan 2015 01:06:49 +0900 Subject: [PATCH] Validate ServiceID/CheckID when deregistering. --- command/agent/agent.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/command/agent/agent.go b/command/agent/agent.go index b21dae5f58..a0bd63539a 100644 --- a/command/agent/agent.go +++ b/command/agent/agent.go @@ -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)