Order
This article mainly studies the overriddenstatus of eureka instance.
overriddenstatus
eureka-client-1.8.8-sources.jar! /com/netflix/appinfo/InstanceInfo.java
/**
* Sets the status overridden by some other external process.This is
* mostly used in putting an instance out of service to block traffic to
* it.
*
* @param status the overridden {@link InstanceStatus} of the instance.
* @return @return the {@link InstanceInfo} builder.
*/
public Builder setOverriddenStatus(InstanceStatus status) {
result.overriddenstatus = status;
return this;
}
As can be seen from the comments, this overriddenstatus means that it is used for some external operations. In netflix, when it is used for red/black deployment, the specified service is first set to OUT_OF_SERVICE to intentionally shut down the request traffic.
InstanceStatus enumeration is defined as follows:
public enum InstanceStatus {
UP, // Ready to receive traffic
DOWN, // Do not send traffic- healthcheck callback failed
STARTING, // Just about starting- initializations to be done - do not
// send traffic
OUT_OF_SERVICE, // Intentionally shutdown for traffic
UNKNOWN;
public static InstanceStatus toEnum(String s) {
if (s != null) {
try {
return InstanceStatus.valueOf(s.toUpperCase());
} catch (IllegalArgumentException e) {
// ignore and fall through to unknown
logger.debug("illegal argument supplied to InstanceStatus.valueOf: {}, defaulting to {}", s, UNKNOWN);
}
}
return UNKNOWN;
}
}
Operation
Set OUT_OF_SERVICE
curl -i -X PUT http://localhost:8761/eureka/apps/client1/127.0.0.1:client1:8081/status?value=OUT_OF_SERVICE
HTTP/1.1 200
Content-Type: application/xml
Content-Length: 0
Date: Wed, 16 May 2018 06:52:29 GMT
Delete OUT_OF_SERVICE
curl -i -X DELETE http://localhost:8761/eureka/apps/client1/127.0.0.1:client1:8081/status
HTTP/1.1 200
Content-Type: application/xml
Content-Length: 0
Date: Wed, 16 May 2018 06:54:30 GM
Summary
The overriddenstatus of eureka instance is very useful for deployment. For example, the red/black upgrade sets some original services to OUT_OF_SERVICE first, stops receiving requests, and then becomes black. After that, the newly deployed services start up, which is called red. If the new service is normal, the old service can be closed. Assuming that the new service has problems, the new service will be deleted immediately, the overriddenstatus of the old service will be deleted, UP will be restored, and the received traffic will be restored.
doc
- Talk about restrapi of Eureka Server
- Talk about eureka server’s instance Registration and Metadata Change Interface
- Deploying the Netflix API
- The Mystery of Eureka Health Monitoring
- The Mystery of Eureka self-preservation
- Unable to return status to UP after overridden status was set to OUT_OF_SERVICE #955
- Eureka 1.x – there is no mechanism provided to remove overridden status #389
- Provide an API to remove all overridden status #89
- Support DELETE operation for instance status override.