{"record":{"id":"46a80cafb32bd832","repo":"zhisheng17/flink-learning","slug":"unrecognized-service-type-46a80c","errorCode":null,"errorMessage":"Unrecognized Service type: {}","messagePattern":"Unrecognized Service type: (.+?)","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"flink-learning-k8s/flink-k8s/src/main/java/org/apache/flink/kubernetes/kubeclient/Fabric8FlinkKubeClient.java","lineNumber":431,"sourceCode":"\n\t\tif (servicePortCandidates.isEmpty()) {\n\t\t\tthrow new RuntimeException(\"Failed to find port \\\"\" + Constants.REST_PORT_NAME + \"\\\" in Service \\\"\" +\n\t\t\t\tExternalServiceDecorator.getExternalServiceName(this.clusterId) + \"\\\"\");\n\t\t}\n\n\t\tfinal ServicePort externalServicePort = servicePortCandidates.get(0);\n\n\t\tfinal KubernetesConfigOptions.ServiceExposedType externalServiceType =\n\t\t\tKubernetesConfigOptions.ServiceExposedType.valueOf(externalService.getSpec().getType());\n\n\t\tswitch (externalServiceType) {\n\t\t\tcase ClusterIP:\n\t\t\tcase LoadBalancer:\n\t\t\t\treturn externalServicePort.getPort();\n\t\t\tcase NodePort:\n\t\t\t\treturn externalServicePort.getNodePort();\n\t\t\tdefault:\n\t\t\t\tthrow new RuntimeException(\"Unrecognized Service type: \" + externalServiceType);\n\t\t}\n\t}\n\n\tprivate Optional<Endpoint> getRestEndPointFromService(Service service, int restPort) {\n\t\tif (service.getStatus() == null) {\n\t\t\treturn Optional.empty();\n\t\t}\n\n\t\tLoadBalancerStatus loadBalancer = service.getStatus().getLoadBalancer();\n\t\tboolean hasExternalIP = service.getSpec() != null &&\n\t\t\tservice.getSpec().getExternalIPs() != null && !service.getSpec().getExternalIPs().isEmpty();\n\n\t\tif (loadBalancer != null) {\n\t\t\treturn getLoadBalancerRestEndpoint(loadBalancer, restPort);\n\t\t} else if (hasExternalIP) {\n\t\t\tfinal String address = service.getSpec().getExternalIPs().get(0);\n\t\t\tif (address != null && !address.isEmpty()) {\n\t\t\t\treturn Optional.of(new Endpoint(address, restPort));","sourceCodeStart":413,"sourceCodeEnd":449,"githubUrl":"https://github.com/zhisheng17/flink-learning/blob/d731cee7618021be56d132cc925102ffff8d75e6/flink-learning-k8s/flink-k8s/src/main/java/org/apache/flink/kubernetes/kubeclient/Fabric8FlinkKubeClient.java#L413-L449","documentation":"Fabric8FlinkKubeClient.getRestPortFromExternalService resolves the REST port exposed by the Flink cluster's external Service. It handles ClusterIP and LoadBalancer (use the service port) and NodePort (use the node port), and throws this RuntimeException for any other Service type. It is a fail-fast guard against unsupported Kubernetes Service types.","triggerScenarios":"Calling restPort()/getRestPortFromExternalService when the external Flink REST Service's spec.type is anything other than ClusterIP, LoadBalancer, or NodePort — e.g. ExternalName, or a type set/patched to an unexpected value.","commonSituations":"Users set kubernetes.rest-service.exposed.type (or service.type) to an unsupported value, manually edit the Service YAML to ExternalName, or a controller/GitOps tool rewrites the Service type after deployment.","solutions":["Set kubernetes.rest-service.exposed.type to ClusterIP, LoadBalancer, or NodePort.","Inspect the deployed Service (kubectl get svc <cluster-id> -o jsonpath='{.spec.type}') and fix a manually/externally changed type.","If a GitOps controller keeps rewriting the type, exclude the Flink Services from its management."],"exampleFix":"// before\nkubernetes.rest-service.exposed.type: ExternalName\n// after\nkubernetes.rest-service.exposed.type: LoadBalancer","handlingStrategy":"validation","validationCode":"String type = flinkConfig.get(KubernetesConfigOptions.REST_SERVICE_EXPOSED_TYPE) != null ? flinkConfig.get(KubernetesConfigOptions.REST_SERVICE_EXPOSED_TYPE).name() : service.getSpec().getType();\nif (!(\"ClusterIP\".equals(type) || \"LoadBalancer\".equals(type) || \"NodePort\".equals(type))) {\n    throw new IllegalStateException(\"Unsupported Service type for REST port lookup: \" + type);\n}","typeGuard":null,"tryCatchPattern":"try {\n    int port = kubeClient.getRestPort(clusterId);\n} catch (RuntimeException e) {\n    LOG.warn(\"Unsupported service type, cannot resolve REST port: {}\", e.getMessage());\n}","preventionTips":["Only use ClusterIP, LoadBalancer, or NodePort for kubernetes.rest-service.exposed.type.","Audit Service types after applying GitOps manifests.","Check Service type with kubectl before resolving ports programmatically."],"tags":["kubernetes","service-type","flink"],"backgroundTag":"invalid-enum-value","analyzedSha":"d731cee7618021be56d132cc925102ffff8d75e6","analyzedAt":"2026-09-06T05:35:08.496Z","contentChangedAt":"2026-09-06T05:35:08.496Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}