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 2024/02/13 18:00:59 UTC

(camel-karavan) branch main updated (15211937 -> 88de999f)

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 15211937 Fix error in container has no port
     new 08b11db4 Docker statistic collection issue fixed
     new 88de999f Fix #1122

The 2 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:
 .../apache/camel/karavan/docker/DockerService.java |  7 +++++
 .../karavan/service/ContainerStatusService.java    | 16 +++++++++--
 .../webui/src/project/files/DeleteFileModal.tsx    | 15 +++++++---
 .../main/webui/src/projects/DeleteProjectModal.tsx | 32 ++++++++++++++--------
 4 files changed, 52 insertions(+), 18 deletions(-)


(camel-karavan) 02/02: Fix #1122

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 88de999f0dc0abd51d1f094d74ce847efb44458d
Author: Marat Gubaidullin <ma...@talismancloud.io>
AuthorDate: Tue Feb 13 13:00:49 2024 -0500

    Fix #1122
---
 .../webui/src/project/files/DeleteFileModal.tsx    | 15 +++++++---
 .../main/webui/src/projects/DeleteProjectModal.tsx | 32 ++++++++++++++--------
 2 files changed, 32 insertions(+), 15 deletions(-)

diff --git a/karavan-web/karavan-app/src/main/webui/src/project/files/DeleteFileModal.tsx b/karavan-web/karavan-app/src/main/webui/src/project/files/DeleteFileModal.tsx
index 05635cee..c89ba0ad 100644
--- a/karavan-web/karavan-app/src/main/webui/src/project/files/DeleteFileModal.tsx
+++ b/karavan-web/karavan-app/src/main/webui/src/project/files/DeleteFileModal.tsx
@@ -17,9 +17,9 @@
 
 import React from 'react';
 import {
-    Button,
+    Button, HelperText, HelperTextItem,
     Modal,
-    ModalVariant,
+    ModalVariant, Text, TextContent, TextVariants,
 } from '@patternfly/react-core';
 import '../../designer/karavan.css';
 import {useFileStore} from "../../api/ProjectStore";
@@ -46,12 +46,19 @@ export function DeleteFileModal () {
                 isOpen={isOpen}
                 onClose={() => closeModal()}
                 actions={[
-                    <Button key="confirm" variant="primary" onClick={e => confirmAndCloseModal()}>Delete</Button>,
+                    <Button key="confirm" variant="danger" onClick={e => confirmAndCloseModal()}>Delete</Button>,
                     <Button key="cancel" variant="link"
                             onClick={e => closeModal()}>Cancel</Button>
                 ]}
                 onEscapePress={e => closeModal()}>
-                <div>{"Are you sure you want to delete file " + file?.name + "?"}</div>
+                <TextContent>
+                    <Text component={TextVariants.h3}>Delete file <b>{file?.name}</b> ?</Text>
+                    <HelperText>
+                        <HelperTextItem variant="warning">
+                            File will be also deleted from <b>git</b> repository
+                        </HelperTextItem>
+                    </HelperText>
+                </TextContent>
             </Modal>
     )
 }
\ No newline at end of file
diff --git a/karavan-web/karavan-app/src/main/webui/src/projects/DeleteProjectModal.tsx b/karavan-web/karavan-app/src/main/webui/src/projects/DeleteProjectModal.tsx
index 574486cb..ce80c9f2 100644
--- a/karavan-web/karavan-app/src/main/webui/src/projects/DeleteProjectModal.tsx
+++ b/karavan-web/karavan-app/src/main/webui/src/projects/DeleteProjectModal.tsx
@@ -17,13 +17,14 @@
 
 import React, {useState} from 'react';
 import {
-    Button,
+    Button, HelperText, HelperTextItem,
     Modal,
-    ModalVariant, Switch,
+    ModalVariant, Switch, Text, TextContent, TextVariants,
 } from '@patternfly/react-core';
 import '../designer/karavan.css';
 import {useProjectStore} from "../api/ProjectStore";
 import {ProjectService} from "../api/ProjectService";
