Skip to content

Commit

Permalink
Merge branch 'main' into feature/754-healthendpoint-service-refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
bonzofenix authored Jul 28, 2024
2 parents bf33a99 + 2ed9059 commit 3f1d58f
Show file tree
Hide file tree
Showing 10 changed files with 73 additions and 33 deletions.
6 changes: 4 additions & 2 deletions ci/autoscaler/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,10 @@ resources:
check_every: 5m
source:
uri: https://github.com/SAP/SapMachine.git
branch: sapmachine
version_depth: 20
branch: sapmachine21 # use JDK 21 as the LTS version
fetch_tags: true
tag_regex: 'sapmachine-[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+'
version_depth: 50

- name: gcp-jammy-stemcell
type: bosh-io-stemcell
Expand Down
13 changes: 9 additions & 4 deletions ci/autoscaler/tasks/update-sdk/download_java.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,24 @@

set -euo pipefail

JAVA_VERSION=${1:-"21.0.3"} # default java version
script_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
source "${script_dir}/vars.source.sh"

JAVA_VERSION=${1:-"21.0.3"}

# Step 1 --> Download java from https://github.com/SAP/SapMachine/releases/download/sapmachine-21.0.3/sapmachine-jdk-21.0.3_linux-x64_bin.tar.gz
SAP_MACHINE_BASE_URL="https://github.com/SAP/SapMachine"
binary_name="sapmachine-jdk-${JAVA_VERSION}_linux-x64_bin.tar.gz"

printf "\n"

jdk_download_url="${SAP_MACHINE_BASE_URL}/releases/download/sapmachine-${JAVA_VERSION}/${binary_name}"

echo "Fetching SAP Machine JDK from ${JAVA_VERSION} ${jdk_download_url}"
mkdir -p src/binaries/jdk && pushd src/binaries/jdk > /dev/null
echo "Fetching SAP Machine JDK ${JAVA_VERSION} from ${jdk_download_url}"
# shellcheck disable=SC2154
pushd "${autoscaler_dir}"
mkdir -p src/binaries/jdk && pushd src/binaries/jdk > /dev/null
curl -JLO "${jdk_download_url}"
popd > /dev/null
popd > /dev/null

# Step 2 --> Build java
Expand Down
68 changes: 49 additions & 19 deletions ci/autoscaler/tasks/update-sdk/update_java_package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,47 +2,79 @@

# This script is used to update the java version used in the bosh packaging
# It downloads the given SAP Machine java distribution and updates the bosh packaging with the new version.
# usage: ./update_java_package 21.0.3

[ -n "${DEBUG}" ] && set -x
set -euo pipefail

script_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
source "${script_dir}/vars.source.sh"

JAVA_VERSION=${1:-"21.0.3"} # default java version
java_dir=${JAVA_DIR:-"${autoscaler_dir}/../SapMachine"}
java_dir=$(realpath --canonicalize-existing "${java_dir}")

pushd "${java_dir}"
java_major_version=$(grep "DEFAULT_JDK_SOURCE_TARGET_VERSION" make/conf/version-numbers.conf | cut -d= -f2)
java_version_interim=$(grep "DEFAULT_VERSION_INTERIM" make/conf/version-numbers.conf | cut -d= -f2)
java_version_update=$(grep "DEFAULT_VERSION_UPDATE" make/conf/version-numbers.conf | cut -d= -f2)
java_version_prerelease=$(grep "DEFAULT_PROMOTED_VERSION_PRE" make/conf/version-numbers.conf | cut -d= -f2)
popd

sapmachine_java_version="${java_major_version}.${java_version_interim}.${java_version_update}"
echo "Desired Java Version: ${sapmachine_java_version}"

# consider only lts releases
if [ "${java_version_prerelease}" != "" ]; then
echo "java version ${sapmachine_java_version} is not a LTS release. skipping update"
exit 0
fi

JAVA_VERSION=${sapmachine_java_version:-"21.0.3"}
desired_major_version=${JAVA_VERSION%%.*}

