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

Changing the default port of the embedded server does not change the K8S probes default port #2832

Open
manusa opened this issue Mar 18, 2024 Discussed in #2826 · 29 comments · May be fixed by #2880
Open

Changing the default port of the embedded server does not change the K8S probes default port #2832

manusa opened this issue Mar 18, 2024 Discussed in #2826 · 29 comments · May be fixed by #2880
Assignees
Labels
bug Something isn't working

Comments

@manusa
Copy link
Member

manusa commented Mar 18, 2024

Discussed in #2826

Originally posted by waynemorphic March 16, 2024
I was checking out the Spring Boot Quickstart provided under the Maven package and found something peculiar that I would like a little help with. The default port of the embedded server is 8080. However, I changed it to 8081 underresources\application.yaml with the configuration:

server:
  port: 8081

This follows that, building the Spring Boot application with mvn spring-boot:run serves the application on Tomcat's port 8081.

2024-03-16 18:55:29.067  INFO 3498 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8081 (http)
2024-03-16 18:55:29.085  INFO 3498 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2024-03-16 18:55:29.085  INFO 3498 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet engine: [Apache Tomcat/9.0.82]
2024-03-16 18:55:29.210  INFO 3498 --- [           main] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2024-03-16 18:55:29.210  INFO 3498 --- [           main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 1614 ms
2024-03-16 18:55:29.870  INFO 3498 --- [           main] o.s.b.a.e.web.EndpointLinksResolver      : Exposing 1 endpoint(s) beneath base path '/actuator'
2024-03-16 18:55:29.974  INFO 3498 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 8081 (http) with context path ''
2024-03-16 18:55:29.987  INFO 3498 --- [           main] o.e.j.m.sample.spring.boot.Application   : Started Application in 3.102 seconds (JVM running for 3.656)

However, when running the command that creates K8S resources descriptors, i.e mvn clean k8s:resource -Pkubernetes, then there is a discrepancy between the ports:

[INFO] k8s: jkube-controller: Adding a default Deployment
[INFO] k8s: jkube-service: Adding a default service 'spring-boot' with ports [8081]
[INFO] k8s: jkube-healthcheck-spring-boot: Adding readiness probe on port 8080, path='/actuator/health', scheme='HTTP', with initial delay 10 seconds
[INFO] k8s: jkube-healthcheck-spring-boot: Adding liveness probe on port 8080, path='/actuator/health', scheme='HTTP', with initial delay 180 seconds
[INFO] k8s: jkube-service-discovery: Using first mentioned service port '8081' 

What I have tried so far with the invaluable help of @rohanKanojia was adding the following property in my POM file:

<properties>
    <jkube.version>${project.version}</jkube.version>
    <jkube.generator.spring-boot.webPort>8081</jkube.generator.spring-boot.webPort>
  </properties>

However, the above port discrepancy persists. Guidance on this will be helpful. Thank you

@manusa manusa added the bug Something isn't working label Mar 18, 2024
@arsenalzp
Copy link
Contributor

Hello,
Is it possible to work for this issue?

@rohanKanojia
Copy link
Member

@arsenalzp : Please see my comment #2800 (comment) for some code pointers related to this issue. If you need more help, please don't hesitate to ping me.

@arsenalzp
Copy link
Contributor

arsenalzp commented Mar 27, 2024

The issue is that the call SpringBootConfiguration.from(getContext().getProject()); returns the different configuration.
As you may see at the screenshot Spring Boot port was changed from 8080 to 8081, I used <jkube.generator.spring-boot.webPort>8081</jkube.generator.spring-boot.webPort> property to override the default port for the embedded server.

изображение

However, SprongBootConfiguration call returns wrong value which doesn't reflect the changed default port.
The following call https://github.com/eclipse/jkube/blob/9392602ca5eb81db04e4516d64b91ba691f93596/jkube-kit/common/src/main/java/org/eclipse/jkube/kit/common/util/SpringBootUtil.java#L67 doesn't return valid Properties object, that's because both variables ymlResource and propertiesResource are null.

It is still possible to get Properties from springActiveProfile by using following call:
https://github.com/eclipse/jkube/blob/9392602ca5eb81db04e4516d64b91ba691f93596/jkube-kit/common/src/main/java/org/eclipse/jkube/kit/common/util/YamlUtil.java#L48

however there is resource parameter check in the if (resource != null) statement, which is ALWAYS false, because resource is always null

@rohanKanojia
Copy link
Member

@arsenalzp : Hello, Sorry I was PTO last week.

I used <jkube.generator.spring-boot.webPort>8081</jkube.generator.spring-boot.webPort> property to override the default port for the embedded server.

You're configuring the generator (responsible for creating container images) but running k8s:resource goal (responsible for generating Kubernetes manifests. As far as I remember @waynemorphic was trying to configure Spring Application's configuration in src/main/resources/appliation.yml:

server:
  port: 8081

Do you have application.yml file present in src/main/resources ?

The expected behavior is to automatically detect Spring Boot Configuration and use that port.

@arsenalzp
Copy link
Contributor

arsenalzp commented Apr 5, 2024

@arsenalzp : Hello, Sorry I was PTO last week.

I used <jkube.generator.spring-boot.webPort>8081</jkube.generator.spring-boot.webPort> property to override the default port for the embedded server.

You're configuring the generator (responsible for creating container images) but running k8s:resource goal (responsible for generating Kubernetes manifests. As far as I remember @waynemorphic was trying to configure Spring Application's configuration in src/main/resources/appliation.yml:

server:
  port: 8081

Do you have application.yml file present in src/main/resources ?

The expected behavior is to automatically detect Spring Boot Configuration and use that port.

Hello,
Yest, I clearly understand what should be done and I know the differences between enrichers and generators (thanks to meaningful doc, of course!), I just wanted to reproduce all the steps described in the initial message of this issue.

@rohanKanojia
Copy link
Member

rohanKanojia commented Apr 5, 2024

generators -> classes responsible for creating container images as per different frameworks by inspecting project dependencies

enrichers -> classes responsible for creating Kubernetes manifests by checking project depednencies/ setup.

@arsenalzp
Copy link
Contributor

arsenalzp commented Apr 5, 2024

Last week and begging of the current one I was on vacations due to the Easter, so I will keep working on this issue with your permission.

@rohanKanojia
Copy link
Member

@arsenalzp : Please take your time and don't worry about the delay, there are no strict deadlines here.

@arsenalzp
Copy link
Contributor

arsenalzp commented Apr 5, 2024

@arsenalzp : Please take your time and don't worry about the delay, there are no strict deadlines here.

Thank you!
I've just arrived at home and checked the second question asked by you regarding resources path - answer is YES, I put the files in the right directory, as described in Spring Boot docs:

/jkube/quickstarts/maven/spring-boot/src/main/resources

Spring Boot instance boots up with the right port defined in application.yml.

The issue is that URLClassLoader couldn't find files either application.yml or application.properties.

Why is that? That's because URLs to look for are classpath and outputDirectories (target/classes), and of course, there are no any resources directory.

Upd.
The right path should be baseDirectory + /src/main/resources then if works in correct way.
I've just added jKubeProject.getResourcesDirectory().getAbsolutePath() call to ClassUtil.createClassLoader() method:
https://github.com/eclipse/jkube/blob/2ebeabe2ae6ebbcd52e0fd9323607892bcb831d4/jkube-kit/common/src/main/java/org/eclipse/jkube/kit/common/util/JKubeProjectUtil.java#L175-L179

and it is working!

@arsenalzp arsenalzp linked a pull request Apr 6, 2024 that will close this issue
17 tasks
@arsenalzp
Copy link
Contributor

arsenalzp commented Apr 6, 2024

Here is the bug affected version.
As you may see on the screen both yamlResources and propertiesResources objects are null:

изображение

Checking paths:

изображение

The full list of paths defined in compilerClassLoader.ucp.path field:

file:/home/username/eclipse-workspace/jkube/quickstarts/maven/spring-boot/target/classes/
file:/home/username/eclipse-workspace/jkube/quickstarts/maven/spring-boot/target/classes/
file:/home/username/.m2/repository/org/springframework/boot/spring-boot-starter-web/2.7.17/spring-boot-starter-web-2.7.17.jar
file:/home/username/.m2/repository/org/springframework/boot/spring-boot-starter/2.7.17/spring-boot-starter-2.7.17.jar
file:/home/username/.m2/repository/org/springframework/boot/spring-boot/2.7.17/spring-boot-2.7.17.jar
file:/home/username/.m2/repository/org/springframework/boot/spring-boot-autoconfigure/2.7.17/spring-boot-autoconfigure-2.7.17.jar
file:/home/username/.m2/repository/org/springframework/boot/spring-boot-starter-logging/2.7.17/spring-boot-starter-logging-2.7.17.jar
file:/home/username/.m2/repository/ch/qos/logback/logback-classic/1.2.12/logback-classic-1.2.12.jar
file:/home/username/.m2/repository/ch/qos/logback/logback-core/1.2.12/logback-core-1.2.12.jar
file:/home/username/.m2/repository/org/slf4j/slf4j-api/1.7.36/slf4j-api-1.7.36.jar
file:/home/username/.m2/repository/org/apache/logging/log4j/log4j-to-slf4j/2.17.2/log4j-to-slf4j-2.17.2.jar
file:/home/username/.m2/repository/org/apache/logging/log4j/log4j-api/2.17.2/log4j-api-2.17.2.jar
file:/home/username/.m2/repository/org/slf4j/jul-to-slf4j/1.7.36/jul-to-slf4j-1.7.36.jar
file:/home/username/.m2/repository/jakarta/annotation/jakarta.annotation-api/1.3.5/jakarta.annotation-api-1.3.5.jar
file:/home/username/.m2/repository/org/springframework/spring-core/5.3.30/spring-core-5.3.30.jar
file:/home/username/.m2/repository/org/springframework/spring-jcl/5.3.30/spring-jcl-5.3.30.jar
file:/home/username/.m2/repository/org/yaml/snakeyaml/1.30/snakeyaml-1.30.jar
file:/home/username/.m2/repository/org/springframework/boot/spring-boot-starter-json/2.7.17/spring-boot-starter-json-2.7.17.jar
file:/home/username/.m2/repository/com/fasterxml/jackson/core/jackson-databind/2.13.5/jackson-databind-2.13.5.jar
file:/home/username/.m2/repository/com/fasterxml/jackson/core/jackson-annotations/2.13.5/jackson-annotations-2.13.5.jar
file:/home/username/.m2/repository/com/fasterxml/jackson/core/jackson-core/2.13.5/jackson-core-2.13.5.jar
file:/home/username/.m2/repository/com/fasterxml/jackson/datatype/jackson-datatype-jdk8/2.13.5/jackson-datatype-jdk8-2.13.5.jar
file:/home/username/.m2/repository/com/fasterxml/jackson/datatype/jackson-datatype-jsr310/2.13.5/jackson-datatype-jsr310-2.13.5.jar
file:/home/username/.m2/repository/com/fasterxml/jackson/module/jackson-module-parameter-names/2.13.5/jackson-module-parameter-names-2.13.5.jar
file:/home/username/.m2/repository/org/springframework/boot/spring-boot-starter-tomcat/2.7.17/spring-boot-starter-tomcat-2.7.17.jar
file:/home/username/.m2/repository/org/apache/tomcat/embed/tomcat-embed-core/9.0.82/tomcat-embed-core-9.0.82.jar
file:/home/username/.m2/repository/org/apache/tomcat/embed/tomcat-embed-el/9.0.82/tomcat-embed-el-9.0.82.jar
file:/home/username/.m2/repository/org/apache/tomcat/embed/tomcat-embed-websocket/9.0.82/tomcat-embed-websocket-9.0.82.jar
file:/home/username/.m2/repository/org/springframework/spring-web/5.3.30/spring-web-5.3.30.jar
file:/home/username/.m2/repository/org/springframework/spring-beans/5.3.30/spring-beans-5.3.30.jar
file:/home/username/.m2/repository/org/springframework/spring-webmvc/5.3.30/spring-webmvc-5.3.30.jar
file:/home/username/.m2/repository/org/springframework/spring-aop/5.3.30/spring-aop-5.3.30.jar
file:/home/username/.m2/repository/org/springframework/spring-context/5.3.30/spring-context-5.3.30.jar
file:/home/username/.m2/repository/org/springframework/spring-expression/5.3.30/spring-expression-5.3.30.jar
file:/home/username/.m2/repository/org/springframework/boot/spring-boot-starter-actuator/2.7.17/spring-boot-starter-actuator-2.7.17.jar
file:/home/username/.m2/repository/org/springframework/boot/spring-boot-actuator-autoconfigure/2.7.17/spring-boot-actuator-autoconfigure-2.7.17.jar
file:/home/username/.m2/repository/org/springframework/boot/spring-boot-actuator/2.7.17/spring-boot-actuator-2.7.17.jar
file:/home/username/.m2/repository/io/micrometer/micrometer-core/1.9.16/micrometer-core-1.9.16.jar
file:/home/username/.m2/repository/org/hdrhistogram/HdrHistogram/2.1.12/HdrHistogram-2.1.12.jar
file:/home/username/.m2/repository/org/jolokia/jolokia-core/1.7.2/jolokia-core-1.7.2.jar
file:/home/username/.m2/repository/com/googlecode/json-simple/json-simple/1.1.1/json-simple-1.1.1.jar

So, as you might see there are no src/main/resources path among the paths list, thus resources files can't be found!

@rohanKanojia
Copy link
Member

Are you able to see application.yml file in file:/home/username/eclipse-workspace/jkube/quickstarts/maven/spring-boot/target/classes/ ?

I see this behavior. When I don't run mvn package before running mvn k8s:resource application.yml file is not copied to target/classes . The plugin expects the spring application.yml file to be present in this path, if it doesn't find this file it reverts to opinionted defaults.

When I do mvn package k8s:resource I'm able to see correct port being set in generated manfiests.

@arsenalzp
Copy link
Contributor

arsenalzp commented Apr 8, 2024

Are you able to see application.yml file in file:/home/username/eclipse-workspace/jkube/quickstarts/maven/spring-boot/target/classes/ ?

I see this behavior. When I don't run mvn package before running mvn k8s:resource application.yml file is not copied to target/classes . The plugin expects the spring application.yml file to be present in this path, if it doesn't find this file it reverts to opinionted defaults.

When I do mvn package k8s:resource I'm able to see correct port being set in generated manfiests.

Hello,
Yes, I see application.yml in target/classes which is copied by mvn package, however I guess this behavior is wrong, file application.yml must be processed by mvn k8s:resource from src/main/resources/ (shortly resources/) path without any advance preparation.

Otherwise, if command mvn package is required before mvn k8s:resource then no bug is observed here, just need to update doc and close the issue.

P.S.
I guess, my patch is bringing straightforward and independent way of generating K8S resources. Imagine user has medium or even big java project, user just need a simple k8s deployment resource for it, so to get it user has to run mvn package command before run mvn k8s:resource one, it leads to run over all preceding phases: validate, compile, test!

@manusa
Copy link
Member Author

manusa commented Apr 9, 2024

Otherwise, if command mvn package is required before mvn k8s:resource then no bug is observed here, just need to update doc and close the issue.

P.S. I guess, my patch is bringing straightforward and independent way of generating K8S resources. Imagine user has medium or even big java project, user just need a simple k8s deployment resource for it, so to get it user has to run mvn package command before run mvn k8s:resource one, it leads to run over all preceding phases: validate, compile, test!

The problem is that some projects perform filtering and transformation on src resources, that's why JKube considers the final classes, resources and artifacts as processed by the compile (and others) lifecycle goals.

It's also strange (in my opinion) that you want to generate the deployment file from the sources instead of the compiled files. [...]user just need a simple k8s deployment resource for it[...] I can't really think of a realistic use case where this would happen.

Regarding the issue itself, I'm not sure if this issue is also related to #2665

@arsenalzp
Copy link
Contributor

arsenalzp commented Apr 9, 2024

Thank you for your feedback, it is very appreciated.
Let's produce a decision here, if no bug is being observed then we can close this particular issue, otherwise I can put changes in my PR to reflect all your remarks and wishes which are necessary.
I'm ready to work!

@manusa
Copy link
Member Author

manusa commented Apr 9, 2024

As I see it:

Having a fallback to read resources from additional places might be an improvement to the user experience.
However, this brings in a set of additional problems:

  • Resources are not always located at src/main/resources
  • Users who post-process their resources might end up consuming wrong resources if they forget to process their resources prior to running the k8s:resource goal (i.e. the opposite of the problem you are reporting as part of this issue)

From my perspective, unless there's some specific scenario where this is providing a real benefit and we can overcome the aforementioned issues, then we should do it.

Otherwise, the only thing we can try to consider is providing extra-information about how the exposed port was inferred to help users that run into your same problem.

@arsenalzp
Copy link
Contributor

arsenalzp commented Apr 10, 2024

As I see it:

Having a fallback to read resources from additional places might be an improvement to the user experience. However, this brings in a set of additional problems:

* Resources are not always located at `src/main/resources`

* Users who post-process their resources might end up consuming wrong resources if they forget to process their resources prior to running the `k8s:resource` goal (i.e. the opposite of the problem you are reporting as part of this issue)

From my perspective, unless there's some specific scenario where this is providing a real benefit and we can overcome the aforementioned issues, then we should do it.

Otherwise, the only thing we can try to consider is providing extra-information about how the exposed port was inferred to help users that run into your same problem.

We can allow user to set up resource directory to consume resources from custom path (within project context dir, of course) by using configuration section for particular plugin in pom.xml.
However, src/main/resources path is pretty common among many Java project.

Anyway, working on this issue was very good experience for me to deep dive into this great project!

Decision is up to you, guys

@manusa
Copy link
Member Author

manusa commented Apr 11, 2024

However, src/main/resources path is pretty common among many Java project.

It's the default for Maven and usually for Gradle. However, you can define multiple resource directories, rename this directory (don't use its default location), add filtering capabilities, and so on. For example, in Maven, the Apache Maven Resources Plugin is responsible for all this (https://maven.apache.org/plugins/maven-resources-plugin/).

IMO the only thing we can do is try to add a helpful or debug message stating where/how was the application port inferred from, probably at the Generator level (will very likely require changes for each supported framework).

@arsenalzp
Copy link
Contributor

However, src/main/resources path is pretty common among many Java project.

It's the default for Maven and usually for Gradle. However, you can define multiple resource directories, rename this directory (don't use its default location), add filtering capabilities, and so on. For example, in Maven, the Apache Maven Resources Plugin is responsible for all this (https://maven.apache.org/plugins/maven-resources-plugin/).

IMO the only thing we can do is try to add a helpful or debug message stating where/how was the application port inferred from, probably at the Generator level (will very likely require changes for each supported framework).

Agree with you.
I can fix my code to reflect your remarks. So, I keep the current PR code, just gonna add debug message.
Does it sound good?

@arsenalzp
Copy link
Contributor

arsenalzp commented Apr 22, 2024

@manusa hello,
I've just added INFO message for demo purposes. I have feelings the last commit has a smell, however there are not so many opportunities and places in the code where properties file (application.yml or application.properties) could be set/get.

How output does look like now:

  1. with no package phase before
$ mvn k8s:resource -Pkubernetes -Djkube.generator.name="arsenalzp/spring-boot"
[INFO] Scanning for projects...
[INFO] 
[INFO] ----------< org.eclipse.jkube.quickstarts.maven:spring-boot >-----------
[INFO] Building Eclipse JKube :: Quickstarts :: Maven :: Spring Boot Web 1.17-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] --- kubernetes-maven-plugin:1.17-SNAPSHOT:resource (default-cli) @ spring-boot ---
[INFO] k8s: Running generator spring-boot
[INFO] k8s: spring-boot: Using Docker image quay.io/jkube/jkube-java:0.0.23 as base / builder
[INFO] k8s: The following properties file is used file:/home/username/eclipse-workspace/jkube/quickstarts/maven/spring-boot/src/main/resources/application.yml
[INFO] k8s: Using resource templates from /home/username/eclipse-workspace/jkube/quickstarts/maven/spring-boot/src/main/jkube
[INFO] k8s: jkube-controller: Adding a default Deployment
[INFO] k8s: jkube-service: Adding a default service 'spring-boot' with ports [8082]
[INFO] k8s: jkube-healthcheck-spring-boot: Adding readiness probe on port 8082, path='/actuator/health', scheme='HTTP', with initial delay 10 seconds
[INFO] k8s: jkube-healthcheck-spring-boot: Adding liveness probe on port 8082, path='/actuator/health', scheme='HTTP', with initial delay 180 seconds
[INFO] k8s: jkube-service-discovery: Using first mentioned service port '8082' 
[INFO] k8s: jkube-revision-history: Adding revision history limit to 2
[WARNING] k8s: jkube-git: Could not detect any git remote
[WARNING] k8s: jkube-git: Could not detect any git remote
[WARNING] k8s: jkube-git: Could not detect any git remote
[WARNING] k8s: jkube-git: Could not detect any git remote
[WARNING] k8s: jkube-git: Could not detect any git remote
[WARNING] k8s: jkube-git: Could not detect any git remote
[INFO] k8s: validating /home/username/eclipse-workspace/jkube/quickstarts/maven/spring-boot/target/classes/META-INF/jkube/kubernetes/spring-boot-service.yml resource
[INFO] k8s: validating /home/username/eclipse-workspace/jkube/quickstarts/maven/spring-boot/target/classes/META-INF/jkube/kubernetes/spring-boot-deployment.yml resource
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  4.538 s
[INFO] Finished at: 2024-04-22T20:45:37+03:00
[INFO] ------------------------------------------------------------------------
$
  1. after the package phase