+import ExclamationIcon from '@patternfly/react-icons/dist/esm/icons/exclamation-icon';
 
 export function DeleteProjectModal () {
 
@@ -42,23 +43,32 @@ export function DeleteProjectModal () {
     const isOpen= operation === "delete";
     return (
             <Modal
-                title="Project delete confirmation"
+                title="Confirmation"
                 variant={ModalVariant.small}
                 isOpen={isOpen}
                 onClose={() => closeModal()}
                 actions={[
-                    <Button key="confirm" variant="primary" onClick={e => confirmAndCloseModal()}>Delete</Button>,
+                    <Button key="confirm" variant="danger" onClick={e => confirmAndCloseModal()}>Delete</Button>,
                     <Button key="cancel" variant="link"
                             onClick={e => closeModal()}>Cancel</Button>
                 ]}
                 onEscapePress={e => closeModal()}>
-                {/*<div>{"Are you sure you want to delete the project " + project?.projectId + "?"}</div>*/}
-                <Switch
-                    label={"Delete container and/or deployments?"}
-                    isChecked={deleteContainers}
-                    onChange={(_, checked) => setDeleteContainers(checked)}
-                    isReversed
-                />
+                    <TextContent>
+                        <Text component={TextVariants.h3}>Delete project <b>{project?.projectId}</b> ?</Text>
+                        <HelperText>
+                            <HelperTextItem variant="warning">
+                                Project will be also deleted from <b>git</b> repository
+                            </HelperTextItem>
+                        </HelperText>
+                        <Text component={TextVariants.p}></Text>
+                        <Text component={TextVariants.p}></Text>
+                    </TextContent>
+                    <Switch
+                        label={"Delete related container and/or deployments?"}
+                        isChecked={deleteContainers}
+                        onChange={(_, checked) => setDeleteContainers(checked)}
+                        isReversed
+                    />
             </Modal>
     )
 }
\ No newline at end of file


(camel-karavan) 01/02: Docker statistic collection issue fixed

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 08b11db48d25c0a3d6876a25b8bce609758a83cf
Author: Marat Gubaidullin <ma...@talismancloud.io>
AuthorDate: Tue Feb 13 12:37:43 2024 -0500

    Docker statistic collection issue fixed
---
 .../org/apache/camel/karavan/docker/DockerService.java   |  7 +++++++
 .../camel/karavan/service/ContainerStatusService.java    | 16 +++++++++++++---
 2 files changed, 20 insertions(+), 3 deletions(-)

diff --git a/karavan-web/karavan-app/src/main/java/org/apache/camel/karavan/docker/DockerService.java b/karavan-web/karavan-app/src/main/java/org/apache/camel/karavan/docker/DockerService.java
index 776e5f58..7b8efdc4 100644
--- a/karavan-web/karavan-app/src/main/java/org/apache/camel/karavan/docker/DockerService.java
+++ b/karavan-web/karavan-app/src/main/java/org/apache/camel/karavan/docker/DockerService.java
@@ -117,6 +117,13 @@ public class DockerService extends DockerServiceUtils {
         return result;
     }
 
+    public ContainerStatus collectContainerStatistics(ContainerStatus containerStatus) {
+        Container container = getContainerByName(containerStatus.getContainerName());
+        Statistics stats = getContainerStats(container.getId());
+        updateStatistics(containerStatus, stats);
+        return containerStatus;
+    }
+
     public void startListeners() {
         getDockerClient().eventsCmd().exec(dockerEventListener);
     }
diff --git a/karavan-web/karavan-app/src/main/java/org/apache/camel/karavan/service/ContainerStatusService.java b/karavan-web/karavan-app/src/main/java/org/apache/camel/karavan/service/ContainerStatusService.java
index e8d34d20..1f54a52e 100644
--- a/karavan-web/karavan-app/src/main/java/org/apache/camel/karavan/service/ContainerStatusService.java
+++ b/karavan-web/karavan-app/src/main/java/org/apache/camel/karavan/service/ContainerStatusService.java
@@ -38,6 +38,7 @@ import java.util.Objects;
 public class ContainerStatusService {
 
     public static final String CONTAINER_STATUS = "CONTAINER_STATUS";
+    public static final String CONTAINER_STATISTIC = "CONTAINER_STATISTIC";
     public static final String CONTAINER_DELETED = "CONTAINER_DELETED";
     private static final Logger LOGGER = Logger.getLogger(ContainerStatusService.class.getName());
     @ConfigProperty(name = "karavan.environment")
@@ -55,13 +56,22 @@ public class ContainerStatusService {
     @Scheduled(every = "{karavan.container.statistics.interval}", concurrentExecution = Scheduled.ConcurrentExecution.SKIP)
     void collectContainersStatistics() {
         if (karavanCacheService.isReady() && !ConfigService.inKubernetes()) {
-            List<ContainerStatus> statusesInDocker = dockerService.collectContainersStatistics();
+            List<ContainerStatus> statusesInDocker = dockerService.collectContainersStatuses();
             statusesInDocker.forEach(containerStatus -> {
-                eventBus.publish(ContainerStatusService.CONTAINER_STATUS, JsonObject.mapFrom(containerStatus));
+                eventBus.publish(ContainerStatusService.CONTAINER_STATISTIC, JsonObject.mapFrom(containerStatus));
             });
         }
     }
 
+    @ConsumeEvent(value = CONTAINER_STATISTIC, blocking = true, ordered = false)
+    void collectContainersStatistics(JsonObject data) {
+        if (karavanCacheService.isReady()) {
+            ContainerStatus status = data.mapTo(ContainerStatus.class);
+            ContainerStatus newStatus = dockerService.collectContainerStatistics(status);
+            eventBus.publish(ContainerStatusService.CONTAINER_STATUS, JsonObject.mapFrom(newStatus));
+        }
+    }
+
     @Scheduled(every = "{karavan.container.status.interval}", concurrentExecution = Scheduled.ConcurrentExecution.SKIP)
     void collectContainersStatuses() {
         if (karavanCacheService.isReady() && !ConfigService.inKubernetes()) {
@@ -126,7 +136,7 @@ public class ContainerStatusService {
                 return;
             }
         }
-        if (newStatus.getCpuInfo() == null || newStatus.getCpuInfo().isEmpty()) {
+        if (newStatus.getCpuInfo() == null || newStatus.getCpuInfo().isBlank()) {
             newStatus.setCpuInfo(oldStatus.getCpuInfo());
             newStatus.setMemoryInfo(oldStatus.getMemoryInfo());
         }