Allow configuring redis instance for sessions
What does this MR do?
This allows adding a setting redis_sessions_instance and redis_sessions_sentinels in gitlab.rb to create a new configuration file for a separate Redis instance to store session data.
Related issues
gitlab-com/gl-infra/scalability#1335
gitlab-com/gl-infra&579 (closed)
gitlab-org/charts/gitlab!2234 (merged)
Rails: (Still in progress)
Test plan
We test two things:
Does it create a redis.sessions.yml
config file if you supply redis_sessions_instance
& redis_sessions_sentinels
values?
- Run omnibus against the current branch. Image available at registry.gitlab.com/gitlab-org/build/omnibus-gitlab-mirror/gitlab-ee:14.4.0-rfbranch.393408545.bb02c918-0
- Edit the
gitlab-rails['redis_sessions_instance']
(and optionally thegitlab-rails['redis_sessions_sentinels']
) setting to point to a redis instance. In this example I'm pointing it to the same redis socket, but a different database.
gitlab-rails['redis_sessions_instance'] = /var/opt/gitlab/redis/redis.socket?db=2
- Run
gitlab-ctl reconfigure
- Check that
redis.sessions.yml
is created at/var/opt/gitlab/gitlab-rails/etc/redis.sessions.yml
root@docker:/# find /var/opt/gitlab/gitlab-rails/etc/redis.sessions.yml
/var/opt/gitlab/gitlab-rails/etc/redis.sessions.yml
The contents of this file will be
production:
url: /var/opt/gitlab/redis/redis.socket?db=2
id:
The gitlab-ctl reconfigure
logs will show that a redis.sessions.yml
file is created as well
* templatesymlink[Create a redis.sessions.yml and create a symlink to Rails root] action create
* template[/var/opt/gitlab/gitlab-rails/etc/redis.sessions.yml] action create
- create new file /var/opt/gitlab/gitlab-rails/etc/redis.sessions.yml
- update content in file /var/opt/gitlab/gitlab-rails/etc/redis.sessions.yml from none to 0bfcfb
--- /var/opt/gitlab/gitlab-rails/etc/redis.sessions.yml 2021-10-22 08:26:33.599491119 +0000
+++ /var/opt/gitlab/gitlab-rails/etc/.chef-redis20211022-3275-39oe7s.sessions.yml 2021-10-22 08:26:33.596544781 +0000
@@ -1 +1,4 @@
+production:
+ url: /var/opt/gitlab/redis/redis.socket?db=2
+ id:
- change mode from '' to '0644'
- change owner from '' to 'root'
- change group from '' to 'root'
* link[Link /opt/gitlab/embedded/service/gitlab-rails/config/redis.sessions.yml to /var/opt/gitlab/gitlab-rails/etc/redis.sessions.yml] action create
- create symlink at /opt/gitlab/embedded/service/gitlab-rails/config/redis.sessions.yml to /var/opt/gitlab/gitlab-rails/etc/redis.sessions.yml
* file[/opt/gitlab/embedded/service/gitlab-rails/config/redis.sessions.yml] action delete (skipped due to only_if)
* file[/var/opt/gitlab/gitlab-rails/etc/redis.sessions.yml] action delete (skipped due to only_if)
Does it skip the creation of the redis.sessions.yml
file if you don't supply the abovementioned values?
- Run omnibus against the current branch. Image available at registry.gitlab.com/gitlab-org/build/omnibus-gitlab-mirror/gitlab-ee:14.4.0-rfbranch.393408545.bb02c918-0
- Run
gitlab-ctl reconfigure
- No
redis.sessions.yml
file is persisted.
root@docker:/# find /var/opt/gitlab/gitlab-rails/etc/redis.sessions.yml
find: ‘/var/opt/gitlab/gitlab-rails/etc/redis.sessions.yml’: No such file or directory
The gitlab-ctl reconfigure
logs will say the following about it:
* templatesymlink[Create a redis.sessions.yml and create a symlink to Rails root] action create (skipped due to not_if)
* file[/opt/gitlab/embedded/service/gitlab-rails/config/redis.sessions.yml] action delete (up to date)
* file[/var/opt/gitlab/gitlab-rails/etc/redis.sessions.yml] action delete (up to date)
Checklist
See Definition of done.
For anything in this list which will not be completed, please provide a reason in the MR discussion
Required
-
Merge Request Title, and Description are up to date, accurate, and descriptive -
MR targeting the appropriate branch -
MR has a green pipeline on GitLab.com -
Pipeline is green on dev.gitlab.org if the change is touching anything besides documentation or internal cookbooks -
trigger-package
has a green pipeline running against latest commit
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 -> since Rails support isn't complete, we cannot do this yet. -
Equivalent MR/issue for the GitLab Chart opened -> gitlab-org/charts/gitlab!2234 (merged)