$ mvn k8s:resource -Pkubernetes -Djkube.generator.name="arsenalzp/spring-boot"
[INFO] Scanning for projects...
[INFO] 
[INFO] ----------< org.eclipse.jkube.quickstarts.maven:spring-boot >-----------
[INFO] Building Eclipse JKube :: Quickstarts :: Maven :: Spring Boot Web 1.17-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] --- kubernetes-maven-plugin:1.17-SNAPSHOT:resource (default-cli) @ spring-boot ---
[INFO] k8s: Running generator spring-boot
[INFO] k8s: spring-boot: Using Docker image quay.io/jkube/jkube-java:0.0.23 as base / builder
[INFO] k8s: The following properties file is used file:/home/username/eclipse-workspace/jkube/quickstarts/maven/spring-boot/target/classes/application.yml
[INFO] k8s: Using resource templates from /home/username/eclipse-workspace/jkube/quickstarts/maven/spring-boot/src/main/jkube
[INFO] k8s: jkube-controller: Adding a default Deployment
[INFO] k8s: jkube-service: Adding a default service 'spring-boot' with ports [8082]
[INFO] k8s: jkube-healthcheck-spring-boot: Adding readiness probe on port 8082, path='/actuator/health', scheme='HTTP', with initial delay 10 seconds
[INFO] k8s: jkube-healthcheck-spring-boot: Adding liveness probe on port 8082, path='/actuator/health', scheme='HTTP', with initial delay 180 seconds
[INFO] k8s: jkube-service-discovery: Using first mentioned service port '8082' 
[INFO] k8s: jkube-revision-history: Adding revision history limit to 2
[WARNING] k8s: jkube-git: Could not detect any git remote
[WARNING] k8s: jkube-git: Could not detect any git remote
[WARNING] k8s: jkube-git: Could not detect any git remote
[WARNING] k8s: jkube-git: Could not detect any git remote
[WARNING] k8s: jkube-git: Could not detect any git remote
[WARNING] k8s: jkube-git: Could not detect any git remote
[INFO] k8s: validating /home/username/eclipse-workspace/jkube/quickstarts/maven/spring-boot/target/classes/META-INF/jkube/kubernetes/spring-boot-service.yml resource
[INFO] k8s: validating /home/username/eclipse-workspace/jkube/quickstarts/maven/spring-boot/target/classes/META-INF/jkube/kubernetes/spring-boot-deployment.yml resource
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  4.544 s
[INFO] Finished at: 2024-04-22T20:50:13+03:00
[INFO] ------------------------------------------------------------------------
$

