From 16c4de76706563e832809275edced54e934706e2 Mon Sep 17 00:00:00 2001 From: "Steven E. Harris" Date: Wed, 31 Aug 2016 19:14:21 -0400 Subject: [PATCH] Correct expected status code for deregistration Per the Eureka documentation and the implementation in method com.netflix.eureka.resources.InstanceResource#cancelLease(), Eureka returns HTTP status code 200 to indicate successful deregistration of an instance, and not status code 204 as our EurekaConnection's DeregisterInstance method had expected. --- net.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/net.go b/net.go index a4cbe55..b293eee 100644 --- a/net.go +++ b/net.go @@ -217,7 +217,9 @@ func (e *EurekaConnection) DeregisterInstance(ins *Instance) error { log.Errorf("Could not complete deregistration, error: %s", err.Error()) return err } - if rcode != 204 { + // Eureka promises to return HTTP status code upon deregistration success, but fargo used to accept status code 204 + // here instead. Accommodate both for backward compatibility with any fake or proxy Eureka stand-ins. + if rcode != 200 && rcode != 204 { log.Warningf("HTTP returned %d deregistering Instance=%s App=%s", rcode, ins.Id(), ins.App) return fmt.Errorf("http returned %d possible failure deregistering instance\n", rcode) }