You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kie.apache.org by ed...@apache.org on 2024/02/19 21:10:51 UTC
(incubator-kie-tools) 01/01: Upgrade to most recent operator version + fix podman issue
This is an automated email from the ASF dual-hosted git repository.
ederign pushed a commit to branch KOGITO-9848-2024
in repository https://gitbox.apache.org/repos/asf/incubator-kie-tools.git
commit 7ef8d5d0810f5eb79e0a0d8a197f97787da9660d
Author: Eder Ignatowicz <ig...@gmail.com>
AuthorDate: Mon Feb 19 16:10:30 2024 -0500
Upgrade to most recent operator version + fix podman issue
---
packages/kn-plugin-workflow/go.mod | 2 +-
packages/kn-plugin-workflow/go.sum | 2 ++
packages/kn-plugin-workflow/pkg/command/run.go | 8 ++---
.../kn-plugin-workflow/pkg/common/containers.go | 40 ++++++++++++++--------
.../kn-plugin-workflow/pkg/metadata/constants.go | 3 +-
5 files changed, 35 insertions(+), 20 deletions(-)
diff --git a/packages/kn-plugin-workflow/go.mod b/packages/kn-plugin-workflow/go.mod
index 87024810acb..ac4f037e6b0 100644
--- a/packages/kn-plugin-workflow/go.mod
+++ b/packages/kn-plugin-workflow/go.mod
@@ -5,7 +5,7 @@ go 1.20
replace github.com/apache/incubator-kie-kogito-serverless-operator/api v0.0.0 => github.com/apache/incubator-kie-kogito-serverless-operator/api v0.0.0-20240126134605-2b5056d12bb9
require (
- github.com/apache/incubator-kie-kogito-serverless-operator/workflowproj v0.0.0-20240126134605-2b5056d12bb9
+ github.com/apache/incubator-kie-kogito-serverless-operator/workflowproj v0.0.0-20240122.0.20240219180504-5ebaf85efc66
github.com/beevik/etree v1.2.0
github.com/docker/docker v24.0.7+incompatible
github.com/docker/go-connections v0.4.0
diff --git a/packages/kn-plugin-workflow/go.sum b/packages/kn-plugin-workflow/go.sum
index 6e2fc3af1d4..af1169659b8 100644
--- a/packages/kn-plugin-workflow/go.sum
+++ b/packages/kn-plugin-workflow/go.sum
@@ -45,6 +45,8 @@ github.com/Microsoft/go-winio v0.6.1/go.mod h1:LRdKpFKfdobln8UmuiYcKPot9D2v6svN5
github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
github.com/apache/incubator-kie-kogito-serverless-operator/api v0.0.0-20240126134605-2b5056d12bb9 h1:LrUW2+TRA8t0ttZTWjrDFW+gSWKaGWU2Led+RJiGUn8=
github.com/apache/incubator-kie-kogito-serverless-operator/api v0.0.0-20240126134605-2b5056d12bb9/go.mod h1:pve19HflUPuWGb8jzBaFqrZU8DWnRG2hpcRyo3w9shQ=
+github.com/apache/incubator-kie-kogito-serverless-operator/workflowproj v0.0.0-20240122.0.20240219180504-5ebaf85efc66 h1:z7qKamBtG5Y2ZqWuW1O+MNBeOLndLoaYqW5ypDjcKZA=
+github.com/apache/incubator-kie-kogito-serverless-operator/workflowproj v0.0.0-20240122.0.20240219180504-5ebaf85efc66/go.mod h1:Vw5jMxj6TmDe0TOrVkcVdlquOX1z8SP9rd+wzVMqmnY=
github.com/apache/incubator-kie-kogito-serverless-operator/workflowproj v0.0.0-20240126134605-2b5056d12bb9 h1:PT7EqTODfuhRvEUk+Tl4eJEt7//oHYsL7JoYgsptYcA=
github.com/apache/incubator-kie-kogito-serverless-operator/workflowproj v0.0.0-20240126134605-2b5056d12bb9/go.mod h1:Vw5jMxj6TmDe0TOrVkcVdlquOX1z8SP9rd+wzVMqmnY=
github.com/beevik/etree v1.2.0 h1:l7WETslUG/T+xOPs47dtd6jov2Ii/8/OjCldk5fYfQw=
diff --git a/packages/kn-plugin-workflow/pkg/command/run.go b/packages/kn-plugin-workflow/pkg/command/run.go
index 7f83254c4bc..ec0393d9838 100644
--- a/packages/kn-plugin-workflow/pkg/command/run.go
+++ b/packages/kn-plugin-workflow/pkg/command/run.go
@@ -100,12 +100,12 @@ func runDevCmdConfig() (cfg RunCmdConfig, err error) {
func runSWFProject(cfg RunCmdConfig) error {
- if errDocker := common.CheckDocker(); errDocker == nil {
- if err := runSWFProjectDevMode(common.Docker, cfg); err != nil {
+ if errPodman := common.CheckPodman(); errPodman == nil {
+ if err := runSWFProjectDevMode(common.Podman, cfg); err != nil {
return err
}
- } else if errDocker := common.CheckPodman(); errDocker == nil {
- if err := runSWFProjectDevMode(common.Podman, cfg); err != nil {
+ } else if errDocker := common.CheckDocker(); errDocker == nil {
+ if err := runSWFProjectDevMode(common.Docker, cfg); err != nil {
return err
}
} else {
diff --git a/packages/kn-plugin-workflow/pkg/common/containers.go b/packages/kn-plugin-workflow/pkg/common/containers.go
index 5924a78b6f2..d4db79d6fb5 100644
--- a/packages/kn-plugin-workflow/pkg/common/containers.go
+++ b/packages/kn-plugin-workflow/pkg/common/containers.go
@@ -28,6 +28,7 @@ import (
"os"
"os/exec"
"os/signal"
+ "runtime"
"strings"
"syscall"
@@ -61,10 +62,10 @@ func getDockerClient() (*client.Client, error) {
func GetContainerID(containerTool string) (string, error) {
switch containerTool {
- case Docker:
- return getDockerContainerID()
case Podman:
return getPodmanContainerID()
+ case Docker:
+ return getDockerContainerID()
default:
return "", fmt.Errorf("no matching container type found")
}
@@ -76,10 +77,13 @@ func getPodmanContainerID() (string, error) {
"-a",
"--filter",
fmt.Sprintf("ancestor=%s", metadata.DevModeImage),
+ "--filter",
+ "status=running",
"--format", "{{.ID}}")
+ fmt.Println(cmd)
output, err := cmd.CombinedOutput()
if err != nil {
- return "", fmt.Errorf("error getting container id: %w", err)
+ return "", fmt.Errorf("error getting podman container id: %w", err)
}
containerID := strings.TrimSpace(string(output))
return containerID, nil
@@ -130,20 +134,29 @@ func StopContainer(containerTool string, containerID string) error {
return nil
}
+func resolveVolumeBindPath(containerTool string) string {
+ if containerTool == "podman" && runtime.GOOS == "linux" {
+ return metadata.VolumeBindPathSELinux
+ }
+ return metadata.VolumeBindPath
+}
+
func RunContainerCommand(containerTool string, portMapping string, path string) error {
+ volumeBindPath := resolveVolumeBindPath(containerTool)
fmt.Printf("🔎 Warming up SonataFlow containers (%s), this could take some time...\n", metadata.DevModeImage)
if containerTool == Podman {
+ c := exec.Command(
+ containerTool,
+ "run",
+ "--rm",
+ "-p",
+ fmt.Sprintf("%s:8080", portMapping),
+ "-v",
+ fmt.Sprintf("%s:%s", path, volumeBindPath),
+ fmt.Sprintf("%s", metadata.DevModeImage),
+ )
if err := RunCommand(
- exec.Command(
- containerTool,
- "run",
- "--rm",
- "-p",
- fmt.Sprintf("%s:8080", portMapping),
- "-v",
- fmt.Sprintf("%s:%s", path, metadata.VolumeBindPath),
- fmt.Sprintf("%s", metadata.DevModeImage),
- ),
+ c,
"container run",
); err != nil {
return err
@@ -164,7 +177,6 @@ func GracefullyStopTheContainerWhenInterrupted(containerTool string) {
go func() {
<-c // Wait for the interrupt signal
-
containerID, err := GetContainerID(containerTool)
if err != nil {
fmt.Printf("\nerror getting container id: %v\n", err)
diff --git a/packages/kn-plugin-workflow/pkg/metadata/constants.go b/packages/kn-plugin-workflow/pkg/metadata/constants.go
index cbc23d400e5..7a1f5c6b903 100644
--- a/packages/kn-plugin-workflow/pkg/metadata/constants.go
+++ b/packages/kn-plugin-workflow/pkg/metadata/constants.go
@@ -82,7 +82,8 @@ const (
DockerInternalPort = "8080/tcp"
// VolumeBindPath The :z is to let docker know that the volume content can be shared between containers(SELinux)
- VolumeBindPath = "/home/kogito/serverless-workflow-project/src/main/resources:z"
+ VolumeBindPathSELinux = "/home/kogito/serverless-workflow-project/src/main/resources:z"
+ VolumeBindPath = "/home/kogito/serverless-workflow-project/src/main/resources"
DashboardsDefaultDirName = "dashboards"
)
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org