You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ma...@apache.org on 2023/07/04 15:18:24 UTC

[camel-karavan] branch main updated (d78c9cbd -> 75732c34)

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

marat pushed a change to branch main
in repository https://gitbox.apache.org/repos/asf/camel-karavan.git


    from d78c9cbd Set cache for jbang maven #757
     new d97ff0fd Volume for #757
     new 630656eb JBANG_OPTIONS for #757
     new 75732c34 JBANG_OPTIONS for #757

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../java/org/apache/camel/karavan/api/RunnerResource.java  | 12 ++++++++++--
 .../apache/camel/karavan/service/KubernetesService.java    |  9 ++++++---
 karavan-app/src/main/webui/src/api/KaravanApi.tsx          |  4 ++--
 karavan-app/src/main/webui/src/api/ProjectService.ts       |  4 ++--
 karavan-app/src/main/webui/src/project/RunnerToolbar.tsx   | 14 +++++++++++---
 karavan-runner/Dockerfile                                  |  2 +-
 6 files changed, 32 insertions(+), 13 deletions(-)


[camel-karavan] 02/03: JBANG_OPTIONS for #757

Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 630656ebb6644a4a644873e4e48be647a1c8eca1
Author: Marat Gubaidullin <ma...@gmail.com>
AuthorDate: Tue Jul 4 11:04:55 2023 -0400

    JBANG_OPTIONS for #757
---
 karavan-runner/Dockerfile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/karavan-runner/Dockerfile b/karavan-runner/Dockerfile
index c492b6d8..fcea9abd 100644
--- a/karavan-runner/Dockerfile
+++ b/karavan-runner/Dockerfile
@@ -15,4 +15,4 @@ RUN mkdir -p $CODE_DIR \
 
 EXPOSE 8080
 
-ENTRYPOINT jbang --verbose -Dcamel.jbang.version=$CAMEL_VERSION camel@apache/camel run --source-dir=$CODE_DIR --console --local-kamelet-dir=$KAMELETS_DIR --maven-settings=$MAVEN_SETTINGS
\ No newline at end of file
+ENTRYPOINT jbang $JBANG_OPTIONS -Dcamel.jbang.version=$CAMEL_VERSION camel@apache/camel run --source-dir=$CODE_DIR --console --local-kamelet-dir=$KAMELETS_DIR --maven-settings=$MAVEN_SETTINGS
\ No newline at end of file


[camel-karavan] 03/03: JBANG_OPTIONS for #757

Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 75732c34c1149139c1ca67d0cad3b562067704ae
Author: Marat Gubaidullin <ma...@gmail.com>
AuthorDate: Tue Jul 4 11:18:15 2023 -0400

    JBANG_OPTIONS for #757
---
 .../java/org/apache/camel/karavan/api/RunnerResource.java  | 12 ++++++++++--
 .../apache/camel/karavan/service/KubernetesService.java    |  7 ++++---
 karavan-app/src/main/webui/src/api/KaravanApi.tsx          |  4 ++--
 karavan-app/src/main/webui/src/api/ProjectService.ts       |  4 ++--
 karavan-app/src/main/webui/src/project/RunnerToolbar.tsx   | 14 +++++++++++---
 5 files changed, 29 insertions(+), 12 deletions(-)

