This is an automated email from the ASF dual-hosted git repository.
jstastnycz pushed a commit to branch main
in repository
https://gitbox.apache.org/repos/asf/incubator-kie-kogito-pipelines.git
The following commit(s) were added to refs/heads/main by this push:
new c17c50e8 kie-issues#747: tweak CI image docker startup (#1140)
c17c50e8 is described below
commit c17c50e81b5d7f7ef1512f191cd7cdd328b41d19
Author: Jan Stastny <[email protected]>
AuthorDate: Fri Dec 8 13:04:10 2023 +0100
kie-issues#747: tweak CI image docker startup (#1140)
Co-authored-by: jstastny-cz <[email protected]>
---
.ci/jenkins/Jenkinsfile.build-kogito-ci-image | 11 ++++++++---
apache-nodes/Dockerfile.kogito-ci-build | 13 +++++++++++--
apache-nodes/entrypoint.sh | 8 +++++---
apache-nodes/start-docker.sh | 20 ++------------------
apache-nodes/wait-for-docker.sh | 4 ++++
.../{start-docker.sh => wait-for-process.sh} | 18 +++---------------
dsl/scripts/pr_check.groovy | 5 +++--
dsl/seed/jenkinsfiles/Jenkinsfile.buildchain | 1 +
jenkins-pipeline-shared-libraries/vars/util.groovy | 8 ++++++++
9 files changed, 45 insertions(+), 43 deletions(-)
diff --git a/.ci/jenkins/Jenkinsfile.build-kogito-ci-image
b/.ci/jenkins/Jenkinsfile.build-kogito-ci-image
index c86ec42a..af1b45dc 100644
--- a/.ci/jenkins/Jenkinsfile.build-kogito-ci-image
+++ b/.ci/jenkins/Jenkinsfile.build-kogito-ci-image
@@ -1,12 +1,12 @@
import org.jenkinsci.plugins.workflow.libs.Library
-@Library('jenkins-pipeline-shared-libraries')_
-
pipeline {
agent {
label 'ubuntu'
}
-
+ libraries {
+ lib("jenkins-pipeline-shared-libraries@${BRANCH_NAME}")
+ }
environment {
DOCKER_CONFIG = "${WORKSPACE}/.docker"
@@ -65,8 +65,13 @@ pipeline {
}
}
steps {
+ echo 'Init docker'
+ script {
+ util.waitForDocker()
+ }
echo 'Debug basics'
sh '''
+ sh --version
locale
printenv
'''
diff --git a/apache-nodes/Dockerfile.kogito-ci-build
b/apache-nodes/Dockerfile.kogito-ci-build
index fbe793b7..cf9eddd0 100644
--- a/apache-nodes/Dockerfile.kogito-ci-build
+++ b/apache-nodes/Dockerfile.kogito-ci-build
@@ -157,10 +157,19 @@ ENV CONTAINER_ENGINE_TLS_OPTIONS=""
WORKDIR /project/directory
USER root
-COPY start-docker.sh entrypoint.sh /usr/local/bin/
+COPY start-docker.sh wait-for-docker.sh wait-for-process.sh entrypoint.sh
/usr/local/bin/
RUN chmod +x /usr/local/bin/start-docker.sh \
- /usr/local/bin/entrypoint.sh
+ /usr/local/bin/entrypoint.sh \
+ /usr/local/bin/wait-for-docker.sh \
+ /usr/local/bin/wait-for-process.sh
USER nonrootuser
+RUN echo "source wait-for-docker.sh" >> ~/.bashrc
+
+# Use bash as default instead of dash (BEGIN)
+RUN sudo bash -c "echo \"dash dash/sh boolean false\" | debconf-set-selections"
+RUN sudo bash -c "DEBIAN_FRONTEND=noninteractive dpkg-reconfigure dash"
+# Use bash as default instead of dash (END)
+
ENTRYPOINT ["entrypoint.sh"]
CMD ["bash"]
diff --git a/apache-nodes/entrypoint.sh b/apache-nodes/entrypoint.sh
index a1247741..61d79e22 100755
--- a/apache-nodes/entrypoint.sh
+++ b/apache-nodes/entrypoint.sh
@@ -1,11 +1,9 @@
#!/bin/bash
set -e
-# Start docker
-start-docker.sh
# cgroup v2: enable nesting
if [ -f /sys/fs/cgroup/cgroup.controllers ]; then
- echo "in cgroupv2 branch"
+ echo "in cgroupv2 branch"
# move the processes from the root group to the /init group,
# otherwise writing subtree_control fails with EBUSY.
# An error during moving non-existent process (i.e., "cat") is ignored.
@@ -15,6 +13,10 @@ if [ -f /sys/fs/cgroup/cgroup.controllers ]; then
sudo bash -c "sed -e 's/ / +/g' -e 's/^/+/' <
/sys/fs/cgroup/cgroup.controllers > /sys/fs/cgroup/cgroup.subtree_control"
fi
+# Start docker and print logs
+start-docker.sh
+
+# process the command passed, after docker is started
if [ $# -gt 0 ]; then
exec "$@"
fi
\ No newline at end of file
diff --git a/apache-nodes/start-docker.sh b/apache-nodes/start-docker.sh
index bebdf338..9b1422d9 100755
--- a/apache-nodes/start-docker.sh
+++ b/apache-nodes/start-docker.sh
@@ -1,31 +1,15 @@
#!/bin/bash
source /opt/bash-utils/logger.sh
-function wait_for_process () {
- local max_time_wait=30
- local process_name="$1"
- local waited_sec=0
- while ! pgrep "$process_name" >/dev/null && ((waited_sec <
max_time_wait)); do
- INFO "Process $process_name is not running yet. Retrying in 1 seconds"
- INFO "Waited $waited_sec seconds of $max_time_wait seconds"
- sleep 1
- ((waited_sec=waited_sec+1))
- if ((waited_sec >= max_time_wait)); then
- return 1
- fi
- done
- sudo chown root:docker /var/run/docker.sock
- return 0
-}
-
INFO "Starting supervisor"
sudo bash -c "/usr/bin/supervisord >> /dev/null 2>&1" &
INFO "Waiting for docker to be running"
-wait_for_process dockerd
+source wait-for-docker.sh
if [ $? -ne 0 ]; then
ERROR "dockerd is not running after max time"
exit 1
else
+ sudo chown root:docker /var/run/docker.sock
INFO "dockerd is running"
fi
\ No newline at end of file
diff --git a/apache-nodes/wait-for-docker.sh b/apache-nodes/wait-for-docker.sh
new file mode 100644
index 00000000..ee636f9c
--- /dev/null
+++ b/apache-nodes/wait-for-docker.sh
@@ -0,0 +1,4 @@
+#!/bin/bash
+source wait-for-process.sh
+
+wait_for_process dockerd
\ No newline at end of file
diff --git a/apache-nodes/start-docker.sh b/apache-nodes/wait-for-process.sh
old mode 100755
new mode 100644
similarity index 62%
copy from apache-nodes/start-docker.sh
copy to apache-nodes/wait-for-process.sh
index bebdf338..9cfc0a8d
--- a/apache-nodes/start-docker.sh
+++ b/apache-nodes/wait-for-process.sh
@@ -1,6 +1,6 @@
#!/bin/bash
source /opt/bash-utils/logger.sh
-
+set -e
function wait_for_process () {
local max_time_wait=30
local process_name="$1"
@@ -14,18 +14,6 @@ function wait_for_process () {
return 1
fi
done
- sudo chown root:docker /var/run/docker.sock
+ INFO "Process $process_name successfully started."
return 0
-}
-
-INFO "Starting supervisor"
-sudo bash -c "/usr/bin/supervisord >> /dev/null 2>&1" &
-
-INFO "Waiting for docker to be running"
-wait_for_process dockerd
-if [ $? -ne 0 ]; then
- ERROR "dockerd is not running after max time"
- exit 1
-else
- INFO "dockerd is running"
-fi
\ No newline at end of file
+}
\ No newline at end of file
diff --git a/dsl/scripts/pr_check.groovy b/dsl/scripts/pr_check.groovy
index 59b5ec6b..49ab0fef 100644
--- a/dsl/scripts/pr_check.groovy
+++ b/dsl/scripts/pr_check.groovy
@@ -40,8 +40,9 @@ void launch() {
void launchInDocker(String builderImage) {
docker.image(builderImage).inside(dockerArgs.join(' ')) {
- // Debug. To be removed in the future
- sh "printenv"
+ sh 'printenv > env_props'
+ archiveArtifacts artifacts: 'env_props'
+ util.waitForDocker()
sh 'ls -last /var/run/docker.sock'
try {
launchStages()
diff --git a/dsl/seed/jenkinsfiles/Jenkinsfile.buildchain
b/dsl/seed/jenkinsfiles/Jenkinsfile.buildchain
index d0a7e9db..912a3e68 100644
--- a/dsl/seed/jenkinsfiles/Jenkinsfile.buildchain
+++ b/dsl/seed/jenkinsfiles/Jenkinsfile.buildchain
@@ -62,6 +62,7 @@ pipeline {
script {
sh 'printenv > env_props'
archiveArtifacts artifacts: 'env_props'
+ util.waitForDocker()
sh 'ls -last /var/run/docker.sock'
if (mavenDeployArtifacts) {
diff --git a/jenkins-pipeline-shared-libraries/vars/util.groovy
b/jenkins-pipeline-shared-libraries/vars/util.groovy
index 30e00587..94ba17e2 100644
--- a/jenkins-pipeline-shared-libraries/vars/util.groovy
+++ b/jenkins-pipeline-shared-libraries/vars/util.groovy
@@ -547,3 +547,11 @@ String displayDurationFromSeconds(int durationInSec) {
result += "${seconds}s"
return result
}
+
+/**
+ * Method to wait for dockerd to be started. Put in initial pipeline stages to
make sure all starts in time.
+ */
+void waitForDocker() {
+ sleep(10) // give it some ahead time not to invoke docker exec immediately
after container start
+ sh 'wait-for-docker.sh' // script in kogito-ci-build image itself put in
/usr/local/bin
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]