1fanwang commented on code in PR #28047:
URL: https://github.com/apache/flink/pull/28047#discussion_r4574644947
##########
flink-kubernetes/src/main/java/org/apache/flink/kubernetes/kubeclient/decorators/InitJobManagerDecorator.java:
##########
@@ -189,7 +189,7 @@ private List<ContainerPort> getContainerPorts() {
}
return Arrays.asList(
new ContainerPortBuilder()
- .withName(Constants.REST_PORT_NAME)
+
.withName(kubernetesJobManagerParameters.getRestServicePortName())
Review Comment:
Done in
https://github.com/1fanwang/flink/commit/f975e637b1e82858f11f933b1b8e29fddcef2404.
The container port keeps the configured name, as asked in the earlier review,
and a colliding name now fails with a message that names the option.
##########
flink-kubernetes/src/main/java/org/apache/flink/kubernetes/kubeclient/services/ServiceType.java:
##########
@@ -109,25 +108,29 @@ public abstract Optional<Endpoint> getRestEndpoint(
*/
public abstract String getType();
- /** Get rest port from the external Service. */
+ /**
+ * Get rest port from the external Service. The rest Service is built with
exactly one port
+ * (whose name is configurable via {@link
KubernetesConfigOptions#REST_SERVICE_PORT_NAME}), so
+ * the lookup does not depend on the port name. If the Service has zero or
more than one port,
+ * this method throws — the invariant comes from {@link
#buildUpExternalRestService}.
+ */
public int getRestPortFromExternalService(Service externalService) {
- final List<ServicePort> servicePortCandidates =
- externalService.getSpec().getPorts().stream()
- .filter(x ->
x.getName().equals(Constants.REST_PORT_NAME))
- .collect(Collectors.toList());
+ final List<ServicePort> ports = externalService.getSpec().getPorts();
+ final String serviceName = externalService.getMetadata().getName();
- if (servicePortCandidates.isEmpty()) {
+ if (ports == null || ports.isEmpty()) {
throw new RuntimeException(
- "Failed to find port \""
- + Constants.REST_PORT_NAME
- + "\" in Service \""
- + externalService.getMetadata().getName()
- + "\"");
+ "Failed to find any port in Service \"" + serviceName +
"\"");
+ }
+ if (ports.size() > 1) {
Review Comment:
Done in
https://github.com/1fanwang/flink/commit/f975e637b1e82858f11f933b1b8e29fddcef2404.
The lookup selects the port with the configured name and still reads a Service
with a single port as it is.
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]