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
openshift-maven-plugin: service.yml fragment with ports creates service with unnamed port mapping #513
Comments
With the service.yml fragment removed from src/main/jkube, which is then empty, the generated service-xxx.json then contains the following correct definition of the "http" port mapping, appropriately named:
|
Here is the best I can do for a reproducer project: https://github.com/robinroos/jkube-513 Please see the REDME file in that project. |
@robinroos : Thanks a lot for taking time to provide a reproducer 👍 . It will be really helpful for us in investigating the issue. |
Seems like Service name is being set
I think we can simply avoid renaming private void ensurePortName(ServicePort port, String protocol) {
if (port.getName() != null && !port.getName().isEmpty()) {
- port.setName(getDefaultPortName(port.getPort(), getProtocol(protocol)));
+ String defaultPortName = getDefaultPortName(port.getPort(), getProtocol(protocol));
+ if (defaultPortName != null) {
+ port.setName(defaultPortName);
+ }
}
} I'm able to see ports being generated correctly: "spec" : {
"clusterIP" : "172.30.241.108",
"ports" : [ {
"name" : "http",
"port" : 80,
"protocol" : "TCP",
"targetPort" : 8080
}, {
"name" : "hazelcast",
"port" : 5701,
"protocol" : "TCP",
"targetPort" : 5701
} ] |
Right now from you seem to adding another
|
In ensurePortName() you only det a default name if the port originally had a non-null non-empty name. I would have expected that in such a case you should not set a default name, but that you should set a default name if the port has a name which is null or empty. |
I have submitted a PR #516 to resolve this, having built 1.1.0-SNAPSHOT from my branch and shown the fix to be working. I will try to get the contributor's agreement signed tonight. |
I have signed the ECA. |
So apparently, this issue was introduced in this commit (probably due to a typo): The bug not only affects the port name, but service name and others |
Description
Using openshift-maven-plugin in a Spring Boot app, with the "spring boot" generator.
In the absence of any fragments the project builds and deploys successfully to OpenShift. Once service is defined, "http" TCP 80 -> 8080
The intention of the fragment is to define an ADDITIONAL service, "hazelcast" TCP 5701 -> 5701.
src/main/jkube/service.yml:
With the above fragment present, openshift-maven-plugin generates:
target/jkube/applyJson/namespace/service-xxx.json
including the following extract:
Note that the port entry has no name.
At this point deployment is successful; TCP 5701 -> 5701 is exposed by an unnamed port mapping in service-xxx, but there is no HTTP port exposed.
If the fragment is extended to include "http" as follows:
src/main/jkube/service.yml:
then openshift-maven-plugin fails (silently) to generate anything in target/jkube/applyJson, possibly due to name collision for two unnamed service port entries, and deployment subsequenly fails with:
since openshift.yml is absent.
Info
Potentially relevant maven properties include:
I will endeavour to add a simple reproducer project as soon as possible.
The text was updated successfully, but these errors were encountered: