Skip to content

Commit 4a1eca1

Browse files
authored
Support base docker registry login to increase pull limit (#4842)
- Pulling image from dockerhub reaches limit during release - Enabling base_docker_registry_credential to increase this limit Signed-off-by: LongyuZhang <[email protected]>
1 parent 8270e9c commit 4a1eca1

File tree

6 files changed

+106
-16
lines changed

6 files changed

+106
-16
lines changed

buildenv/jenkins/JenkinsfileBase

+12-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,17 @@ def makeTest(testParam) {
1212
}
1313
try {
1414
sh "$tearDownCmd"
15-
if (env.DOCKER_REGISTRY_URL && env.DOCKER_REGISTRY_URL_CREDENTIAL_ID) {
16-
withCredentials([usernamePassword(credentialsId: "${env.DOCKER_REGISTRY_URL_CREDENTIAL_ID}", usernameVariable: 'DOCKER_REGISTRY_CREDENTIALS_USR', passwordVariable: 'DOCKER_REGISTRY_CREDENTIALS_PSW')]) {
15+
if (env.DOCKER_REGISTRY_URL && env.DOCKER_REGISTRY_URL_CREDENTIAL_ID && env.BASE_DOCKER_REGISTRY_CREDENTIAL_ID) {
16+
withCredentials([
17+
usernamePassword(credentialsId: "${env.DOCKER_REGISTRY_URL_CREDENTIAL_ID}", usernameVariable: 'DOCKER_REGISTRY_CREDENTIALS_USR', passwordVariable: 'DOCKER_REGISTRY_CREDENTIALS_PSW'),
18+
usernamePassword(credentialsId: "${env.BASE_DOCKER_REGISTRY_CREDENTIAL_ID}", usernameVariable: 'BASE_DOCKER_REGISTRY_CREDENTIAL_USR', passwordVariable: 'BASE_DOCKER_REGISTRY_CREDENTIAL_PSW')
19+
]) {
20+
sh "$makeTestCmd"
21+
}
22+
} else if (env.DOCKER_REGISTRY_URL && env.DOCKER_REGISTRY_URL_CREDENTIAL_ID) {
23+
withCredentials([
24+
usernamePassword(credentialsId: "${env.DOCKER_REGISTRY_URL_CREDENTIAL_ID}", usernameVariable: 'DOCKER_REGISTRY_CREDENTIALS_USR', passwordVariable: 'DOCKER_REGISTRY_CREDENTIALS_PSW'),
25+
]) {
1726
sh "$makeTestCmd"
1827
}
1928
} else {
@@ -89,6 +98,7 @@ def setupEnv() {
8998
env.DOCKER_REGISTRY_URL = params.DOCKER_REGISTRY_URL ? params.DOCKER_REGISTRY_URL : ""
9099
env.DOCKER_REGISTRY_DIR = params.DOCKER_REGISTRY_DIR ? params.DOCKER_REGISTRY_DIR : ""
91100
env.DOCKER_REGISTRY_URL_CREDENTIAL_ID = params.DOCKER_REGISTRY_URL_CREDENTIAL_ID ? params.DOCKER_REGISTRY_URL_CREDENTIAL_ID : ""
101+
env.BASE_DOCKER_REGISTRY_CREDENTIAL_ID = params.BASE_DOCKER_REGISTRY_CREDENTIAL_ID ? params.BASE_DOCKER_REGISTRY_CREDENTIAL_ID : ""
92102
ITERATIONS = params.ITERATIONS ? "${params.ITERATIONS}".toInteger() : 1
93103
env.TKG_ITERATIONS = params.TKG_ITERATIONS ? "${params.TKG_ITERATIONS}".toInteger() : 1
94104
env.EXIT_FAILURE = params.EXIT_FAILURE ? params.EXIT_FAILURE : false

buildenv/jenkins/testJobTemplate

+2
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ if (!binding.hasVariable('CUSTOMIZED_SDK_URL_CREDENTIAL_ID')) CUSTOMIZED_SDK_URL
4949
if (!binding.hasVariable('DOCKER_REGISTRY_URL')) DOCKER_REGISTRY_URL = ""
5050
if (!binding.hasVariable('DOCKER_REGISTRY_DIR')) DOCKER_REGISTRY_DIR = ""
5151
if (!binding.hasVariable('DOCKER_REGISTRY_URL_CREDENTIAL_ID')) DOCKER_REGISTRY_URL_CREDENTIAL_ID = ""
52+
if (!binding.hasVariable('BASE_DOCKER_REGISTRY_CREDENTIAL_ID')) BASE_DOCKER_REGISTRY_CREDENTIAL_ID = ""
5253
if (!binding.hasVariable('SLACK_CHANNEL')) SLACK_CHANNEL = ""
5354
if (!binding.hasVariable('TRIGGER_SCHEDULE')) TRIGGER_SCHEDULE = ""
5455
if (!binding.hasVariable('LIGHT_WEIGHT_CHECKOUT')) LIGHT_WEIGHT_CHECKOUT = true
@@ -325,6 +326,7 @@ ARCH_OS_LIST.each { ARCH_OS ->
325326
stringParam('DOCKER_REGISTRY_URL', DOCKER_REGISTRY_URL, "Only use this if you need to access a docker registry")
326327
stringParam('DOCKER_REGISTRY_DIR', DOCKER_REGISTRY_DIR, "Only use this if you need to specify the directory in docker registry")
327328
stringParam('DOCKER_REGISTRY_URL_CREDENTIAL_ID', DOCKER_REGISTRY_URL_CREDENTIAL_ID, "Only use this if the docker registry you access needs credential")
329+
stringParam('BASE_DOCKER_REGISTRY_CREDENTIAL_ID', BASE_DOCKER_REGISTRY_CREDENTIAL_ID, "Only use this if base docker registry credential is needed to avoid reach limit")
328330
stringParam('UPSTREAM_JOB_NAME', "", '''Upstream job name from the same Jenkins server to download JDK. e.g., UploadFile<br/>
329331
Only set when SDK_RESOURCE=upstream. It has to be used together with UPSTREAM_JOB_NUMBER <br/>''')
330332
stringParam('UPSTREAM_JOB_NUMBER', "", '''Upstream job number from the same Jenkins server to download JDK. e.g., 40<br/>

external/common_functions.sh

+5
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,11 @@ function set_platform() {
177177
platform=$1
178178
}
179179

180+
# Set base_docker_registry_url
181+
function set_base_docker_registry_url() {
182+
base_docker_registry_url="$1"
183+
}
184+
180185
# Set base_docker_registry_dir
181186
function set_base_docker_registry_dir() {
182187
base_docker_registry_dir="$1"

external/criu-portable-checkpoint/build.xml

+23-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,29 @@
1515
<mkdir dir="${DEST}"/>
1616
</target>
1717

18-
<target name="dist" depends="move_scripts,clean_image,build_image" description="generate the distribution">
18+
<target name="prepare_base_image" depends="move_scripts,clean_image" description="prepare the base image">
19+
<echo message="Executing external.sh --prepare --dir ${TEST} --tag ${dockerImageTag} --version ${JDK_VERSION} --impl ${JDK_IMPL} --base_docker_registry_url 'docker.io' --base_docker_registry_dir 'default' --docker_args ${extra_docker_args} " />
20+
<exec executable="bash" failonerror="true">
21+
<arg value="${DEST_EXTERNAL}/external.sh"/>
22+
<arg value="--prepare"/>
23+
<arg value="--dir"/>
24+
<arg value="${TEST}"/>
25+
<arg value="--tag"/>
26+
<arg value="${dockerImageTag}"/>
27+
<arg value="--version"/>
28+
<arg value="${JDK_VERSION}"/>
29+
<arg value="--impl"/>
30+
<arg value="${JDK_IMPL}"/>
31+
<arg value="--base_docker_registry_url"/>
32+
<arg value="docker.io"/>
33+
<arg value="--base_docker_registry_dir"/>
34+
<arg value="default"/>
35+
<arg value="--docker_args"/>
36+
<arg value="${extra_docker_args}"/>
37+
</exec>
38+
</target>
39+
40+
<target name="dist" depends="prepare_base_image,build_image" description="generate the distribution">
1941
<copy todir="${DEST}">
2042
<fileset dir="${src}" includes="*.xml, *.mk"/>
2143
</copy>

external/criu-ubi-portable-checkpoint/build.xml

+23-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,29 @@
1515
<mkdir dir="${DEST}"/>
1616
</target>
1717

18-
<target name="build_image" depends="move_scripts,clean_image" description="build the image">
18+
<target name="prepare_base_image" depends="move_scripts,clean_image" description="prepare the base image">
19+
<echo message="Executing external.sh --prepare --dir ${TEST} --tag ${dockerImageTag} --version ${JDK_VERSION} --impl ${JDK_IMPL} --base_docker_registry_url '${env.DOCKER_REGISTRY_URL}' --base_docker_registry_dir 'ubi8-with-criu/${env.SPEC}-ubi8-criu' --docker_args ${extra_docker_args} " />
20+
<exec executable="bash" failonerror="true">
21+
<arg value="${DEST_EXTERNAL}/external.sh"/>
22+
<arg value="--prepare"/>
23+
<arg value="--dir"/>
24+
<arg value="${TEST}"/>
25+
<arg value="--tag"/>
26+
<arg value="${dockerImageTag}"/>
27+
<arg value="--version"/>
28+
<arg value="${JDK_VERSION}"/>
29+
<arg value="--impl"/>
30+
<arg value="${JDK_IMPL}"/>
31+
<arg value="--base_docker_registry_url"/>
32+
<arg value="${env.DOCKER_REGISTRY_URL}"/>
33+
<arg value="--base_docker_registry_dir"/>
34+
<arg value="ubi8-with-criu/${env.SPEC}-ubi8-criu"/>
35+
<arg value="--docker_args"/>
36+
<arg value="${extra_docker_args}"/>
37+
</exec>
38+
</target>
39+
40+
<target name="build_image" depends="prepare_base_image" description="build the image">
1941
<echo message="Executing external.sh --build --dir ${TEST} --tag ${dockerImageTag} --version ${JDK_VERSION} --impl ${JDK_IMPL} --base_docker_registry_dir 'ubi8-with-criu/${env.SPEC}-ubi8-criu' --docker_registry_url ${env.DOCKER_REGISTRY_URL} --docker_args ${extra_docker_args} " />
2042
<exec executable="bash" failonerror="true">
2143
<arg value="${DEST_EXTERNAL}/external.sh"/>

external/external.sh

+41-12
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
# limitations under the License.
1414
#
1515

16-
# script runs in 4 modes - build / run / load / clean
16+
# script runs in 5 modes - prepare / build / run / load / clean
1717

1818
set -e
1919
tag=nightly
@@ -47,7 +47,8 @@ container_rmi="docker rmi"
4747
docker_registry_required="false"
4848
docker_registry_url=""
4949
docker_registry_dir=""
50-
base_docker_registry_dir="public"
50+
base_docker_registry_url="default"
51+
base_docker_registry_dir="default"
5152
reportdst="false"
5253
reportsrc="false"
5354
docker_args=""
@@ -57,7 +58,7 @@ imageArg=""
5758

5859

5960
usage () {
60-
echo 'Usage : external.sh --dir TESTDIR --tag DOCKERIMAGE_TAG --version JDK_VERSION --impl JDK_IMPL [--docker_os docker_os][--platform PLATFORM] [--portable portable] [--node_name node_name] [--node_labels node_labels] [--docker_registry_required docker_registry_required] [--docker_registry_url DOCKER_REGISTRY_URL] [--docker_registry_dir DOCKER_REGISTRY_DIR] [--base_docker_registry_dir baseDockerRegistryDir] [--mount_jdk mount_jdk] [--test_root TEST_ROOT] [--reportsrc appReportDir] [--reportdst REPORTDIR] [--testtarget target] [--docker_args EXTRA_DOCKER_ARGS] [--build|--run|--load|--clean]'
61+
echo 'Usage : external.sh --dir TESTDIR --tag DOCKERIMAGE_TAG --version JDK_VERSION --impl JDK_IMPL [--docker_os docker_os][--platform PLATFORM] [--portable portable] [--node_name node_name] [--node_labels node_labels] [--docker_registry_required docker_registry_required] [--docker_registry_url DOCKER_REGISTRY_URL] [--docker_registry_dir DOCKER_REGISTRY_DIR] [--base_docker_registry_url baseDockerRegistryUrl] [--base_docker_registry_dir baseDockerRegistryDir] [--mount_jdk mount_jdk] [--test_root TEST_ROOT] [--reportsrc appReportDir] [--reportdst REPORTDIR] [--testtarget target] [--docker_args EXTRA_DOCKER_ARGS] [--build|--run|--load|--clean]'
6162
}
6263

6364
supported_tests="external_custom aot camel criu-portable-checkpoint criu-portable-restore criu-ubi-portable-checkpoint criu-ubi-portable-restore derby elasticsearch jacoco jenkins functional-test kafka lucene-solr openliberty-mp-tck payara-mp-tck quarkus quarkus_quickstarts scala system-test tomcat tomee wildfly wycheproof netty spring"
@@ -175,9 +176,17 @@ parseCommandLineArgs() {
175176
docker_image_source_job_name=${dir_array[0]}
176177
build_number=${dir_array[1]};;
177178

179+
"--base_docker_registry_url" )
180+
if [ -z "$1" ]; then
181+
base_docker_registry_url="default";
182+
else
183+
base_docker_registry_url="$1";
184+
fi
185+
shift;;
186+
178187
"--base_docker_registry_dir" )
179188
if [ -z "$1" ]; then
180-
base_docker_registry_dir="public";
189+
base_docker_registry_dir="default";
181190
else
182191
base_docker_registry_dir="$1";
183192
fi
@@ -198,6 +207,9 @@ parseCommandLineArgs() {
198207
"--testtarget" )
199208
testtarget="$1"; shift;;
200209

210+
"--prepare" | "-p" )
211+
command_type=prepare;;
212+
201213
"--build" | "-b" )
202214
command_type=build;;
203215

@@ -270,17 +282,34 @@ parseCommandLineArgs "$@"
270282
# set DOCKER_HOST env variables
271283
# DOCKER_HOST=$(docker-ip $test-test)
272284

273-
if [ $command_type == "build" ]; then
274-
# Temporarily ubi image with criu binary is only available internally
275-
if [[ $base_docker_registry_dir != "public" ]]; then
276-
echo "Private Docker Registry login starts to obtain base Docker Image:"
277-
echo $DOCKER_REGISTRY_CREDENTIALS_PSW | $container_login --username=$DOCKER_REGISTRY_CREDENTIALS_USR --password-stdin $docker_registry_url
285+
if [ $command_type == "prepare" ]; then
286+
# Specify docker.io or internal registry to prepare base image with login to increase pull limit or authenticate; Redhat Registry no login.
287+
if [[ $base_docker_registry_url != "default" ]]; then
288+
echo "Base Docker Registry login starts to obtain Base Docker Image:"
289+
# Temporarily criu-ubi image with criu binary is only available internally
290+
if [[ "${test}" != *"criu-ubi"* ]]; then
291+
echo $BASE_DOCKER_REGISTRY_CREDENTIAL_PSW | $container_login --username=$BASE_DOCKER_REGISTRY_CREDENTIAL_USR --password-stdin $base_docker_registry_url
292+
else
293+
echo $DOCKER_REGISTRY_CREDENTIALS_PSW | $container_login --username=$DOCKER_REGISTRY_CREDENTIALS_USR --password-stdin $base_docker_registry_url
294+
fi
278295

279-
echo "$container_pull $docker_registry_url/$base_docker_registry_dir:latest"
280-
$container_pull $docker_registry_url/$base_docker_registry_dir:latest
296+
if [[ $base_docker_registry_dir == "default" ]]; then
297+
base_docker_image_name="eclipse-temurin:${JDK_VERSION}-jdk"
298+
if [[ "${JDK_IMPL}" == *"openj9"* ]]; then
299+
base_docker_image_name="ibm-semeru-runtimes:open-${JDK_VERSION}-jdk"
300+
fi
301+
else
302+
base_docker_image_name="$base_docker_registry_dir:latest"
303+
fi
304+
305+
echo "$container_pull $base_docker_registry_url/$base_docker_image_name"
306+
$container_pull $base_docker_registry_url/$base_docker_image_name
281307

282-
$container_logout $docker_registry_url
308+
$container_logout $base_docker_registry_url
283309
fi
310+
fi
311+
312+
if [ $command_type == "build" ]; then
284313
echo "build_image.sh $test $version $impl $docker_os $package $build_type $platform $base_docker_registry_dir $check_external_custom $imageArg"
285314
source $(dirname "$0")/build_image.sh $test $version $impl $docker_os $package $build_type $platform "$base_docker_registry_dir" $check_external_custom $imageArg
286315
fi

0 commit comments

Comments
 (0)