Skip to content

Expose setting to specify config_command in GitLab Workhorse config file

Balasankar 'Balu' C requested to merge 8363-workhorse-external-config into master

What does this MR do?

Expose setting to specify config_command in GitLab Workhorse config file. Depends on gitlab!140898 (merged)

Testing

  1. Deploy GitLab using the following docker-compose.yml file

    docker-compose.yml
    version: '3.8'
    name: 'gitlab-test'
    
    x-default_settings: &default_settings
      image: "${GITLAB_IMAGE:-registry.gitlab.com/gitlab-org/omnibus-gitlab/gitlab-ee:8363-workhorse-external-config}"
      pull_policy: always
      privileged: true
      shm_size: '256m'
      restart: always
    
    services:
      redis:
        <<: *default_settings
        environment:
          GITLAB_OMNIBUS_CONFIG: |
            roles ['redis_master_role']
    
            # Redis configuration
            redis['bind'] = '10.0.0.2'
            redis['port'] = 6379
            redis['password'] = 'redis-password'
    
            # This is a pure Redis node. We don't need Rails stuff.
            gitlab_rails['enable'] = false
        networks:
          default:
            ipv4_address: 10.0.0.2
        healthcheck:
          test: ["CMD", "gitlab-redis-cli", "ping"]
          start_period: 60s
      gitlab:
        <<: *default_settings
        environment:
          GITLAB_OMNIBUS_CONFIG: |
            external_url "http://127.0.0.1"
    
            # Disable bundled Redis
            redis['enable'] = false
    
            # Disable PG
            postgresql['enable'] = false
    
            # Disable everything else that uses Redis
            gitlab_rails['enable'] = false
            gitlab_kas['enable'] = false
            prometheus_monitoring['enable'] = false
    
            # Enable GitLab Workhorse
            gitlab_workhorse['enable'] = true
            # GitLab Exporter uses the Redis information from `gitlab_rails`
            gitlab_rails['redis_host'] = '10.0.0.2'
            gitlab_rails['redis_port'] = '6379'
        ports:
          - "80:80"
          - "443:443"
          - "22:22"
        networks:
          default:
            ipv4_address: 10.0.0.3
        healthcheck:
          disable: true
        depends_on:
          redis:
            condition: service_healthy
    
    networks:
      default:
        ipam:
          config:
            - subnet: 10.0.0.0/24
  2. Check the logs of gitlab-workhorse and see that it shows a warning about Redis not having an auth

  3. In the gitlab container, create the file /opt/redis-for-workhorse.sh with the following content

    #!/usr/bin/env bash
    
    cat <<EOF
    {
      "redis": {
        "password": "redis-password"
      }
    }
    EOF
  4. Make it executable

    $ chmod +x /opt/redis-for-workhorse.sh
  5. Add the following to /etc/gitlab/gitlab.rb

    gitlab_workhorse['extra_config_command'] = '/opt/redis-for-workhorse.sh'
  6. Run gitlab-ctl reconfigure and see that the error in gitlab-workhorse logs regarding Redis auth is gone.

Related issues

Closes #8363 (closed)

Checklist

See Definition of done.

For anything in this list which will not be completed, please provide a reason in the MR discussion.

Required

  • MR title and description are up to date, accurate, and descriptive.
  • MR targeting the appropriate branch.
  • Latest Merge Result pipeline is green.
  • When ready for review, MR is labeled "~workflow::ready for review" per the Distribution MR workflow.

For GitLab team members

If you don't have access to this, the reviewer should trigger these jobs for you during the review process.

  • The manual Trigger:ee-package jobs have a green pipeline running against latest commit.
  • If config/software or config/patches directories are changed, make sure the build-package-on-all-os job within the Trigger:ee-package downstream pipeline succeeded.
  • If you are changing anything SSL related, then the Trigger:package:fips manual job within the Trigger:ee-package downstream pipeline must succeed.
  • If CI configuration is changed, the branch must be pushed to dev.gitlab.org to confirm regular branch builds aren't broken.

Expected (please provide an explanation if not completing)

  • Test plan indicating conditions for success has been posted and passes.
  • Documentation created/updated.
  • Tests added.
  • Integration tests added to GitLab QA.
  • Equivalent MR/issue for the GitLab Chart opened.
  • Validate potential values for new configuration settings. Formats such as integer 10, duration 10s, URI scheme://user:passwd@host:port may require quotation or other special handling when rendered in a template and written to a configuration file.
Edited by Robert Marshall

Merge request reports