# identify current version
current_major_version=$(find ./packages -type d -name "openjdk-*" -exec bash -c '
# shellcheck disable=SC2154
current_major_version=$(find "${autoscaler_dir}/packages" -type d -name "openjdk-*" -exec bash -c '
directory_name="$1"
version_number=${directory_name#*-}
version_number=${directory_name##*-}
echo "${version_number}"
' bash {} \;)
# shellcheck disable=SC2154
current_java_version=$(cat "${autoscaler_dir}/packages/openjdk-${current_major_version}/version")
echo "Checking current Java Versions"
echo " - Full version: ${current_java_version}"

if [ "${JAVA_VERSION}" == "${current_java_version}" ]; then
echo "Already on java version ${JAVA_VERSION}. No need to update the java version"
exit 0
fi

# Step 1 --> Download java...
source "${script_dir}/download_java.sh" "${JAVA_VERSION}"
printf "\n"

# Step 2 --> upload blob to blobstore
binary_name="sapmachine-jdk-${JAVA_VERSION}_linux-x64_bin.tar.gz"
pushd "${autoscaler_dir}" > /dev/null
echo "- Adding and uploading blobs to release blobstore "
bosh add-blob "src/binaries/jdk/${binary_name}" "${binary_name}"
create_bosh_config
bosh upload-blobs
popd > /dev/null

# Step 2 --> upload blob to blobstore
echo "- Adding and uploading blobs to release blobstore "
bosh add-blob "${autoscaler_dir}/src/binaries/jdk/${binary_name}" "${binary_name}"
create_bosh_config
bosh upload-blobs
printf "\n"

# Step 3 --> update bosh java package references
echo "- updating bosh java packages..."
# shellcheck disable=SC2038
find . -type f ! -name "*.yml" ! -name "update_java_package.sh" ! -path '*/\.*' -exec grep --files-with-matches "openjdk-${current_major_version}" {} \;| xargs sed --in-place "s/openjdk-${current_major_version}/openjdk-${desired_major_version}/g"
mv ./packages/openjdk-"${current_major_version}" ./packages/openjdk-"${desired_major_version}"
# only change java references if major versions are different
if [ "${current_major_version}" != "${desired_major_version}" ]; then
find "${autoscaler_dir}" -type f ! -name "*.yml" ! -name "update_java_package.sh" ! -path '*/\.*' -exec grep -l "openjdk-${current_major_version}" {} \;| xargs sed -i "s/openjdk-${current_major_version}/openjdk-${desired_major_version}/g"
mv "${autoscaler_dir}/packages/openjdk-${current_major_version}" "${autoscaler_dir}/packages/openjdk-${desired_major_version}"
exit 0
fi

echo " - creating spec file"
cat > "packages/openjdk-$desired_major_version/spec" <<EOF
cat > "${autoscaler_dir}/packages/openjdk-$desired_major_version/spec" <<EOF
---
name: openjdk-${desired_major_version}
dependencies: []
Expand All @@ -51,20 +83,18 @@ files:
EOF

echo " - creating packaging script "
cat > "packages/openjdk-$desired_major_version/packaging" <<EOF
cat > "${autoscaler_dir}/packages/openjdk-$desired_major_version/packaging" <<EOF
set -ex
# compile and runtime bosh env vars
export JAVA_HOME=/var/vcap/packages/openjdk-$desired_major_version
export PATH=\$JAVA_HOME/bin:\$PATH
cd \${BOSH_INSTALL_TARGET}
# extract jdk from src/binaries/jdk
tar zxvf \${BOSH_COMPILE_TARGET}/*.tar.gz --strip 1
EOF

# creates pr
echo -n "${JAVA_VERSION}" > "${AUTOSCALER_DIR}/version"
echo -n "${JAVA_VERSION}" > "${AUTOSCALER_DIR}/vendored-commit"

echo -n "${JAVA_VERSION}" > "./packages/openjdk-${desired_major_version}/version"
#required for PR creation
echo -n "${JAVA_VERSION}" > "${autoscaler_dir}/version"
echo -n "${JAVA_VERSION}" > "${autoscaler_dir}/vendored-commit"
echo -n "${JAVA_VERSION}" > "${autoscaler_dir}/packages/openjdk-${desired_major_version}/version"
3 changes: 1 addition & 2 deletions ci/autoscaler/tasks/update-sdk/update_package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ set -euo pipefail
script_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
source "${script_dir}/vars.source.sh"
create_pr=${CREATE_PR:-"false"}
java_version=${1:-"21.0.3"} # default java version

# shellcheck disable=SC2154
"${script_dir}"/update_"${type}"_package.sh "$java_version"
"${script_dir}"/update_"${type}"_package.sh
[[ ${create_pr} == "true" ]] && "${script_dir}"/create_pr.sh
2 changes: 1 addition & 1 deletion ci/dockerfiles/autoscaler-tools/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ RUN wget -q https://github.com/cloudfoundry/bosh-bootloader/releases/download/${

# Install credhub
# renovate: datasource=github-releases depName=credhub-cli lookupName=cloudfoundry/credhub-cli
ARG CREDHUB_VERSION=2.9.34
ARG CREDHUB_VERSION=2.9.35
RUN wget -q https://github.com/cloudfoundry/credhub-cli/releases/download/${CREDHUB_VERSION}/credhub-linux-amd64-${CREDHUB_VERSION}.tgz && \
tar xvfz credhub-linux-amd64-${CREDHUB_VERSION}.tgz && \
mv credhub /usr/local/bin/credhub &&\
Expand Down
4 changes: 4 additions & 0 deletions config/blobs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,7 @@ sapmachine-jdk-21.0.3_linux-x64_bin.tar.gz:
size: 207918252
object_id: 1379a421-7184-4d17-540e-2b15a5c066c8
sha: sha256:774bb6f5cf54ff22a64c289edf64c4772efe3f200e4f7e781d5e316651290e81
sapmachine-jdk-21.0.4_linux-x64_bin.tar.gz:
size: 208055144
object_id: a5bb48f2-ae8e-4b00-7655-b553b1a264d7
sha: sha256:9c4779b48a9d6f8120901e6c095227baebd2af2d7d7db1b0196c144ae9b9397d
2 changes: 1 addition & 1 deletion packages/openjdk-21/spec
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
name: openjdk-21
dependencies: []
files:
- sapmachine-jdk-21.0.3_linux-x64_bin.tar.gz # from https://github.com/SAP/SapMachine/releases/download/sapmachine-21.0.3/sapmachine-jdk-21.0.3_linux-x64_bin.tar.gz
- sapmachine-jdk-21.0.4_linux-x64_bin.tar.gz # from https://github.com/SAP/SapMachine/releases/download/sapmachine-21.0.4/sapmachine-jdk-21.0.4_linux-x64_bin.tar.gz
2 changes: 1 addition & 1 deletion packages/openjdk-21/version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
21.0.3
21.0.4
2 changes: 1 addition & 1 deletion src/autoscaler/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ require (
go.opentelemetry.io/otel/sdk v1.27.0
go.opentelemetry.io/otel/trace v1.27.0
golang.org/x/crypto v0.25.0
golang.org/x/exp v0.0.0-20240716175740-e3f259677ff7
golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56
golang.org/x/net v0.27.0
golang.org/x/time v0.5.0
google.golang.org/grpc v1.65.0
Expand Down
4 changes: 2 additions & 2 deletions src/autoscaler/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1102,8 +1102,8 @@ golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u0
golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM=
golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU=
golang.org/x/exp v0.0.0-20220827204233-334a2380cb91/go.mod h1:cyybsKvd6eL0RnXn6p/Grxp8F5bW7iYuBgsNCOHpMYE=
golang.org/x/exp v0.0.0-20240716175740-e3f259677ff7 h1:wDLEX9a7YQoKdKNQt88rtydkqDxeGaBUTnIYc3iG/mA=
golang.org/x/exp v0.0.0-20240716175740-e3f259677ff7/go.mod h1:M4RDyNAINzryxdtnbRXRL/OHtkFuWGRjvuhBJpk2IlY=
golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 h1:2dVuKD2vS7b0QIHQbpyTISPd0LeHDbnYEryqj5Q1ug8=
golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56/go.mod h1:M4RDyNAINzryxdtnbRXRL/OHtkFuWGRjvuhBJpk2IlY=
golang.org/x/image v0.0.0-20180708004352-c73c2afc3b81/go.mod h1:ux5Hcp/YLpHSI86hEcLt0YII63i6oz57MZXIpbrjZUs=
golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js=
golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
Expand Down

0 comments on commit 3f1d58f

Please sign in to comment.