Skip to content

Add Geo replication for Pages (no verification) [RUN ALL RSPEC] [RUN AS-IF-FOSS]

Nick Nguyen requested to merge nhxnguyen-geo-pages-replication into master

What does this MR do?

Adds Geo replication for GitLab Pages deployments via the Geo self-service framework.

Closes #331931 (closed)

Screenshots or Screencasts (strongly suggested)

Geo site status pages_replication_node_status
Replicables Detail View pages_replication_details

How to setup and validate locally (strongly suggested)

  1. Set up GDK with Runner and Pages enabled and configured.
  2. Set up a second GDK Geo instance
  3. Enable feature flag with Feature.enable(:geo_pages_deployment_replication) in Rails console
  4. Create a GitLab Pages project and deploy a Pages site.
  5. Visit the Geo Sites Dashboard and validate that the Pages deployment was replicated.
  6. If you configure the secondary to serve Pages sites, you should also be able to view the site from the secondary.

Does this MR meet the acceptance criteria?

Conformity

Availability and Testing

Security

Does this MR contain changes to processing or storing of credentials or tokens, authorization and authentication methods or other items described in the security review guidelines? If not, then delete this Security section.

  • Label as security and @ mention @gitlab-com/gl-security/appsec
  • The MR includes necessary changes to maintain consistency between UI, API, email, or other methods
  • Security reports checked/validated by a reviewer from the AppSec team

Database Review

`rake geo:db:migrate` ```shell == 20210709162057 CreatePagesDeploymentRegistry: migrating ==================== -- table_exists?(:pages_deployment_registry) -> 0.0004s -- create_table(:pages_deployment_registry, {:id=>:bigserial, :force=>:cascade}) -> 0.0268s == 20210709162057 CreatePagesDeploymentRegistry: migrated (0.0284s) =========== ```
`rake geo:db:rollback` ```shell == 20210709162057 CreatePagesDeploymentRegistry: reverting ==================== -- drop_table(:pages_deployment_registry) -> 0.0181s == 20210709162057 CreatePagesDeploymentRegistry: reverted (0.0182s) =========== ```
`PagesDeployment.replicables_for_current_secondary`

Query:

SELECT
    "pages_deployments".*
FROM
    "pages_deployments"
WHERE
    "pages_deployments"."id" BETWEEN 1 AND 1000
    AND "pages_deployments"."file_store" = 1

Plan:

 Index Scan using index_pages_deployments_on_file_store_and_id on public.pages_deployments  (cost=0.42..2.60 rows=1 width=133) (actual time=10.949..10.950 rows=0 loops=1)
   Index Cond: ((pages_deployments.file_store = 1) AND (pages_deployments.id >= 1) AND (pages_deployments.id <= 1000))
   Buffers: shared hit=6 read=3
   I/O Timings: read=10.815 write=0.000
`PagesDeploymentRegistryFinder`

Query:

SELECT
    "pages_deployment_registry".*
FROM
    "pages_deployment_registry"
ORDER BY
    "pages_deployment_registry"."id" ASC

Plan:

                                    QUERY PLAN
----------------------------------------------------------------------------------
 Sort  (cost=1.05..1.06 rows=3 width=1170)
   Sort Key: id
   ->  Seq Scan on pages_deployment_registry  (cost=0.00..1.03 rows=3 width=1170)
(3 rows)
Edited by Nick Nguyen

Merge request reports