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/03/09 14:07:09 UTC

[camel-karavan] branch main updated: Backend for #662

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


The following commit(s) were added to refs/heads/main by this push:
     new e94b9804 Backend for #662
e94b9804 is described below

commit e94b9804f8ebedad1696a0de9235d65163b12a7e
Author: Marat Gubaidullin <ma...@gmail.com>
AuthorDate: Thu Mar 9 09:06:12 2023 -0500

    Backend for #662
---
 .../camel/karavan/service/KubernetesService.java      | 19 +++++++++++++++++++
 1 file changed, 19 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 796dbfc3..99b6e135 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
@@ -16,6 +16,7 @@
  */
 package org.apache.camel.karavan.service;
 
+import io.fabric8.knative.internal.pkg.apis.Condition;
 import io.fabric8.kubernetes.api.model.ObjectMeta;
 import io.fabric8.kubernetes.api.model.ObjectMetaBuilder;
 import io.fabric8.kubernetes.api.model.Pod;
@@ -36,6 +37,8 @@ import io.fabric8.tekton.pipeline.v1beta1.PipelineRun;
 import io.fabric8.tekton.pipeline.v1beta1.PipelineRunBuilder;
 import io.fabric8.tekton.pipeline.v1beta1.PipelineRunSpec;
 import io.fabric8.tekton.pipeline.v1beta1.PipelineRunSpecBuilder;
+import io.fabric8.tekton.pipeline.v1beta1.PipelineRunStatus;
+import io.fabric8.tekton.pipeline.v1beta1.PipelineRunStatusBuilder;
 import io.fabric8.tekton.pipeline.v1beta1.WorkspaceBindingBuilder;
 import io.quarkus.vertx.ConsumeEvent;
 import io.vertx.mutiny.core.eventbus.EventBus;
@@ -221,6 +224,22 @@ public class KubernetesService {
                 .findFirst().get();
     }
 
+    public void stopPipelineRun(String pipelineRunName, String namespace) {
+        try {
+            LOGGER.info("Stop PipelineRun: " + pipelineRunName + " in the namespace: " + namespace);
+
+            PipelineRun run = tektonClient().v1beta1().pipelineRuns().inNamespace(namespace).withName(pipelineRunName).get();
+            run.getSpec().setStatus("CancelledRunFinally");
+
+            tektonClient().v1beta1().pipelineRuns().inNamespace(namespace)
+                    .resource(run)
+                    .lockResourceVersion(run.getMetadata().getResourceVersion())
+                    .replaceStatus();
+        } catch (Exception ex) {
+            LOGGER.error(ex.getMessage());
+        }
+    }
+    
     public void rolloutDeployment(String name, String namespace) {
         try {
             kubernetesClient().apps().deployments().inNamespace(namespace).withName(name).rolling().restart();