@rohanKanojia
Copy link
Member

@arsenalzp : Hello, I'm assuming you're running this in quickstarts/maven/spring-boot. I tried running mvn k8s:resource -Djkube.version=1.17-SNAPSHOT but couldn't reproduce the issue. My Git remote is in the following format:

$ git remote -v
origin  git@github.com:rohanKanojia/jkube.git (fetch)
origin  git@github.com:rohanKanojia/jkube.git (push)

This warning is coming from GitEnricher when JKube tries to add git annotations to generated Kubernetes manifests:


Somehow in your case gitRemoteUrl is coming as null

@arsenalzp
Copy link
Contributor

arsenalzp commented Apr 22, 2024

@arsenalzp : Hello, I'm assuming you're running this in quickstarts/maven/spring-boot. I tried running mvn k8s:resource -Djkube.version=1.17-SNAPSHOT but couldn't reproduce the issue. My Git remote is in the following format:

$ git remote -v
origin  git@github.com:rohanKanojia/jkube.git (fetch)
origin  git@github.com:rohanKanojia/jkube.git (push)

This warning is coming from GitEnricher when JKube tries to add git annotations to generated Kubernetes manifests:

Somehow in your case gitRemoteUrl is coming as null

Hello,
Thank you for your feedback.
Yes, I'm playing with quickstarts/maven/spring-boot.
I just updated pom.xml file to use updated version I work for:

  <artifactId>spring-boot</artifactId>
  <version>1.17-SNAPSHOT</version>
  <name>Eclipse JKube :: Quickstarts :: Maven :: Spring Boot Web</name>
  <packaging>jar</packaging>

