This is an automated email from the ASF dual-hosted git repository.
ricardozanini pushed a commit to branch main
in repository
https://gitbox.apache.org/repos/asf/incubator-kie-kogito-serverless-operator.git
The following commit(s) were added to refs/heads/main by this push:
new 59169ca8 Fix #364 pipelines using an old Ubuntu version (#365)
59169ca8 is described below
commit 59169ca8fd9c8f48ff7da0b0f96a4830cc25dcbe
Author: Ricardo Zanini <[email protected]>
AuthorDate: Wed Jan 24 16:57:26 2024 -0300
Fix #364 pipelines using an old Ubuntu version (#365)
Signed-off-by: Ricardo Zanini <[email protected]>
---
.github/workflows/check-container-builder.yml | 5 ++--
.github/workflows/checks.yml | 4 +--
.../builder/kaniko_integration_test_suite.go | 2 +-
.../cleaner/docker_integration_test.go | 19 ++++++++-----
.../cleaner/docker_integration_test_suite.go | 2 +-
.../cleaner/registry_docker_integration_test.go | 12 ++++++---
container-builder/common/registry.go | 22 +++++----------
container-builder/common/registry_docker.go | 31 ++++++----------------
8 files changed, 43 insertions(+), 54 deletions(-)
diff --git a/.github/workflows/check-container-builder.yml
b/.github/workflows/check-container-builder.yml
index 0f0d5c45..c70dd1ac 100644
--- a/.github/workflows/check-container-builder.yml
+++ b/.github/workflows/check-container-builder.yml
@@ -54,11 +54,12 @@ jobs:
cancel-in-progress: true
timeout-minutes: 120
name: Integration tests (${{ matrix.container-engine }})
- runs-on: ubuntu-22.04
+ runs-on: ubuntu-latest
steps:
- name: Install packages
run: |
- sudo apt-get -y install \
+ sudo apt-get update &&\
+ sudo apt-get -y install --no-install-recommends \
libgpgme-dev \
libbtrfs-dev \
libdevmapper-dev
diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml
index 7e6d0b47..bed06419 100644
--- a/.github/workflows/checks.yml
+++ b/.github/workflows/checks.yml
@@ -84,10 +84,10 @@ jobs:
uses: actions/checkout@v3
# since we now have to download container-builder deps, we need these
packages installed before generating our types.
- # we should be able to remove this after
https://issues.redhat.com/browse/KOGITO-9106
- name: Install packages
run: |
- sudo apt-get -y install \
+ sudo apt-get update &&\
+ sudo apt-get -y install --no-install-recommends \
btrfs-progs \
libgpgme-dev \
libbtrfs-dev \
diff --git a/container-builder/builder/kaniko_integration_test_suite.go
b/container-builder/builder/kaniko_integration_test_suite.go
index 56b44e0d..b34030dd 100644
--- a/container-builder/builder/kaniko_integration_test_suite.go
+++ b/container-builder/builder/kaniko_integration_test_suite.go
@@ -63,7 +63,7 @@ func (suite *KanikoDockerTestSuite) TearDownSuite() {
} else {
suite.LocalRegistry.StopRegistry()
}
- purged, err := suite.Docker.PurgeContainer("", common.REGISTRY_IMG)
+ purged, err := suite.Docker.PurgeContainer("", common.RegistryImg)
klog.V(log.I).InfoS("Purged containers", "containers", purged)
if err != nil {
klog.V(log.E).ErrorS(err, "Purged registry")
diff --git a/container-builder/cleaner/docker_integration_test.go
b/container-builder/cleaner/docker_integration_test.go
index a7440ad5..629c0712 100644
--- a/container-builder/cleaner/docker_integration_test.go
+++ b/container-builder/cleaner/docker_integration_test.go
@@ -33,6 +33,12 @@ import (
"github.com/apache/incubator-kie-kogito-serverless-operator/container-builder/util/log"
)
+const (
+ testImg = "busybox"
+ latestTag = "latest"
+ testImgLocalTag = "localhost:5000/busybox:latest"
+)
+
func TestDockerIntegrationTestSuite(t *testing.T) {
suite.Run(t, new(DockerTestSuite))
}
@@ -44,22 +50,21 @@ func (suite *DockerTestSuite)
TestImagesOperationsOnDockerRegistryForTest() {
repos, err := registryContainer.GetRepositories()
initialSize := len(repos)
assert.Nil(suite.T(), err)
-
- pullErr := suite.Docker.PullImage(common.TEST_IMG + ":" +
common.LATEST_TAG)
+ pullErr := suite.Docker.PullImage(testImg + ":" + latestTag)
if pullErr != nil {
klog.V(log.E).ErrorS(pullErr, "Pull Error")
}
assert.Nil(suite.T(), pullErr, "Pull image failed")
time.Sleep(2 * time.Second) // Needed on CI
- assert.True(suite.T(),
suite.LocalRegistry.IsImagePresent(common.TEST_IMG), "Test image not found in
the registry after the pull")
- tagErr := suite.Docker.TagImage(common.TEST_IMG,
common.TEST_IMG_LOCAL_TAG)
+ assert.True(suite.T(), suite.LocalRegistry.IsImagePresent(testImg),
"Test image not found in the registry after the pull")
+ tagErr := suite.Docker.TagImage(testImg, testImgLocalTag)
if tagErr != nil {
klog.V(log.E).ErrorS(tagErr, "Tag Error")
}
assert.Nil(suite.T(), tagErr, "Tag image failed")
time.Sleep(2 * time.Second) // Needed on CI
- pushErr := suite.Docker.PushImage(common.TEST_IMG_LOCAL_TAG,
common.REGISTRY_CONTAINER_URL_FROM_DOCKER_SOCKET, "", "")
+ pushErr := suite.Docker.PushImage(testImgLocalTag,
common.RegistryContainerUrlFromDockerSocket, "", "")
if pushErr != nil {
klog.V(log.E).ErrorS(pushErr, "Push Error")
}
@@ -72,8 +77,8 @@ func (suite *DockerTestSuite)
TestImagesOperationsOnDockerRegistryForTest() {
assert.NotNil(suite.T(), repos)
assert.True(suite.T(), len(repos) == initialSize+1)
- digest, erroDIgest :=
registryContainer.Connection.ManifestDigest(common.TEST_IMG, common.LATEST_TAG)
+ digest, erroDIgest :=
registryContainer.Connection.ManifestDigest(testImg, latestTag)
assert.Nil(suite.T(), erroDIgest)
assert.NotNil(suite.T(), digest)
- assert.NotNil(suite.T(), registryContainer.DeleteImage(common.TEST_IMG,
common.LATEST_TAG), "Delete Image not allowed")
+ assert.NotNil(suite.T(), registryContainer.DeleteImage(testImg,
latestTag), "Delete Image not allowed")
}
diff --git a/container-builder/cleaner/docker_integration_test_suite.go
b/container-builder/cleaner/docker_integration_test_suite.go
index bae8c2ce..0b7650cb 100644
--- a/container-builder/cleaner/docker_integration_test_suite.go
+++ b/container-builder/cleaner/docker_integration_test_suite.go
@@ -55,7 +55,7 @@ func (suite *DockerTestSuite) TearDownSuite() {
} else {
suite.LocalRegistry.StopRegistry()
}
- purged, err := suite.Docker.PurgeContainer("", common.REGISTRY_IMG)
+ purged, err := suite.Docker.PurgeContainer("", common.RegistryImg)
if err != nil {
klog.V(log.E).ErrorS(err, "Error during purged container in
TearDown Suite.")
}
diff --git a/container-builder/cleaner/registry_docker_integration_test.go
b/container-builder/cleaner/registry_docker_integration_test.go
index 3bd5d0fc..e89b6f16 100644
--- a/container-builder/cleaner/registry_docker_integration_test.go
+++ b/container-builder/cleaner/registry_docker_integration_test.go
@@ -33,6 +33,12 @@ import (
"github.com/apache/incubator-kie-kogito-serverless-operator/container-builder/util/log"
)
+const (
+ testImgSecond = "alpine"
+ testImgSecondTag = "alpine:latest"
+ testImgSecondLocalTag = "localhost:5000/alpine:latest"
+)
+
func TestRegistryDockerIntegrationTestSuite(t *testing.T) {
suite.Run(t, new(DockerTestSuite))
}
@@ -65,20 +71,20 @@ func dockerPullTagPushOnRegistryContainer(suite
*DockerTestSuite) bool {
dockerSocketConn := suite.Docker.Connection
d := common.Docker{Connection: dockerSocketConn}
- err := d.PullImage(common.TEST_IMG_SECOND)
+ err := d.PullImage(testImgSecond)
time.Sleep(2 * time.Second) // needed on CI
if err != nil {
assert.Fail(suite.T(), "Pull Image Failed", err)
return false
}
- err = d.TagImage(common.TEST_IMG_SECOND_TAG,
common.TEST_IMG_SECOND_LOCAL_TAG)
+ err = d.TagImage(testImgSecondTag, testImgSecondLocalTag)
if err != nil {
assert.Fail(suite.T(), "Tag Image Failed", err)
return false
}
- err = d.PushImage(common.TEST_IMG_SECOND_LOCAL_TAG,
common.REGISTRY_CONTAINER_URL_FROM_DOCKER_SOCKET, "", "")
+ err = d.PushImage(testImgSecondLocalTag,
common.RegistryContainerUrlFromDockerSocket, "", "")
if err != nil {
assert.Fail(suite.T(), "Push Image Failed", err)
return false
diff --git a/container-builder/common/registry.go
b/container-builder/common/registry.go
index a52252d2..aca1d1f9 100644
--- a/container-builder/common/registry.go
+++ b/container-builder/common/registry.go
@@ -35,20 +35,12 @@ import (
"github.com/apache/incubator-kie-kogito-serverless-operator/container-builder/util/log"
)
-const REGISTRY_IMG = "registry"
-const REGISTRY_IMG_FULL = "docker.io/library/registry"
-const REGISTRY_IMG_FULL_TAG = "docker.io/library/registry:latest"
-const REGISTRY_CONTAINER_URL_FROM_DOCKER_SOCKET = "tcp://localhost:5000"
-const REGISTRY_CONTAINER_URL = "http://localhost:5000"
-const TEST_IMG = "busybox"
-const TEST_REGISTRY_REPO = "localhost:5000/"
-const TEST_REPO = "docker.io/library/"
-const LATEST_TAG = "latest"
-const TEST_IMG_TAG = "busybox:latest"
-const TEST_IMG_SECOND = "alpine"
-const TEST_IMG_SECOND_TAG = "alpine:latest"
-const TEST_IMG_SECOND_LOCAL_TAG = "localhost:5000/alpine:latest"
-const TEST_IMG_LOCAL_TAG = "localhost:5000/busybox:latest"
+const (
+ RegistryContainerUrlFromDockerSocket = "tcp://localhost:5000"
+ RegistryImg = "registry"
+ registryImgFullTag =
"docker.io/library/registry:latest"
+ registryContainerUrl = "http://localhost:5000"
+)
type Registry interface {
StartRegistry()
@@ -121,7 +113,7 @@ func (r *RegistryContainer) url(pathTemplate string, args
...interface{}) string
}
func GetRegistryContainer() (RegistryContainer, error) {
- registryContainerConnection, err :=
GetRegistryConnection(REGISTRY_CONTAINER_URL, "", "")
+ registryContainerConnection, err :=
GetRegistryConnection(registryContainerUrl, "", "")
if err != nil {
klog.V(log.E).ErrorS(err, "Can't connect to the
RegistryContainer")
return RegistryContainer{}, err
diff --git a/container-builder/common/registry_docker.go
b/container-builder/common/registry_docker.go
index cccd45d2..afd970c0 100644
--- a/container-builder/common/registry_docker.go
+++ b/container-builder/common/registry_docker.go
@@ -44,21 +44,6 @@ func GetDockerConnection() (*client.Client, error) {
return cli, nil
}
-func GetCustomDockerConnectionWithIP(ip string) (*client.Client, error) {
- return client.NewClientWithOpts(client.FromEnv,
client.WithAPIVersionNegotiation(), client.WithHost(ip))
-}
-
-func GetCustomRegistry() (DockerLocalRegistry, *client.Client, error) {
- connectionLocal, err :=
GetCustomDockerConnectionWithIP(REGISTRY_CONTAINER_URL_FROM_DOCKER_SOCKET)
- if err != nil {
- klog.V(log.E).ErrorS(err, "error during Get Custom Registry")
- return DockerLocalRegistry{}, nil, err
- }
-
- d := DockerLocalRegistry{Connection: connectionLocal}
- return d, connectionLocal, nil
-}
-
func (d DockerLocalRegistry) getConnection() (*client.Client, error) {
connectionLocal := d.Connection
if connectionLocal == nil {
@@ -86,7 +71,7 @@ func (d DockerLocalRegistry) StartRegistry() string {
if !d.IsRegistryImagePresent() {
klog.V(log.I).InfoS("Registry Image Pull")
- _, err := d.Connection.ImagePull(ctx, REGISTRY_IMG,
types.ImagePullOptions{})
+ _, err := d.Connection.ImagePull(ctx, RegistryImg,
types.ImagePullOptions{})
if err != nil {
fmt.Println(err)
return ""
@@ -97,7 +82,7 @@ func (d DockerLocalRegistry) StartRegistry() string {
klog.V(log.I).InfoS("Registry Container Create")
resp, err := d.Connection.ContainerCreate(ctx, &container.Config{
- Image: REGISTRY_IMG,
+ Image: RegistryImg,
ExposedPorts: nat.PortSet{"5000": struct{}{}},
},
&container.HostConfig{
@@ -105,7 +90,7 @@ func (d DockerLocalRegistry) StartRegistry() string {
},
nil,
nil,
- REGISTRY_IMG)
+ RegistryImg)
if err != nil {
klog.V(log.E).ErrorS(err, "error during Registry Container
Create")
@@ -160,7 +145,7 @@ func (d DockerLocalRegistry) GetRegistryRunningID() string {
}
for _, container := range containers {
- if container.Image == REGISTRY_IMG {
+ if container.Image == RegistryImg {
return container.ID
}
}
@@ -174,7 +159,7 @@ func (d DockerLocalRegistry) IsRegistryImagePresent() bool {
return false
}
for _, imagex := range imageList {
- if (len(imagex.RepoTags) > 0 && imagex.RepoTags[0] ==
REGISTRY_IMG) || (imagex.RepoDigests != nil &&
strings.HasPrefix(imagex.RepoDigests[0], REGISTRY_IMG)) {
+ if (len(imagex.RepoTags) > 0 && imagex.RepoTags[0] ==
RegistryImg) || (len(imagex.RepoDigests) > 0 &&
strings.HasPrefix(imagex.RepoDigests[0], RegistryImg)) {
return true
}
}
@@ -210,7 +195,7 @@ func SetupDockerSocket() (DockerLocalRegistry, string,
Docker) {
if err != nil {
klog.V(log.E).ErrorS(err, "error during SetupDockerSocket")
}
- _, err = dockerSock.PurgeContainer("", REGISTRY_IMG)
+ _, err = dockerSock.PurgeContainer("", RegistryImg)
if err != nil {
klog.V(log.E).ErrorS(err, "error during SetupDockerSocket")
}
@@ -218,12 +203,12 @@ func SetupDockerSocket() (DockerLocalRegistry, string,
Docker) {
d := DockerLocalRegistry{Connection: dockerSocketConn}
klog.V(log.I).InfoS("Check if registry image is present", "isPresent",
d.IsRegistryImagePresent())
if !d.IsRegistryImagePresent() {
- dockerSock.PullImage(REGISTRY_IMG_FULL_TAG)
+ dockerSock.PullImage(registryImgFullTag)
}
registryID := d.GetRegistryRunningID()
if len(registryID) == 0 {
registryID = d.StartRegistry()
- klog.V(log.E).ErrorS(err, "Registry started")
+ klog.V(log.I).InfoS("Registry started")
} else {
klog.V(log.I).InfoS("Registry already up and running", "ID",
registryID)
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]