You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@trafficcontrol.apache.org by GitBox <gi...@apache.org> on 2020/10/12 19:13:04 UTC

[GitHub] [trafficcontrol] rawlinp commented on a change in pull request #5133: TR: set cache to unavailable if not found in TM health data

rawlinp commented on a change in pull request #5133:
URL: https://github.com/apache/trafficcontrol/pull/5133#discussion_r503484237



##########
File path: traffic_router/core/src/main/java/com/comcast/cdn/traffic_control/traffic_router/core/edge/Node.java
##########
@@ -200,9 +200,18 @@ public InetAddress getIp6() {
 
 	@SuppressWarnings({"PMD.CyclomaticComplexity", "PMD.NPathComplexity"})
 	public void setState(final JsonNode state) {
-		final boolean isAvailable = JsonUtils.optBoolean(state, "isAvailable", true);
-		final boolean ipv4Available = JsonUtils.optBoolean(state, "ipv4Available", true);
-		final boolean ipv6Available = JsonUtils.optBoolean(state, "ipv6Available", true);
+		final boolean ipv4Available;
+		final boolean ipv6Available;
+		if (state == null) {
+			LOGGER.warn("got null health state for " + fqdn + ". Setting it to unavailable!");
+			isAvailable = false;
+			ipv4Available = false;
+			ipv6Available = false;
+		} else {
+			isAvailable = JsonUtils.optBoolean(state, "isAvailable", true);
+			ipv4Available = JsonUtils.optBoolean(state, "ipv4Available", true);
+			ipv6Available = JsonUtils.optBoolean(state, "ipv6Available", true);
+		}

Review comment:
       The behavior is slightly different if we were to do that instead, because there is a difference between the entire state being null and the state missing one of the `ipv4Available` or `ipv6Available` keys (which were added in 4.0 I believe). Upon upgrading, those two would need to default to `true` if missing (since they're new); otherwise, TR would mistakenly treat every cache as unavailable.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org