diff --git a/karavan-app/src/main/java/org/apache/camel/karavan/api/RunnerResource.java b/karavan-app/src/main/java/org/apache/camel/karavan/api/RunnerResource.java
index 52f985bc..b728f7f4 100644
--- a/karavan-app/src/main/java/org/apache/camel/karavan/api/RunnerResource.java
+++ b/karavan-app/src/main/java/org/apache/camel/karavan/api/RunnerResource.java
@@ -57,17 +57,25 @@ public class RunnerResource {
     @POST
     @Produces(MediaType.APPLICATION_JSON)
     @Consumes(MediaType.APPLICATION_JSON)
-    public Response runProject(Project project) {
+    @Path("/{jBangOptions}")
+    public Response runProjectWithJBangOptions(Project project, @PathParam("jBangOptions") String jBangOptions) {
         String runnerName = project.getProjectId() + "-" + RUNNER_SUFFIX;
         String status = infinispanService.getRunnerStatus(runnerName, RunnerStatus.NAME.context);
         if (status == null) {
             Project p = infinispanService.getProject(project.getProjectId());
             infinispanService.saveRunnerStatus(runnerName, STATUS_NEED_INITIAL_LOAD, STATUS_NEED_INITIAL_LOAD);
-            return Response.ok(kubernetesService.tryCreateRunner(p, runnerName)).build();
+            return Response.ok(kubernetesService.tryCreateRunner(p, runnerName, jBangOptions)).build();
         }
         return Response.notModified().build();
     }
 
+    @POST
+    @Produces(MediaType.APPLICATION_JSON)
+    @Consumes(MediaType.APPLICATION_JSON)
+    public Response runProject(Project project) {
+        return runProjectWithJBangOptions(project, "");
+    }
+
     @GET
     @Produces(MediaType.APPLICATION_JSON)
     @Path("/reload/{projectId}")
diff --git a/karavan-app/src/main/java/org/apache/camel/karavan/service/KubernetesService.java b/karavan-app/src/main/java/org/apache/camel/karavan/service/KubernetesService.java
index d5b3b7e1..cc538db7 100644
--- a/karavan-app/src/main/java/org/apache/camel/karavan/service/KubernetesService.java
+++ b/karavan-app/src/main/java/org/apache/camel/karavan/service/KubernetesService.java
@@ -386,14 +386,14 @@ public class KubernetesService implements HealthCheck{
         return result;
     }
 
-    public String tryCreateRunner(Project project, String runnerName) {
+    public String tryCreateRunner(Project project, String runnerName, String jBangOptions) {
         createPVC(runnerName);
         Pod old = kubernetesClient().pods().inNamespace(getNamespace()).withName(runnerName).get();
         if (old == null) {
             ProjectFile properties = infinispanService.getProjectFile(project.getProjectId(), APPLICATION_PROPERTIES_FILENAME);
             Map<String,String> containerResources = ServiceUtil
                     .getRunnerContainerResourcesMap(properties, isOpenshift(), project.getRuntime().equals("quarkus"));
-            Pod pod = getRunnerPod(project.getProjectId(), runnerName, containerResources);
+            Pod pod = getRunnerPod(project.getProjectId(), runnerName, jBangOptions, containerResources);
             Pod result = kubernetesClient().resource(pod).createOrReplace();
             LOGGER.info("Created pod " + result.getMetadata().getName());
         }
@@ -423,7 +423,7 @@ public class KubernetesService implements HealthCheck{
                 .build();
     }
 
-    private Pod getRunnerPod(String projectId, String name, Map<String,String> containerResources) {
+    private Pod getRunnerPod(String projectId, String name, String jbangOptions, Map<String,String> containerResources) {
         Map<String,String> labels = new HashMap<>();
         labels.putAll(getRuntimeLabels());
         labels.putAll(getKaravanRunnerLabels(name));
@@ -449,6 +449,7 @@ public class KubernetesService implements HealthCheck{
                 .withPorts(port)
                 .withResources(resources)
                 .withImagePullPolicy("Always")
+                .withEnv(new EnvVarBuilder().withName("JBANG_OPTIONS").withValue(jbangOptions).build())
                 .withVolumeMounts(
                         new VolumeMountBuilder().withName(name).withMountPath("/karavan/.jbang/cache").build(),
                         new VolumeMountBuilder().withName("maven-settings").withSubPath("maven-settings.xml")
diff --git a/karavan-app/src/main/webui/src/api/KaravanApi.tsx b/karavan-app/src/main/webui/src/api/KaravanApi.tsx
index f29f453b..c4358fd5 100644
--- a/karavan-app/src/main/webui/src/api/KaravanApi.tsx
+++ b/karavan-app/src/main/webui/src/api/KaravanApi.tsx
@@ -330,8 +330,8 @@ export class KaravanApi {
         });
     }
 
-    static async runProject(project: Project, after: (res: AxiosResponse<string>) => void) {
-        instance.post('/api/runner', project)
+    static async runProject(project: Project, verbose: boolean, after: (res: AxiosResponse<string>) => void) {
+        instance.post('/api/runner' + (verbose ? '/-verbose' : ''), project)
             .then(res => {
                 after(res);
             }).catch(err => {
diff --git a/karavan-app/src/main/webui/src/api/ProjectService.ts b/karavan-app/src/main/webui/src/api/ProjectService.ts
index f4bb71ec..204a9cf2 100644
--- a/karavan-app/src/main/webui/src/api/ProjectService.ts
+++ b/karavan-app/src/main/webui/src/api/ProjectService.ts
@@ -15,9 +15,9 @@ import {ProjectEventBus} from "./ProjectEventBus";
 
 export class ProjectService {
 
-    public static startRunner(project: Project) {
+    public static startRunner(project: Project, verbose: boolean) {
         useRunnerStore.setState({status: "starting"})
-        KaravanApi.runProject(project, res => {
+        KaravanApi.runProject(project, verbose, res => {
             if (res.status === 200 || res.status === 201) {
                 ProjectEventBus.sendLog("set", '');
                 useLogStore.setState({showLog: true, type: 'container', podName: res.data})
diff --git a/karavan-app/src/main/webui/src/project/RunnerToolbar.tsx b/karavan-app/src/main/webui/src/project/RunnerToolbar.tsx
index 1594c7c0..6d2f0d11 100644
--- a/karavan-app/src/main/webui/src/project/RunnerToolbar.tsx
+++ b/karavan-app/src/main/webui/src/project/RunnerToolbar.tsx
@@ -1,6 +1,6 @@
-import React from 'react';
+import React, {useState} from 'react';
 import {
-    Button, FlexItem,
+    Button, FlexItem, Switch,
     Tooltip,
     TooltipPosition
 } from '@patternfly/react-core';
@@ -21,6 +21,7 @@ export const RunnerToolbar = (props: Props) => {
 
     const [status] = useRunnerStore((state) => [state.status], shallow )
     const [project] = useProjectStore((state) => [state.project], shallow )
+    const [verbose, setVerbose] = useState(false);
 
     const isRunning = status === "running";
     const isStartingPod = status === "starting";
@@ -39,6 +40,13 @@ export const RunnerToolbar = (props: Props) => {
                 </Button>
             </Tooltip>
         </FlexItem>}
+        {!isRunning && !isReloadingPod && props.reloadOnly !== true && <FlexItem>
+            <Switch aria-label="refresh"
+                    id="refresh"
+                    isChecked={verbose}
+                    onChange={checked => setVerbose(checked)}
+            />
+        </FlexItem>}
         {!isRunning && !isReloadingPod && props.reloadOnly !== true && <FlexItem>
             <Tooltip content="Run in development mode" position={TooltipPosition.bottom}>
                 <Button isLoading={isStartingPod ? true : undefined}
@@ -46,7 +54,7 @@ export const RunnerToolbar = (props: Props) => {
                         variant={"primary"}
                         className="project-button"
                         icon={!isStartingPod ? <RocketIcon/> : <div></div>}
-                        onClick={() => ProjectService.startRunner(project)}>
+                        onClick={() => ProjectService.startRunner(project, verbose)}>
                     {isStartingPod ? "..." : "Run"}
                 </Button>
             </Tooltip>


[camel-karavan] 01/03: Volume for #757

Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit d97ff0fd5e20b994a14364e3405dd43b5ce2aaac
Author: Marat Gubaidullin <ma...@gmail.com>
AuthorDate: Tue Jul 4 11:04:30 2023 -0400

    Volume for #757
---
 .../main/java/org/apache/camel/karavan/service/KubernetesService.java   | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/karavan-app/src/main/java/org/apache/camel/karavan/service/KubernetesService.java b/karavan-app/src/main/java/org/apache/camel/karavan/service/KubernetesService.java
index 14bbcc4d..d5b3b7e1 100644
--- a/karavan-app/src/main/java/org/apache/camel/karavan/service/KubernetesService.java
+++ b/karavan-app/src/main/java/org/apache/camel/karavan/service/KubernetesService.java
@@ -460,6 +460,8 @@ public class KubernetesService implements HealthCheck{
                 .withContainers(container)
                 .withRestartPolicy("Never")
                 .withVolumes(
+                        new VolumeBuilder().withName(name)
+                                .withNewPersistentVolumeClaim(name, false).build(),
                         new VolumeBuilder().withName("maven-settings")
                                 .withConfigMap(new ConfigMapVolumeSourceBuilder()
                                         .withName("karavan").build()).build())