@rohanKanojia
Copy link
Member

@arsenalzp : Is it possible for you to set a breakpoint in GitEnricher and run mvnDebug k8s:resource , it would start a remove JVM debug sesssion; You can connect via your IDE and go step by step to see what's actually happening in your case.

@arsenalzp
Copy link
Contributor

arsenalzp commented Apr 22, 2024

@arsenalzp : Is it possible for you to set a breakpoint in GitEnricher and run mvnDebug k8s:resource , it would start a remove JVM debug sesssion; You can connect via your IDE and go step by step to see what's actually happening in your case.

I'm doing exact the same.

Here is snapshot of code state:

image

The warning is showing up because the remote repository is named differently than code is looking for.

$ git remote -v
micronaut4      git@github.com:arsenalzp/jkube.git (fetch)
micronaut4      git@github.com:arsenalzp/jkube.git (push)
$

Once it was renamed to original an error has gone.

@arsenalzp
Copy link
Contributor

Hello colleagues,
I would appreciate any feedback/remarks on my PR. Any kind of feedback is very appreciated!

@rohanKanojia
Copy link
Member

rohanKanojia commented Apr 25, 2024

@arsenalzp : Thanks for taking time to look into this! I now understand that you're getting the error due to your remote name micronaut4 .
In GitEnricher, it only expects remote name to be origin. Custom remote names need to be configured via jkube.remoteName property.

