1fanwang commented on code in PR #28047:
URL: https://github.com/apache/flink/pull/28047#discussion_r3198511695
##########
flink-kubernetes/src/main/java/org/apache/flink/kubernetes/kubeclient/services/ServiceType.java:
##########
@@ -109,25 +108,22 @@ 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
a single port (whose
+ * name is configurable via {@link
KubernetesConfigOptions#REST_SERVICE_PORT_NAME}), so the
+ * lookup does not depend on the port name.
+ */
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();
- if (servicePortCandidates.isEmpty()) {
+ if (ports == null || ports.isEmpty()) {
Review Comment:
Good catch — added a check that throws when the Service has more than one
port (the invariant comes from `buildUpExternalRestService` building exactly
one). New test `testGetRestPortFromExternalServiceFailsWhenMultiplePorts`
covers it. 0cf59c1acd
##########
flink-kubernetes/src/main/java/org/apache/flink/kubernetes/kubeclient/services/ServiceType.java:
##########
@@ -64,7 +63,7 @@ public Service buildUpExternalRestService(
.getType())
.withSelector(kubernetesJobManagerParameters.getSelectors())
.addNewPort()
- .withName(Constants.REST_PORT_NAME)
+
.withName(kubernetesJobManagerParameters.getRestServicePortName())
Review Comment:
Done — `InitJobManagerDecorator#getContainerPorts` now reads the same
configured name. I broadened the option's description to reflect that it covers
both the Service port and the container port. Considered renaming the option
(e.g. `kubernetes.rest.port-name`) but kept the existing namespace to avoid
invalidating prior CI; happy to rename if you'd prefer. New test
`testMainContainerRestPortNameWithCustomConfig` covers it. 0cf59c1acd
--
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]