diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 8333233caecbb7ce550643597145d956b2d9283c..a0b841f5c8078e44ac038a34d85e1fd3c3ed3d0a 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -223,6 +223,23 @@ gitlab-task-runner-ce: - gitlab-rails-ce <<: *except-ee +gitlab-geo-logcursor: + <<: *job-base + stage: phase-six + script: + - ruby_version=$(get_version gitlab-ruby) + - rails_version=$(get_version gitlab-rails) + - rails_container=$(cat artifacts/rails_container_ee.txt) + - export FORCE_IMAGE_BUILDS="${FORCE_IMAGE_BUILDS-${FORCE_RAILS_IMAGE_BUILDS-false}}" + - export CONTAINER_VERSION=($(echo -n "$rails_container$TARGET_VERSION" | sha1sum)) + - export BASE_IMAGE="$CI_REGISTRY_IMAGE/gitlab-rails-ee:$rails_container" + - build_if_needed --build-arg "FROM_IMAGE=$CI_REGISTRY_IMAGE/gitlab-rails-ee" + --build-arg "TAG=$rails_container" + - push_if_master_or_stable_or_tag $GITLAB_REF_SLUG + dependencies: + - gitlab-rails-ee + <<: *except-ce + gitlab-unicorn-ee: <<: *job-base stage: phase-six diff --git a/gitlab-geo-logcursor/Dockerfile b/gitlab-geo-logcursor/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..e457c6f949a3a648c721e3c9e9cdc8e23eaf3a2f --- /dev/null +++ b/gitlab-geo-logcursor/Dockerfile @@ -0,0 +1,21 @@ +ARG CI_REGISTRY_IMAGE="registry.gitlab.com/gitlab-org/build/cng" +ARG FROM_IMAGE="$CI_REGISTRY_IMAGE/gitlab-rails-ee" +ARG TAG=latest + +FROM ${FROM_IMAGE}:${TAG} + +ARG DATADIR=/var/opt/gitlab +ARG CONFIG=/srv/gitlab/config +ARG GITLAB_USER=git + +# Control the target for `wait-for-deps` schema check +ENV DB_SCHEMA_TARGET=geo + +USER $GITLAB_USER:$GITLAB_USER + +COPY scripts/ /scripts + +CMD /scripts/process-wrapper + +HEALTHCHECK --interval=30s --timeout=30s --retries=5 \ +CMD /scripts/healthcheck diff --git a/gitlab-geo-logcursor/scripts/healthcheck b/gitlab-geo-logcursor/scripts/healthcheck new file mode 100755 index 0000000000000000000000000000000000000000..8a70662246d6a9a0e8f31afe403571d47a943ad8 --- /dev/null +++ b/gitlab-geo-logcursor/scripts/healthcheck @@ -0,0 +1,6 @@ +#!/bin/bash + +set -e + +# Check that geo_log_cursor is running +/usr/bin/pgrep -f "/srv/gitlab/ee/bin/geo_log_cursor" diff --git a/gitlab-geo-logcursor/scripts/process-wrapper b/gitlab-geo-logcursor/scripts/process-wrapper new file mode 100755 index 0000000000000000000000000000000000000000..bd6bd2326305f844723bf6be1ea4d704a9eaf8c2 --- /dev/null +++ b/gitlab-geo-logcursor/scripts/process-wrapper @@ -0,0 +1,9 @@ +#!/bin/bash + +set -e + +cd /srv/gitlab + +# Start geo_log_cursor, logging via stdout. +echo "Starting geo_log_cursor" +/srv/gitlab/ee/bin/geo_log_cursor --stdout-logging ${GEO_LOGCURSOR_ARGUMENTS} diff --git a/gitlab-rails/scripts/wait-for-deps b/gitlab-rails/scripts/wait-for-deps index 4d35bd1be083800379de0a7957ce18024ae9b507..2d0b91c3299f3e8b82dfeec0e09b6c32bc97c7c2 100755 --- a/gitlab-rails/scripts/wait-for-deps +++ b/gitlab-rails/scripts/wait-for-deps @@ -2,16 +2,24 @@ WAIT_FOR_TIMEOUT="${WAIT_FOR_TIMEOUT:-5}" +# Configure for which schema to be verifying +SCHEMA_FILE=db/schema.rb +SCHEMA_RAKE_TASK=db:version +if [ "${DB_SCHEMA_TARGET,,}" == "geo" ]; then + SCHEMA_FILE=ee/db/geo/schema.rb + SCHEMA_RAKE_TASK=geo:db:version +fi + cd /srv/gitlab # fetch the schema desired version directly from the source code -SCHEMA_VERSION=$(grep '(version: ' /srv/gitlab/db/schema.rb | sed -e 's/_//g' -e 's/.* \([[:digit:]]\+\)) do/\1/') +SCHEMA_VERSION=$(grep '(version: ' ${SCHEMA_FILE} | sed -e 's/_//g' -e 's/.* \([[:digit:]]\+\)) do/\1/') # Compare desired schema version to active schema version in the database # - set BYPASS_SCHEMA_VERSION to skip version check, and only test DB online function checkSchemaVersion() { # Ask for the current DB schema version, via Rake - DB_SCHEMA_VERSION=$(/srv/gitlab/bin/bundle exec rake db:version) + DB_SCHEMA_VERSION=$(/srv/gitlab/bin/bundle exec rake ${SCHEMA_RAKE_TASK}) # If rake failed, we're not connected to the DB, and DB_SCHEMA_VERSION is empty. if [ $? -ne 0 ]; then