diff --git a/Dockerfile.cs.template b/Dockerfile.cs.template new file mode 100644 index 00000000..cd378997 --- /dev/null +++ b/Dockerfile.cs.template @@ -0,0 +1,10 @@ +# %%MARIADB_VERSION%% will be set by update.sh according to generating mariadb version image. +FROM mariadb:%%MARIADB_VERSION%% + +RUN apt-get update && \ + apt-get install -y mariadb-plugin-columnstore=%%MARIADB_VERSION%% ; \ + rm -rf /var/lib/apt/lists/* + +COPY docker-entrypoint-cs.sh /usr/local/bin/ + +ENTRYPOINT ["docker-entrypoint-cs.sh"] \ No newline at end of file diff --git a/docker-entrypoint-cs.sh b/docker-entrypoint-cs.sh new file mode 100755 index 00000000..94d7a792 --- /dev/null +++ b/docker-entrypoint-cs.sh @@ -0,0 +1,131 @@ +#!/bin/bash +set -eo pipefail + +# logging functions +mysql_log() { + local type="$1"; shift + printf '%s [%s] [Entrypoint]: %s\n' "$(date --rfc-3339=seconds)" "$type" "$*" +} +mysql_note() { + mysql_log Note "$@" +} +mysql_warn() { + mysql_log Warn "$@" >&2 +} +mysql_error() { + mysql_log ERROR "$@" >&2 + exit 1 +} + +# arg_splitter() { + +# } + +validate_args() { + local storage_manager_args= + storage_manager_args[0]=service + storage_manager_args[1]=object_size + storage_manager_args[2]=metadata_path + storage_manager_args[3]=max_concurrent_downloads + storage_manager_args[4]=max_concurrent_uploads + storage_manager_args[5]=common_prefix_depth + storage_manager_args[6]=region + storage_manager_args[7]=bucket + storage_manager_args[8]=endpoint + storage_manager_args[9]=aws_access_key_id + storage_manager_args[10]=aws_secret_access_key + storage_manager_args[11]=iam_role_name + storage_manager_args[12]=sts_region + storage_manager_args[13]=sts_endpoint + storage_manager_args[14]=ec2_iam_mode + storage_manager_args[15]=use_http + storage_manager_args[16]=ssl_verify + storage_manager_args[17]=libs3_debug + storage_manager_args[18]=path + storage_manager_args[19]=fake_latency + storage_manager_args[20]=max_latency + storage_manager_args[21]=cache_size + storage_manager_args[22]=cache_path + + for arg in $@; do + if [ $arg == '' ]; then + continue + fi + local arr=(${arg//=/ }) + local arg_key=${arr[0]} + local is_exist=false + for storage_manager_arg in "${storage_manager_args[@]}"; do + if [ "$storage_manager_arg" == "$arg_key" ]; then + is_exist=true + fi + done + if [ "$is_exist" != "true" ]; then + echo "argument $arg_key is unknown for storage-manager" >&2 + fi + done + + # *************CODE HERE**************** + # Now, Update the default values if arguments were provided by user relevant to the fields. +} + +get_storage_manager_default_values() { + # For [ObjectStorage] + service='LocalStorage' + object_size='5M' + metadata_path='@ENGINE_DATADIR@/storagemanager/metadata' + journal_path='@ENGINE_DATADIR@/storagemanager/journal' + max_concurrent_downloads=21 + max_concurrent_uploads=21 + common_prefix_depth=3 + + # For [S3] + region='' + bucket='' + endpoint='' + prefix='cs/' + aws_access_key_id='' + aws_secret_access_key='' + iam_role_name= + sts_region= + sts_endpoint= + ec2_iam_mode= + use_http= + ssl_verify= + libs3_debug= + + # The LocalStorage section configures the 'local storage' module + # if specified by ObjectStorage/service. + # [LocalStorage] + + # path specifies where the module should store object data. + path='@ENGINE_DATADIR@/storagemanager/fake-cloud' + fake_latency= + max_latency=50000 + + # [Cache] + cache_size='2g' + cache_path='@ENGINE_DATADIR@/storagemanager/cache' + +} + +_main() { + if [ "$1" = 'StorageManager' ]; then + # Run StorageManage of column-store + # storageManager's directroy :- /var/lib/columnstore/storagemanager + shift + validate_args "$@" + get_storage_manager_default_values + + echo "$@" + elif [ "$1" = 'brm' ]; then + # Run brm + echo "$@" + else + # if [ "$1" = 'mariadbd' ] or No argument then by default: + # simply start mariadb with column-store + exec docker-entrypoint.sh "$@" + fi +} + +# Runs _main() function. +_main "$@" \ No newline at end of file diff --git a/update.sh b/update.sh index b0eb27ab..42af87cf 100755 --- a/update.sh +++ b/update.sh @@ -29,6 +29,27 @@ declare -A suffix=( # For testing with https://downloads.dev.mariadb.org/rest-api typeset -r DOWNLOADS_REST_API="https://downloads.mariadb.org/rest-api" +update_cs_version() +{ + echo "Creating column store specific directory for mariadb version $version: $mariaVersion ($releaseStatus)" + + mkdir "$cs_dir" + cp Dockerfile.cs.template "$cs_dir/Dockerfile" + + cp docker-entrypoint-cs.sh healthcheck.sh "$cs_dir/" + chmod a+x "$cs_dir"/healthcheck.sh + sed -i \ + -e 's!%%MARIADB_VERSION%%!'"$mariaVersion"'!g' \ + "$cs_dir/Dockerfile" +} + +createCSImage() { + cs_dir="cs-$version" + if [ "${#versions[@]}" -gt 0 ] && [ "${versions[0]}" == "--cs" ] && [ ! -d "$cs_dir" ]; then + update_cs_version + fi +} + update_version() { echo "$version: $mariaVersion ($releaseStatus)" @@ -104,6 +125,8 @@ update_version() --arg milestone "$version" --arg version "$mariaVersion" --arg fullVersion "$fullVersion" --arg releaseStatus "$releaseStatus" --arg supportType "$supportType" --arg base "ubuntu:$suite" --arg arches "$arches" \ '.[$milestone] = {"milestone": $milestone, "version": $version, "fullVersion": $fullVersion, "releaseStatus": $releaseStatus, "supportType": $supportType, "base": $base, "arches": $arches|split(" ")}' versions.json)" printf '%s\n' "$versionJson" > versions.json + + createCSImage } update_version_array() @@ -151,18 +174,24 @@ in_development() version=$development_version mariaVersion=${development_version}.0 [ -d "$development_version" ] && update_version + if [ "${#versions[@]}" -gt 0 ] && [ "${versions[0]}" == "--cs" ]; then + createCSImage + fi } +versions=( "$@" ) -if [ $# -eq 0 ]; then +if [ $# -eq 0 ] || ( [ "${versions[0]}" == "--cs" ] && [ "$#" -eq 1 ] ); then all in_development exit 0 fi -versions=( "$@" ) for version in "${versions[@]}"; do + if [ "${version}" == "--cs" ]; then + continue + fi if [ "$version" == $development_version ]; then in_development continue @@ -180,3 +209,4 @@ for version in "${versions[@]}"; do update_version done +