Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Service config parse failures should be UNAVAILABLE #9346

Merged
merged 1 commit into from
Jul 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ ConfigOrError parseLoadBalancingConfigPolicyInternal(
}
return ConfigOrError.fromError(
Status
.INVALID_ARGUMENT
.UNAVAILABLE
.withDescription(
"None of " + policiesTried + " specified child policies are available."));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public ConfigOrError parseLoadBalancingPolicyConfig(Map<String, ?> rawLoadBalanc
String rpcBehavior = JsonUtil.getString(rawLoadBalancingPolicyConfig, "rpcBehavior");
if (rpcBehavior == null) {
return ConfigOrError.fromError(
Status.INVALID_ARGUMENT.withDescription("no 'rpcBehavior' defined"));
Status.UNAVAILABLE.withDescription("no 'rpcBehavior' defined"));
}
return ConfigOrError.fromConfig(new RpcBehaviorConfig(rpcBehavior));
}
Expand Down
2 changes: 1 addition & 1 deletion rls/src/main/java/io/grpc/rls/RlsLoadBalancerProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public ConfigOrError parseLoadBalancingPolicyConfig(Map<String, ?> rawLoadBalanc
new LbPolicyConfiguration(routeLookupConfig, routeLookupChannelServiceConfig, lbPolicy));
} catch (Exception e) {
return ConfigOrError.fromError(
Status.INVALID_ARGUMENT
Status.UNAVAILABLE
.withDescription("can't parse config: " + e.getMessage())
.withCause(e));
}
Expand Down
2 changes: 1 addition & 1 deletion xds/src/main/java/io/grpc/xds/CdsLoadBalancer2.java
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ private void handleClusterDiscovered() {
root.result.lbPolicyConfig());
LoadBalancerProvider lbProvider = lbRegistry.getProvider(unwrappedLbConfig.getPolicyName());
if (lbProvider == null) {
throw NameResolver.ConfigOrError.fromError(Status.INVALID_ARGUMENT.withDescription(
throw NameResolver.ConfigOrError.fromError(Status.UNAVAILABLE.withDescription(
"No provider available for LB: " + unwrappedLbConfig.getPolicyName())).getError()
.asRuntimeException();
}
Expand Down
2 changes: 1 addition & 1 deletion xds/src/main/java/io/grpc/xds/CdsLoadBalancerProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ static ConfigOrError parseLoadBalancingConfigPolicy(Map<String, ?> rawLoadBalanc
return ConfigOrError.fromConfig(new CdsConfig(cluster));
} catch (RuntimeException e) {
return ConfigOrError.fromError(
Status.fromThrowable(e).withDescription(
Status.UNAVAILABLE.withCause(e).withDescription(
"Failed to parse CDS LB config: " + rawLoadBalancingPolicyConfig));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public ConfigOrError parseLoadBalancingPolicyConfig(Map<String, ?> rawConfig) {
}
} catch (RuntimeException e) {
return ConfigOrError.fromError(
Status.fromThrowable(e).withDescription(
Status.INTERNAL.withCause(e).withDescription(
"Failed to parse cluster_manager LB config: " + rawConfig));
}
return ConfigOrError.fromConfig(new ClusterManagerConfig(parsedChildPolicies));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,13 @@ public ConfigOrError parseLoadBalancingPolicyConfig(Map<String, ?> rawConfig) {
choiceCount = DEFAULT_CHOICE_COUNT;
}
if (choiceCount < MIN_CHOICE_COUNT) {
return ConfigOrError.fromError(Status.INVALID_ARGUMENT.withDescription(
"Invalid 'choiceCount'"));
return ConfigOrError.fromError(Status.UNAVAILABLE.withDescription(
"Invalid 'choiceCount' in least_request_experimental config"));
}
return ConfigOrError.fromConfig(new LeastRequestConfig(choiceCount));
} catch (RuntimeException e) {
return ConfigOrError.fromError(
Status.fromThrowable(e).withDescription(
Status.UNAVAILABLE.withCause(e).withDescription(
"Failed to parse least_request_experimental LB config: " + rawConfig));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public ConfigOrError parseLoadBalancingPolicyConfig(Map<String, ?> rawLoadBalanc
}
if (minRingSize <= 0 || maxRingSize <= 0 || minRingSize > maxRingSize
|| maxRingSize > MAX_RING_SIZE) {
return ConfigOrError.fromError(Status.INVALID_ARGUMENT.withDescription(
return ConfigOrError.fromError(Status.UNAVAILABLE.withDescription(
"Invalid 'mingRingSize'/'maxRingSize'"));
}
return ConfigOrError.fromConfig(new RingHashConfig(minRingSize, maxRingSize));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public ConfigOrError parseLoadBalancingPolicyConfig(Map<String, ?> rawConfig) {
return ConfigOrError.fromConfig(new WeightedTargetConfig(parsedChildConfigs));
} catch (RuntimeException e) {
return ConfigOrError.fromError(
Status.fromThrowable(e).withDescription(
Status.INTERNAL.withCause(e).withDescription(
"Failed to parse weighted_target LB config: " + rawConfig));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public ConfigOrError parseLoadBalancingPolicyConfig(Map<String, ?> rawConfig) {
PolicySelection policySelection = (PolicySelection) selectedConfig.getConfig();
return ConfigOrError.fromConfig(new WrrLocalityConfig(policySelection));
} catch (RuntimeException e) {
return ConfigOrError.fromError(Status.fromThrowable(e)
return ConfigOrError.fromError(Status.INTERNAL.withCause(e)
.withDescription("Failed to parse wrr_locality LB config: " + rawConfig));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,9 @@ public void parseLoadBalancingConfig_invalid_negativeSize() throws IOException {
ConfigOrError configOrError =
provider.parseLoadBalancingPolicyConfig(parseJsonObject(lbConfig));
assertThat(configOrError.getError()).isNotNull();
assertThat(configOrError.getError().getCode()).isEqualTo(Code.INVALID_ARGUMENT);
assertThat(configOrError.getError().getCode()).isEqualTo(Code.UNAVAILABLE);
assertThat(configOrError.getError().getDescription())
.isEqualTo("Invalid 'choiceCount'");
.isEqualTo("Invalid 'choiceCount' in least_request_experimental config");
}

@Test
Expand All @@ -107,9 +107,9 @@ public void parseLoadBalancingConfig_invalid_tooSmallSize() throws IOException {
ConfigOrError configOrError =
provider.parseLoadBalancingPolicyConfig(parseJsonObject(lbConfig));
assertThat(configOrError.getError()).isNotNull();
assertThat(configOrError.getError().getCode()).isEqualTo(Code.INVALID_ARGUMENT);
assertThat(configOrError.getError().getCode()).isEqualTo(Code.UNAVAILABLE);
assertThat(configOrError.getError().getDescription())
.isEqualTo("Invalid 'choiceCount'");
.isEqualTo("Invalid 'choiceCount' in least_request_experimental config");
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,13 @@ public NameResolver.ConfigOrError parseLoadBalancingPolicyConfig(
String metadataKey = JsonUtil.getString(rawLoadBalancingPolicyConfig, "metadataKey");
if (metadataKey == null) {
return NameResolver.ConfigOrError.fromError(
Status.INVALID_ARGUMENT.withDescription("no 'metadataKey' defined"));
Status.UNAVAILABLE.withDescription("no 'metadataKey' defined"));
}

String metadataValue = JsonUtil.getString(rawLoadBalancingPolicyConfig, "metadataValue");
if (metadataValue == null) {
return NameResolver.ConfigOrError.fromError(
Status.INVALID_ARGUMENT.withDescription("no 'metadataValue' defined"));
Status.UNAVAILABLE.withDescription("no 'metadataValue' defined"));
}

return NameResolver.ConfigOrError.fromConfig(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public void parseLoadBalancingConfig_invalid_negativeSize() throws IOException {
ConfigOrError configOrError =
provider.parseLoadBalancingPolicyConfig(parseJsonObject(lbConfig));
assertThat(configOrError.getError()).isNotNull();
assertThat(configOrError.getError().getCode()).isEqualTo(Code.INVALID_ARGUMENT);
assertThat(configOrError.getError().getCode()).isEqualTo(Code.UNAVAILABLE);
assertThat(configOrError.getError().getDescription())
.isEqualTo("Invalid 'mingRingSize'/'maxRingSize'");
}
Expand All @@ -109,7 +109,7 @@ public void parseLoadBalancingConfig_invalid_minGreaterThanMax() throws IOExcept
ConfigOrError configOrError =
provider.parseLoadBalancingPolicyConfig(parseJsonObject(lbConfig));
assertThat(configOrError.getError()).isNotNull();
assertThat(configOrError.getError().getCode()).isEqualTo(Code.INVALID_ARGUMENT);
assertThat(configOrError.getError().getCode()).isEqualTo(Code.UNAVAILABLE);
assertThat(configOrError.getError().getDescription())
.isEqualTo("Invalid 'mingRingSize'/'maxRingSize'");
}
Expand All @@ -121,7 +121,7 @@ public void parseLoadBalancingConfig_invalid_ringTooLarge() throws IOException {
ConfigOrError configOrError =
provider.parseLoadBalancingPolicyConfig(parseJsonObject(lbConfig));
assertThat(configOrError.getError()).isNotNull();
assertThat(configOrError.getError().getCode()).isEqualTo(Code.INVALID_ARGUMENT);
assertThat(configOrError.getError().getCode()).isEqualTo(Code.UNAVAILABLE);
assertThat(configOrError.getError().getDescription())
.isEqualTo("Invalid 'mingRingSize'/'maxRingSize'");
}
Expand All @@ -132,7 +132,7 @@ public void parseLoadBalancingConfig_zeroMinRingSize() throws IOException {
ConfigOrError configOrError =
provider.parseLoadBalancingPolicyConfig(parseJsonObject(lbConfig));
assertThat(configOrError.getError()).isNotNull();
assertThat(configOrError.getError().getCode()).isEqualTo(Code.INVALID_ARGUMENT);
assertThat(configOrError.getError().getCode()).isEqualTo(Code.UNAVAILABLE);
assertThat(configOrError.getError().getDescription())
.isEqualTo("Invalid 'mingRingSize'/'maxRingSize'");
}
Expand All @@ -143,7 +143,7 @@ public void parseLoadBalancingConfig_minRingSizeGreaterThanMaxRingSize() throws
ConfigOrError configOrError =
provider.parseLoadBalancingPolicyConfig(parseJsonObject(lbConfig));
assertThat(configOrError.getError()).isNotNull();
assertThat(configOrError.getError().getCode()).isEqualTo(Code.INVALID_ARGUMENT);
assertThat(configOrError.getError().getCode()).isEqualTo(Code.UNAVAILABLE);
assertThat(configOrError.getError().getDescription())
.isEqualTo("Invalid 'mingRingSize'/'maxRingSize'");
}
Expand Down