String gitRemote = getContext().getProperty(GIT_REMOTE);
gitRemote = gitRemote == null ? "origin" : gitRemote;
return repository.getConfig().getString("remote", gitRemote, "url");
}

@arsenalzp
Copy link
Contributor

arsenalzp commented Apr 25, 2024

@arsenalzp : Thanks for taking time to look into this! I now understand that you're getting the error due to your remote name micronaut4 . In GitEnricher, it only expects remote name to be origin. Custom remote names need to be configured via jkube.remoteName property.

String gitRemote = getContext().getProperty(GIT_REMOTE);
gitRemote = gitRemote == null ? "origin" : gitRemote;
return repository.getConfig().getString("remote", gitRemote, "url");
}

Yes, it was fixed, thank you!
It's necessary to decide what to do with original issue and PR which was promoted.
I was asked to bring a debug message about which properties file is used: either from target/classes/ or src/main/resources/ locations - it was done, however I feel there is side effect in the code I brought. Any feedback and remarks are appreciated, I'm ready to work!

@rohanKanojia
Copy link
Member

@arsenalzp : I think it's okay to create a draft PR so that the team can also check.

@arsenalzp
Copy link
Contributor

@arsenalzp : I think it's okay to create a draft PR so that the team can also check.

Could this PR #2880 be converted to draft one?

What was done:

  1. take into account src/main/resources path where spring-boot application properties files are put in.
  2. print info message which path was taken: either target/classes/ or src/main/resources/

@rohanKanojia
Copy link
Member

@arsenalzp : I'll try to check your PR later today.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants