From 242f5c65d78b9de350e730cdd9cf14da5bd8d818 Mon Sep 17 00:00:00 2001 From: Filippe Spolti Date: Fri, 8 Sep 2023 16:52:45 -0300 Subject: [PATCH 1/3] [KIECLOUD-735] - Prepare RHPAM repositories for 7.13.5 release (#1693) Signed-off-by: Spolti --- modules/rhpam-kogito-prod-profile/module.yaml | 2 +- rhpam-kogito-builder-rhel8-overrides.yaml | 4 ++-- rhpam-kogito-imagestream.yaml | 18 +++++++++--------- rhpam-kogito-runtime-jvm-rhel8-overrides.yaml | 2 +- ...-kogito-runtime-native-rhel8-overrides.yaml | 2 +- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/modules/rhpam-kogito-prod-profile/module.yaml b/modules/rhpam-kogito-prod-profile/module.yaml index e589678aa..b897a5bd3 100644 --- a/modules/rhpam-kogito-prod-profile/module.yaml +++ b/modules/rhpam-kogito-prod-profile/module.yaml @@ -1,6 +1,6 @@ schema_version: 1 name: org.kie.kogito.rhpam.prod.profile -version: '7.13.4' +version: '7.13.5' description: Holds custom configurations for productized Kogito images. Add as first module to be installed. envs: diff --git a/rhpam-kogito-builder-rhel8-overrides.yaml b/rhpam-kogito-builder-rhel8-overrides.yaml index de0d6948e..485f88b38 100644 --- a/rhpam-kogito-builder-rhel8-overrides.yaml +++ b/rhpam-kogito-builder-rhel8-overrides.yaml @@ -1,7 +1,7 @@ schema_version: 1 name: "rhpam-7/rhpam-kogito-builder-rhel8" -version: "7.13.4" +version: "7.13.5" from: "registry.redhat.io/ubi8/ubi-minimal:latest" description: "RHPAM Platform for building Kogito based on Quarkus or SpringBoot" @@ -43,7 +43,7 @@ ports: modules: install: - name: org.kie.kogito.rhpam.prod.profile - version: "7.13.4" + version: "7.13.5" - name: org.kie.kogito.image.dependencies - name: org.kie.kogito.system.user - name: org.kie.kogito.logging diff --git a/rhpam-kogito-imagestream.yaml b/rhpam-kogito-imagestream.yaml index 7489d70f0..bec927df9 100644 --- a/rhpam-kogito-imagestream.yaml +++ b/rhpam-kogito-imagestream.yaml @@ -15,18 +15,18 @@ items: openshift.io/provider-display-name: Kie Group. spec: tags: - - name: '7.13.4' + - name: '7.13.5' annotations: description: RHPAM Runtime image for Kogito based on Quarkus or SpringBoot JVM image iconClass: icon-jbpm tags: rhpam-kogito,runtime,kogito,quarkus,springboot,jvm supports: quarkus - version: '7.13.4' + version: '7.13.5' referencePolicy: type: Local from: kind: DockerImage - name: registry.redhat.io/rhpam-7/rhpam-kogito-runtime-jvm-rhel8:7.13.4 + name: registry.redhat.io/rhpam-7/rhpam-kogito-runtime-jvm-rhel8:7.13.5 - kind: ImageStream apiVersion: v1 metadata: @@ -36,18 +36,18 @@ items: openshift.io/provider-display-name: Kie Group. spec: tags: - - name: '7.13.4' + - name: '7.13.5' annotations: description: RHPAM Runtime image for Kogito based on Quarkus native image iconClass: icon-jbpm tags: rhpam-kogito,runtime,kogito,quarkus,native supports: quarkus - version: '7.13.4' + version: '7.13.5' referencePolicy: type: Local from: kind: DockerImage - name: registry.redhat.io/rhpam-7/rhpam-kogito-runtime-native-rhel8:7.13.4 + name: registry.redhat.io/rhpam-7/rhpam-kogito-runtime-native-rhel8:7.13.5 - kind: ImageStream apiVersion: v1 metadata: @@ -57,16 +57,16 @@ items: openshift.io/provider-display-name: Kie Group. spec: tags: - - name: '7.13.4' + - name: '7.13.5' annotations: description: RHPAM Platform for building Kogito based on Quarkus or SpringBoot iconClass: icon-jbpm tags: rhpam-kogito,builder,kogito,quarkus,springboot supports: quarkus - version: '7.13.4' + version: '7.13.5' referencePolicy: type: Local from: kind: DockerImage - name: registry.redhat.io/rhpam-7/rhpam-kogito-builder-rhel8:7.13.4 + name: registry.redhat.io/rhpam-7/rhpam-kogito-builder-rhel8:7.13.5 diff --git a/rhpam-kogito-runtime-jvm-rhel8-overrides.yaml b/rhpam-kogito-runtime-jvm-rhel8-overrides.yaml index 3f37305df..9aa27d351 100644 --- a/rhpam-kogito-runtime-jvm-rhel8-overrides.yaml +++ b/rhpam-kogito-runtime-jvm-rhel8-overrides.yaml @@ -1,7 +1,7 @@ schema_version: 1 name: "rhpam-7/rhpam-kogito-runtime-jvm-rhel8" -version: "7.13.4" +version: "7.13.5" from: "registry.redhat.io/ubi8/ubi-minimal:latest" description: "RHPAM Runtime image for Kogito based on Quarkus or SpringBoot JVM image" diff --git a/rhpam-kogito-runtime-native-rhel8-overrides.yaml b/rhpam-kogito-runtime-native-rhel8-overrides.yaml index 77609f001..a388ea4ec 100644 --- a/rhpam-kogito-runtime-native-rhel8-overrides.yaml +++ b/rhpam-kogito-runtime-native-rhel8-overrides.yaml @@ -1,7 +1,7 @@ schema_version: 1 name: "rhpam-7/rhpam-kogito-runtime-native-rhel8" -version: "7.13.4" +version: "7.13.5" from: "registry.redhat.io/ubi8/ubi-minimal:latest" description: "RHPAM Runtime image for Kogito based on Quarkus native image" From 02bf16ca3bbe1d3bd4360f1ad7ac7318706b7e71 Mon Sep 17 00:00:00 2001 From: Filippe Spolti Date: Thu, 31 Aug 2023 10:54:18 -0300 Subject: [PATCH 2/3] [1.13.x-next][SRVLOGIC-158] - Dynamic resources script is reading wrong container sys files on cgroupsv2 (#1676) Signed-off-by: Spolti Co-authored-by: radtriste --- .../added/container-limits | 83 ++++++++++++++----- .../features/common-dynamic-resources.feature | 9 +- tests/test-apps/clone-repo.sh | 1 + 3 files changed, 69 insertions(+), 24 deletions(-) diff --git a/modules/kogito-dynamic-resources/added/container-limits b/modules/kogito-dynamic-resources/added/container-limits index 3445c49bd..a6c359c70 100644 --- a/modules/kogito-dynamic-resources/added/container-limits +++ b/modules/kogito-dynamic-resources/added/container-limits @@ -1,6 +1,5 @@ #!/bin/sh - -# Detected container limits +# Detects container limits # If found these are exposed as the following environment variables: # # - CONTAINER_MAX_MEMORY @@ -12,6 +11,16 @@ if [ "${SCRIPT_DEBUG}" = "true" ] ; then set -x fi +# query the resources based on cgroups version +# cgroups v1 points to tmpfs +# cgroups v2 points to cgroup2fs +CGROUPS_VERSION="v1" +tmp_fs=$(stat -fc %T /sys/fs/cgroup) +if [ "${tmp_fs}" = "cgroup2fs" ]; then + CGROUPS_VERSION="v2" +fi + + ceiling() { awk -vnumber="$1" -vdiv="$2" ' function ceiling(x){ @@ -23,21 +32,41 @@ ceiling() { ' } -# Based on the cgroup limits, figure out the max number of core we should utilize +# Based on the cgroups limits, figure out the max number of core we should use core_limit() { - local cpu_period_file="/sys/fs/cgroup/cpu/cpu.cfs_period_us" - local cpu_quota_file="/sys/fs/cgroup/cpu/cpu.cfs_quota_us" - if [ -r "${cpu_period_file}" ]; then - local cpu_period="$(cat ${cpu_period_file})" - - if [ -r "${cpu_quota_file}" ]; then - local cpu_quota="$(cat ${cpu_quota_file})" - # cfs_quota_us == -1 --> no restrictions - if [ "x$cpu_quota" != "x-1" ]; then - ceiling "$cpu_quota" "$cpu_period" + if [ "${CGROUPS_VERSION}" = "v1" ]; then + local cpu_period_file="/sys/fs/cgroup/cpu/cpu.cfs_period_us" + local cpu_quota_file="/sys/fs/cgroup/cpu/cpu.cfs_quota_us" + if [ -r "${cpu_period_file}" ]; then + local cpu_period="$(cat ${cpu_period_file})" + if [ -r "${cpu_quota_file}" ]; then + local cpu_quota="$(cat ${cpu_quota_file})" + # cfs_quota_us == -1 --> no restrictions + if [ "x$cpu_quota" != "x-1" ]; then + ceiling "$cpu_quota" "$cpu_period" + fi + fi + fi + else + # v2 + # on cgroupsv2 the period and quota a queried from the same file + local cpu_max_file="/sys/fs/cgroup/cpu.max" + # when both are set we will have the following output: + # $MAX $PERIOD + # where the first number is the quota/max and the second is the period + # if the quota/max is not set then we will have only the period set: + # max 100000 + if [ -r "${cpu_max_file}" ]; then + local cpu_max="$(cat ${cpu_max_file})" + if [ "x$cpu_max" != "x" ]; then + local cpu_quota="$(echo $cpu_max | awk '{print $1}')" + local cpu_period="$(echo $cpu_max | awk '{print $2}')" + if [ "$cpu_quota" != "max" ] && [ "x$cpu_period" != "x" ]; then + ceiling "$cpu_quota" "$cpu_period" + fi fi fi - fi + fi } max_unbounded() { @@ -45,13 +74,27 @@ max_unbounded() { } container_memory() { - # High number which is the max limit unit which memory is supposed to be unbounded. - local mem_file="/sys/fs/cgroup/memory/memory.limit_in_bytes" local max_mem_unbounded="$(max_unbounded)" - if [ -r "${mem_file}" ]; then - local max_mem="$(cat ${mem_file})" - if [ ${max_mem} -lt ${max_mem_unbounded} ]; then - echo "${max_mem}" + # High number which is the max limit unit which memory is supposed to be unbounded. + if [ "${CGROUPS_VERSION}" = "v1" ]; then + local mem_file="/sys/fs/cgroup/memory/memory.limit_in_bytes" + if [ -r "${mem_file}" ]; then + local max_mem="$(cat ${mem_file})" + if [ ${max_mem} -lt ${max_mem_unbounded} ]; then + echo "${max_mem}" + fi + fi + else + # v2 + local mem_file="/sys/fs/cgroup/memory.max" + if [ -r "${mem_file}" ]; then + local max_mem="$(cat ${mem_file})" + # if not set, it will contain only the string "max" + if [ "$max_mem" != "max" ]; then + if [ ${max_mem} -lt ${max_mem_unbounded} ]; then + echo "${max_mem}" + fi + fi fi fi } diff --git a/tests/features/common-dynamic-resources.feature b/tests/features/common-dynamic-resources.feature index faf92d2f3..0e8ef3186 100644 --- a/tests/features/common-dynamic-resources.feature +++ b/tests/features/common-dynamic-resources.feature @@ -48,10 +48,11 @@ Feature: Common tests for Kogito images And container log should match regex -Xmx512m Scenario: Verify if Java Remote Debug is correctly configured - When container is started with args - | arg | value | - | command | bash -c "sleep 2s; /home/kogito/kogito-app-launch.sh" | - | env_json | {"SCRIPT_DEBUG":"true", "JAVA_DEBUG":"true", "JAVA_DEBUG_PORT":"9222"} | + When container is started with env + | variable | value | + | SCRIPT_DEBUG | true | + | JAVA_DEBUG | true | + | JAVA_DEBUG_PORT | 9222 | Then container log should match regex -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=9222 Scenario: Verify if the DEFAULT MEM RATIO properties are overridden with different values from user provided Xmx and Xms diff --git a/tests/test-apps/clone-repo.sh b/tests/test-apps/clone-repo.sh index 39f61bea2..622f0035b 100755 --- a/tests/test-apps/clone-repo.sh +++ b/tests/test-apps/clone-repo.sh @@ -61,6 +61,7 @@ cp /tmp/kogito-examples/dmn-quarkus-example/src/main/resources/* /tmp/kogito-exa cp "${SCRIPT_DIR}"/application.properties /tmp/kogito-examples/rules-quarkus-helloworld/src/main/resources/META-INF/ (echo ""; echo "server.port=10000") >> /tmp/kogito-examples/ruleunit-springboot-example/src/main/resources/application.properties +git config commit.gpgsign false git add --all :/ git commit -am "test" From 3364f375a64093051bf03fdcc93f8c9cf84b7aff Mon Sep 17 00:00:00 2001 From: Roberto Oliveira Date: Wed, 28 Feb 2024 09:09:07 +0100 Subject: [PATCH 3/3] fix bats tests --- modules/kogito-dynamic-resources/added/container-limits | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/kogito-dynamic-resources/added/container-limits b/modules/kogito-dynamic-resources/added/container-limits index a6c359c70..e91ac335f 100644 --- a/modules/kogito-dynamic-resources/added/container-limits +++ b/modules/kogito-dynamic-resources/added/container-limits @@ -103,17 +103,17 @@ min() { printf "%s\n" "$@" | sort -g | head -n1 } -local limit="$(core_limit)" +limit="$(core_limit)" if [ x$limit != x ]; then export CONTAINER_CORE_LIMIT="$limit" fi -local env_core_limit="$(min $CONTAINER_CORE_LIMIT $JAVA_CORE_LIMIT)" +env_core_limit="$(min $CONTAINER_CORE_LIMIT $JAVA_CORE_LIMIT)" if [ -n "$env_core_limit" ]; then export CORE_LIMIT="$env_core_limit" fi -local max_mem="$(container_memory)" +max_mem="$(container_memory)" if [ x$max_mem != x ]; then export CONTAINER_MAX_MEMORY="$max_mem" fi