Skip to content

Commit c664d52

Browse files
authored
Merge pull request #593 from jmtd/OPENJDK-3975-rsync-data-configuration
[OPENJDK-3975] tests for custom configuration and data
2 parents 9151fdf + e2f1d59 commit c664d52

File tree

4 files changed

+37
-7
lines changed

4 files changed

+37
-7
lines changed

modules/s2i/bash/artifacts/opt/jboss/container/java/s2i/maven-s2i-overrides

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11

22
source "${JBOSS_CONTAINER_UTIL_LOGGING_MODULE}/logging.sh"
3+
source "${JBOSS_CONTAINER_S2I_CORE_MODULE}/s2i-core"
34

45
# inject our overridden maven_*() functions
56
function maven_s2i_source_maven_overrides() {
@@ -30,11 +31,7 @@ function maven_s2i_custom_binary_build() {
3031
fi
3132
log_info "Copying binaries from ${binary_dir} to ${S2I_TARGET_DEPLOYMENTS_DIR} ..."
3233

33-
( # OPENJDK-2850: use glob (dotglob to match hidden files) to stop rsync altering
34-
# timestamps of S2I_TARGET_DEPLOYMENTS_DIR. Don't alter parent shell's dotglob.
35-
shopt -s dotglob
36-
rsync --archive --out-format='%n' "${binary_dir}"/* "${S2I_TARGET_DEPLOYMENTS_DIR}"
37-
)
34+
recursive_copy_files "${binary_dir}" "${S2I_TARGET_DEPLOYMENTS_DIR}"
3835
}
3936

4037
function maven_s2i_deploy_artifacts_override() {

modules/s2i/bash/module.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ modules:
1616
- name: jboss.container.maven.s2i
1717
- name: jboss.container.java.run
1818
- name: jboss.container.util.logging
19+
- name: jboss.container.s2i.core
1920

2021
packages:
2122
install:

modules/s2i/core/artifacts/opt/jboss/container/s2i/core/s2i-core

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,20 @@ function s2i_core_env_init_hook() {
4141
:
4242
}
4343

44+
# Copy files from a source path to a destination path
45+
# Do not attempt to change metadata of the destination path, which we
46+
# may not own
47+
function recursive_copy_files() {
48+
src="$1"
49+
dst="$2"
50+
( # OPENJDK-2850: use glob (dotglob to match hidden files) to stop rsync altering
51+
# timestamps of $dst, which we might not own. Subshell to not alter parent shell's
52+
# dotglob setting.
53+
shopt -s dotglob
54+
rsync --archive --out-format='%n' "${src}"/* "${dst}"
55+
)
56+
}
57+
4458
# copy configuration files
4559
# $1 - the base directory to which $S2I_SOURCE_CONFIGURATION_DIR is appended
4660
function s2i_core_copy_configuration() {
@@ -53,7 +67,7 @@ function s2i_core_copy_configuration() {
5367
mkdir -pm 775 "${S2I_TARGET_CONFIGURATION_DIR}"
5468
fi
5569
log_info "Copying configuration from $(realpath --relative-to ${S2I_SOURCE_DIR} ${1}/${S2I_SOURCE_CONFIGURATION_DIR}) to ${S2I_TARGET_CONFIGURATION_DIR}..."
56-
rsync --archive --out-format='%n' "${1}/${S2I_SOURCE_CONFIGURATION_DIR}"/ "${S2I_TARGET_CONFIGURATION_DIR}"
70+
recursive_copy_files "${1}/${S2I_SOURCE_CONFIGURATION_DIR}" "${S2I_TARGET_CONFIGURATION_DIR}"
5771
fi
5872
fi
5973
}
@@ -70,7 +84,7 @@ function s2i_core_copy_data() {
7084
mkdir -pm 775 "${S2I_TARGET_DATA_DIR}"
7185
fi
7286
log_info "Copying app data from $(realpath --relative-to ${S2I_SOURCE_DIR} ${1}/${S2I_SOURCE_DATA_DIR}) to ${S2I_TARGET_DATA_DIR}..."
73-
rsync --archive --out-format='%n' "${1}/${S2I_SOURCE_DATA_DIR}"/ "${S2I_TARGET_DATA_DIR}"
87+
recursive_copy_files "${1}/${S2I_SOURCE_DATA_DIR}" "${S2I_TARGET_DATA_DIR}"
7488
# s2i used to be more forgiving, but the build will fail if this call
7589
# fails. emit a warning and allow the build to succeed
7690
chmod -R g+rwX "${S2I_TARGET_DATA_DIR}" || log_warning "Errors occurred while adding read/write permissions to S2I_TARGET_DATA_DIR ($S2I_TARGET_DATA_DIR)."

modules/s2i/core/tests/features/s2i-core.feature

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,21 @@ Feature: Openshift S2I tests
1818
Then s2i build log should not contain rsync: [generator] failed to set permissions on "/var/tmp/.": Operation not permitted
1919
And s2i build log should contain appsrc-provided s2i assemble script executed
2020
And run stat /var/tmp/spring-boot-sample-simple-1.5.0.BUILD-SNAPSHOT.jar in container and check its output for Access:
21+
22+
# as above, for OPENJDK-3975: handling configuration
23+
Scenario: Ensure copying custom configuration doesn't fail trying to chmod destination directory (OPENJDK-3975)
24+
Given s2i build https://github.com/rh-openjdk/openjdk-container-test-applications.git from OPENJDK-2408-bin-custom-s2i-assemble with env
25+
| variable | value |
26+
| S2I_TARGET_CONFIGURATION_DIR | /var/tmp |
27+
Then s2i build log should not contain rsync: [generator] failed to set permissions on "/var/tmp/.": Operation not permitted
28+
And s2i build log should contain appsrc-provided s2i assemble script executed
29+
And run stat /var/tmp/example.ini in container and check its output for Access:
30+
31+
# as above, for OPENJDK-3975: handling data
32+
Scenario: Ensure copying custom data doesn't fail trying to chmod destination directory (OPENJDK-3975)
33+
Given s2i build https://github.com/rh-openjdk/openjdk-container-test-applications.git from OPENJDK-2408-bin-custom-s2i-assemble with env
34+
| variable | value |
35+
| S2I_TARGET_DATA_DIR | /var/tmp |
36+
Then s2i build log should not contain rsync: [generator] failed to set permissions on "/var/tmp/.": Operation not permitted
37+
And s2i build log should contain appsrc-provided s2i assemble script executed
38+
And run stat /var/tmp/sample.txt in container and check its output for Access:

0 commit comments

Comments
 (0)