This is an automated email from the ASF dual-hosted git repository.

cdeppisch pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/main by this push:
     new afd0efb715f chore(camel-jbang): Fix dev mode in Kubernetes run command
afd0efb715f is described below

commit afd0efb715f186532d3476503a679ffdfd2cfe18
Author: Christoph Deppisch <[email protected]>
AuthorDate: Thu Sep 5 15:31:07 2024 +0200

    chore(camel-jbang): Fix dev mode in Kubernetes run command
    
    - File watch directory has been set to "null" by accident when running a 
single source file
    - Avoid to lose pod log tracker when pods are terminating due to deployment 
update
---
 .../dsl/jbang/core/commands/kubernetes/KubernetesRun.java   | 13 ++++++++++---
 .../camel/dsl/jbang/core/commands/kubernetes/PodLogs.java   |  3 +--
 2 files changed, 11 insertions(+), 5 deletions(-)

diff --git 
a/dsl/camel-jbang/camel-jbang-plugin-kubernetes/src/main/java/org/apache/camel/dsl/jbang/core/commands/kubernetes/KubernetesRun.java
 
b/dsl/camel-jbang/camel-jbang-plugin-kubernetes/src/main/java/org/apache/camel/dsl/jbang/core/commands/kubernetes/KubernetesRun.java
index df7eff9e149..b1dd1092c71 100644
--- 
a/dsl/camel-jbang/camel-jbang-plugin-kubernetes/src/main/java/org/apache/camel/dsl/jbang/core/commands/kubernetes/KubernetesRun.java
+++ 
b/dsl/camel-jbang/camel-jbang-plugin-kubernetes/src/main/java/org/apache/camel/dsl/jbang/core/commands/kubernetes/KubernetesRun.java
@@ -309,7 +309,7 @@ public class KubernetesRun extends KubernetesBaseCommand {
 
         if (dev) {
             DefaultCamelContext reloadContext = new DefaultCamelContext(false);
-            configureFileWatch(reloadContext, export, workingDir);
+            configureFileWatch(reloadContext, workingDir);
             reloadContext.start();
 
             if (cleanup) {
@@ -506,12 +506,15 @@ public class KubernetesRun extends KubernetesBaseCommand {
         return 0;
     }
 
-    private void configureFileWatch(DefaultCamelContext camelContext, 
KubernetesExport export, String workingDir)
+    private void configureFileWatch(DefaultCamelContext camelContext, String 
workingDir)
             throws Exception {
         String watchDir = ".";
         FileFilter filter = null;
         if (filePaths != null && filePaths.length > 0) {
-            watchDir = FileUtil.onlyPath(SourceScheme.onlyName(filePaths[0]));
+            String filePath = 
FileUtil.onlyPath(SourceScheme.onlyName(filePaths[0]));
+            if (filePath != null) {
+                watchDir = filePath;
+            }
 
             filter = pathname -> Arrays.stream(filePaths)
                     .map(FileUtil::stripPath)
@@ -522,6 +525,7 @@ public class KubernetesRun extends KubernetesBaseCommand {
                 = new FileWatcherResourceReloadStrategy(watchDir);
         reloadStrategy.setResourceReload((name, resource) -> {
             printer().printf("Reloading project due to file change: %s%n", 
FileUtil.stripPath(name));
+            KubernetesExport export = configureExport(workingDir);
             int refresh = export.export();
             if (refresh == 0) {
                 if (RuntimeType.quarkus == runtime) {
@@ -529,6 +533,9 @@ public class KubernetesRun extends KubernetesBaseCommand {
                 } else if (RuntimeType.springBoot == runtime) {
                     deploySpringBoot(workingDir);
                 }
+            } else {
+                // print export command output with error details
+                printer().printf("Reloading project failed - export failed 
with code: %d%n", refresh);
             }
         });
         if (filter != null) {
diff --git 
a/dsl/camel-jbang/camel-jbang-plugin-kubernetes/src/main/java/org/apache/camel/dsl/jbang/core/commands/kubernetes/PodLogs.java
 
b/dsl/camel-jbang/camel-jbang-plugin-kubernetes/src/main/java/org/apache/camel/dsl/jbang/core/commands/kubernetes/PodLogs.java
index ec29274f7d0..d55ccf85376 100644
--- 
a/dsl/camel-jbang/camel-jbang-plugin-kubernetes/src/main/java/org/apache/camel/dsl/jbang/core/commands/kubernetes/PodLogs.java
+++ 
b/dsl/camel-jbang/camel-jbang-plugin-kubernetes/src/main/java/org/apache/camel/dsl/jbang/core/commands/kubernetes/PodLogs.java
@@ -148,9 +148,8 @@ public class PodLogs extends KubernetesBaseCommand {
             }
         } catch (IOException e) {
             printer().println("Failed to read pod logs - " + e.getMessage());
-            return false;
         }
 
-        return resumeCount < 10;
+        return resumeCount < 25;
     }
 }

Reply via email to