Draft: Introduce Redis Cluster compatible adapter
What does this MR do and why?
Very rough draft but its working.
Spin up a gdk instance and open a few issues on the web ui. Try adding/removing labels, it should update across all tabs.
MR acceptance checklist
Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
How to set up and validate locally
- Set up gdk with
redis_cluster
enabled. - Spin up a Redis docker container. This helps with checking the
monitor
output in an isolated manner.docker run -p 6378:6379 -d redis:6.2-alpine
- Configure
config/cable.yml
➜ gitlab git:(sc1-sharded-pubsub-actioncable) cat config/cable.yml
development:
adapter: redis
url: redis://localhost:6378
channel_prefix: development_
- Open a few tabs on using
localhost:3000
. e.g.http://localhost:3000/gnuwget/Wget2/-/issues/2
- Run on 2 separate tabs:
redis-cli -p 6378 monitor
andredis-cli -p 6000 monitor
(run for 6001 and 6002 if you wish to monitor all shards). - Perform a few actions
- add/remove labels
- add/remove assignees
- modify weights
Observe on the Redis container that pub/sub commands are showing up and the labels are updated as expected across all tabs.
1714119096.927098 [0 172.17.0.1:37230] "subscribe" "development_:graphql-subscription:42742300-8438-4e8b-9c03-d4f46f074005"
1714119096.927110 [0 172.17.0.1:37230] "subscribe" "development_:graphql-subscription:09d7856a-0ced-4c46-b595-d3be2905b546"
1714119110.799087 [0 172.17.0.1:54948] "publish" "development_:graphql-event::workItemNoteCreated:noteableId:Z2lkOi8vZ2l0bGFiL1dvcmtJdGVtLzI4" "\"{\\\"wal_locations\\\":{},\\\"gql_payload\\\":[{\\\"__gid__\\\":\\\"Z2lkOi8vZ2l0bGFiL1Jlc291cmNlTGFiZWxFdmVudC80NDc\\\"}]}\""
1714119110.802376 [0 172.17.0.1:54948] "publish" "development_:noteable:notes:Z2lkOi8vZ2l0bGFiL0lzc3VlLzI4" "{\"event\":\"updated\"}"
1714119110.911721 [0 172.17.0.1:54948] "publish" "development_:graphql-event::issuableLabelsUpdated:issuableId:Z2lkOi8vZ2l0bGFiL0lzc3VlLzI4" "\"{\\\"wal_locations\\\":{},\\\"gql_payload\\\":{\\\"__gid__\\\":\\\"Z2lkOi8vZ2l0bGFiL0lzc3VlLzI4\\\"}}\""
- Enable the feature flag using rails console
Feature.enabled(:actioncable_cluster_migrate)
- Repeat step 6. We should see
spublish
on the Redis cluster monitors
1714119191.778661 [0 127.0.0.1:60249] "spublish" "development_:graphql-subscription:c167482f-8b52-4eff-a7e9-c6946a0665a8" "{\"result\":{\"data\":{\"issuableLabelsUpdated\":{\"id\":\"gid://gitlab/Issue/28\",\"labels\":{\"nodes\":[{\"id\":\"gid://gitlab/GroupLabel/29\",\"title\":\"Brickwood\",\"description\":null,\"color\":\"#efcf65\",\"textColor\":\"#1F1E24\",\"__typename\":\"Label\"},{\"id\":\"gid://gitlab/GroupLabel/21\",\"title\":\"Sofunc\",\"description\":null,\"color\":\"#c3e9ba\",\"textColor\":\"#1F1E24\",\"__typename\":\"Label\"},{\"id\":\"gid://gitlab/GroupLabel/26\",\"title\":\"Trareforge\",\"description\":null,\"color\":\"#3c8d76\",\"textColor\":\"#FFFFFF\",\"__typename\":\"Label\"},{\"id\":\"gid://gitlab/GroupLabel/24\",\"title\":\"Tryns\",\"description\":null,\"color\":\"#c4e742\",\"textColor\":\"#1F1E24\",\"__typename\":\"Label\"}],\"__typename\":\"LabelConnection\"},\"__typename\":\"Issue\"}}},\"more\":true}"
- Run
gdk restart rails-web
and repeat step 6
Observe ssubscribe
on the Redis Cluster but no subscribe
on the redis container.
1714119281.837643 [0 127.0.0.1:60283] "ssubscribe" "_action_cable_internal"
1714119283.865606 [0 127.0.0.1:60283] "ssubscribe" "development_:graphql-subscription:5d53d13e-7e32-4f03-a6a5-d0d5a2e3a6c9"
1714119283.879021 [0 127.0.0.1:60283] "ssubscribe" "development_:graphql-event::issuableEpicUpdated:issuableId:Z2lkOi8vZ2l0bGFiL0lzc3VlLzI4"
1714119283.926955 [0 127.0.0.1:60283] "ssubscribe" "development_:graphql-subscription:21507ca5-26eb-4384-b29f-68256a298a9b"
1714119283.928964 [0 127.0.0.1:60283] "ssubscribe" "development_:graphql-event::issuableDatesUpdated:issuableId:Z2lkOi8vZ2l0bGFiL0lzc3VlLzI4"
- Repeat step 6. Verify that tabs get updated. You should observe
spublish
on the Redis cluster alongside `publish in the redis container.
Edited by Sylvester Chin