2022-05-16: Staging CI-decomposition Dry-run
Production Change
Change Summary
Before executing an actual CI decomposition Phase 7 run (gitlab-org&7791 (closed)) on staging, we want to do a dry run to test the scripts work. No lasting configuration changes will be made.
Recording uploaded at https://youtu.be/odzlakKLagU (private as may contain logs)
Change Details
- Services Impacted - ServiceAPI ServiceWeb ServiceSidekiq
-
Change Technician -
@gsgl
with@tkuah
as support - Change Reviewer -
- Time tracking - unknown
- Downtime Component - only staging is affected - web, web sockets, git, ssh, kas, registry, sidekiq
Steps required prior to the CR taking place
Estimated Time to Complete (mins) - 5m
-
At T-3H, notify #g_delivery
and@release-managers
that work is starting in 3H to stop deployments.
Detailed steps for the change
Change Steps - steps to take to execute the change
Estimated Time to Complete (mins) - 5m
-
Set label changein-progress /label ~change::in-progress
Run maintenance-mode playbook in "enable" mode
Estimated Time to Complete (mins) - 1h (including manual checks)
Source: https://gitlab.com/gitlab-com/gl-infra/ansible-migrations/-/tree/master/maintenance-mode
-
SSH to gstg-console
-
Ensure you can reach the staging k8s clusters with kubectl
. We used to have instructions in the oncall guides, but we don't seem to anymore. It boils down to doinggcloud auth login
and ensuring you have your~/.kube/config
set-up with the regional + 3 zonal clusters by usinggcloud container clusters get-credentials <cluster>
. -
Start a tmux/screen session -
Clone repo: git clone https://gitlab.com/gitlab-com/gl-infra/ansible-migrations.git
-
Create virtualenv: python3 -m venv venv
-
Source venv: source venv/bin/activate
-
Prepare virtualenv: pip install --upgrade pip pip install -r ansible-migrations/maintenance-mode/requirements.txt
-
Run playbook: export CLOUDFLARE_API_TOKEN=X # in 1Password export CLOUDFLARE_ACCOUNT_ID=X # in Cloudflare dashboard export CLOUDFLARE_ZONE_ID=X # in Cloudflare dashboard export CLOUDFLARE_ZONE=staging.gitlab.com export ENVIRONMENT=gstg export GCP_PROJECT=gitlab-staging-1 cd ansible-migrations/maintenance-mode ansible-playbook -e @variables.yml --step enable.yml
When processing the
gke_gitlab-staging-1_us-east1_gstg-gitlab-gke
cluster, PAUSE after theSet replicas to zero (all EXCEPT sidekiq)
step so we can observe Sidekiq execution rates, queue lengths, etc).- Sidekiq overview Grafana: https://dashboards.gitlab.net/d/sidekiq-main/sidekiq-overview?orgId=1&from=now-24h&to=now&var-PROMETHEUS_DS=Global&var-environment=gstg&var-stage=main
- Sidekiq gstg Kibana: https://nonprod-log.gitlab.net/goto/f3294b80-d4bd-11ec-b3a6-472d0398dd6e
Once ready, you can just press
c
to continue the rest of the playbook without asking for confirmation at each step. -
Confirm that we can still access pages: https://staging.pages-check.gitlab.net/
Run CI Decomposition playbook
Estimated Time to Complete (mins) - 15m
-
Clone repo: git clone https://gitlab.com/gitlab-com/gl-infra/db-migration.git
-
Run playbook: cd db-migration/ci-decomposition ansible-playbook -i inventory/gstg.yml playbooks/1-pre-checks.yml ansible-playbook -i inventory/gstg.yml -e 'restart_pgbouncers=true' playbooks/2-stop.yml ansible-playbook -i inventory/gstg.yml playbooks/3-pre-promote.yml
-
Proceed with the rest of the steps of the playbook: ansible-playbook -i inventory/gstg.yml playbooks/4-promote.yml ansible-playbook -i inventory/gstg.yml -e 'restart_pgbouncers=true' playbooks/5-start.yml
No actual promotion takes place for this dry-run as we didn't specify
-t act
.
Run maintenance-mode playbook in "disable" mode
Estimated Time to Complete (mins) - 15m
-
Run playbook to start services: export CLOUDFLARE_API_TOKEN=X # in 1Password export CLOUDFLARE_ACCOUNT_ID=X # in Cloudflare dashboard export CLOUDFLARE_ZONE_ID=X # in Cloudflare dashboard export CLOUDFLARE_ZONE=staging.gitlab.com export ENVIRONMENT=gstg export GCP_PROJECT=gitlab-staging-1 cd ~/ansible-migrations/maintenance-mode ansible-playbook -e @variables.yml disable.yml
-
Run playbook to open up access in Cloudflare: ansible-playbook -e @variables.yml -t open-access disable.yml
Wrap-up
Estimated Time to Complete (mins) - 2m
-
Set label changecomplete /label ~change::complete
-
Notify #g_delivery
and@release-managers
that work is complete.
Rollback
Rollback steps - steps to be taken in the event of a need to rollback this change
-
Set label changeaborted /label ~change::aborted
This change does not make any lasting changes. It does, however, block inbound traffic to staging.
If pgbouncers are stopped, we need to start them back up:
-
SSH to gstg-console
-
Start a tmux/screen session -
Source venv: source venv/bin/activate
-
Run playbook: cd db-migration/ci-decomposition ansible-playbook -i inventory/gstg.yml -e 'restart_pgbouncers=true' playbooks/5-start.yml
Re-enable traffic to staging:
-
Run playbook: export CLOUDFLARE_EMAIL=X # in 1Password export CLOUDFLARE_API_KEY=X # in 1Password export CLOUDFLARE_ACCCOUNT_ID=X # in Cloudflare dashboard export CLOUDFLARE_ZONE_ID=X # in Cloudflare dashboard export CLOUDFLARE_ZONE=staging.gitlab.com export ENVIRONMENT=gstg export GCP_PROJECT=gitlab-staging-1 cd ansible-migrations/maintenance-mode ansible-playbook -e @variables.yml --step disable.yml
Monitoring
Key metrics to observe
- Metric: Metric Name
- Location: Dashboard URL
- What changes to this metric should prompt a rollback: Describe Changes
Change Reviewer checklist
-
Check if the following applies: - The scheduled day and time of execution of the change is appropriate.
- The change plan is technically accurate.
- The change plan includes estimated timing values based on previous testing.
- The change plan includes a viable rollback plan.
- The specified metrics/monitoring dashboards provide sufficient visibility for the change.
-
Check if the following applies: - The complexity of the plan is appropriate for the corresponding risk of the change. (i.e. the plan contains clear details).
- The change plan includes success measures for all steps/milestones during the execution.
- The change adequately minimizes risk within the environment/service.
- The performance implications of executing the change are well-understood and documented.
- The specified metrics/monitoring dashboards provide sufficient visibility for the change.
- If not, is it possible (or necessary) to make changes to observability platforms for added visibility?
- The change has a primary and secondary SRE with knowledge of the details available during the change window.
Change Technician checklist
-
Check if all items below are complete: - The change plan is technically accurate.
- This Change Issue is linked to the appropriate Issue and/or Epic
- Change has been tested in staging and results noted in a comment on this issue.
- A dry-run has been conducted and results noted in a comment on this issue.
- For C1 and C2 change issues, the SRE on-call has been informed prior to change being rolled out. (In #production channel, mention
@sre-oncall
and this issue and await their acknowledgement.) - Release managers have been informed (If needed! Cases include DB change) prior to change being rolled out. (In #production channel, mention
@release-managers
and this issue and await their acknowledgment.) - There are currently no active incidents that are severity1 or severity2
- If the change involves doing maintenance on a database host, an appropriate silence targeting the host(s) should be added for the duration of the change.