*[Design and launch ticket](https://gitlab.torproject.org/tpo/tpa/team/-/issues/40364)
# Discussion
# Discussion
## Overview
## Overview
<!-- describe the overall project. should include a link to a ticket -->
The static shim was built to unblock the [Jenkins retirement
<!-- that has a launch checklist -->
project](https://gitlab.torproject.org/groups/tpo/-/milestones/27). A key blocker was that the [static mirror system][] was
strongly coupled with Jenkins: many high traffic and critical websites
<!-- if this is an old project being documented, summarize the known -->
are built and deployed by Jenkins. Unless we wanted to completely
<!-- issues with the project. to quote the "audit procedure":
retire the static mirror system (in favor, say, of GitLab Pages), we
had to create a way for GitLab CI to deploy content to the static
5. When was the last security review done on the project? What was
mirror system.
the outcome? Are there any security issues currently? Should it
have another security review?
6. When was the last risk assessment done? Something that would cover
risks from the data stored, the access required, etc.
7. Are there any in-progress projects? Technical debt cleanup?
Migrations? What state are they in? What's the urgency? What's the
next steps?
8. What urgent things need to be done on this project?
-->
## Goals
## Goals
<!-- include bugs to be fixed -->
### Must have
### Must have
* deploy sites from GitLab CI to the static mirror system
* site A cannot deploy to site B without being explicitly granted
permissions
* server-side (ie. in Puppet) access control (ie. user X can only
deploy site B)
### Nice to have
### Nice to have
* automate migration from Jenkins to avoid manually doing many sites
* reusable GitLab CI templates
### Non-Goals
### Non-Goals
* static mirror system replacement
## Approvals required
## Approvals required
<!-- for example, legal, "vegas", accounting, current maintainer -->
TPA
## Proposed Solution
## Proposed Solution
We have decided to deploy sites over SSH from GitLab CI, see below for
a discussion.
## Cost
## Cost
One VM, 20-30 hours of work, see [tpo/tpa/team#40364](https://gitlab.torproject.org/tpo/tpa/team/-/issues/40364) for time tracking.
## Alternatives considered
## Alternatives considered
This shim was designed to replace Jenkins with GitLab CI. As suche,
This shim was designed to replace Jenkins with GitLab CI. As suche,
...
@@ -478,6 +498,18 @@ webhooks, but originally decided against it for the following reasons:
...
@@ -478,6 +498,18 @@ webhooks, but originally decided against it for the following reasons:
exception and is more error prone (e.g. if we somehow forget the
exception and is more error prone (e.g. if we somehow forget the
`command=` override, we open full shell access)
`command=` override, we open full shell access)
After trying the webhook deployment mechanism (below), we decided to
go back to the deployment mechanism instead, because:
* the webhook implementation fails if sites take more than 10 seconds
to deploy.
* the webhook implementation doesn't provide much visibility on
failures or progress, to see the list of recent webhook calls, head
to Settings -> Webhooks -> Edit -> Recent deliveries
See below for details on that, and above for the full design of the
current deployment.
### webhook deployment
### webhook deployment
A designed based on GitLab webhooks was established, with a workflow
A designed based on GitLab webhooks was established, with a workflow
...
@@ -489,8 +521,7 @@ that goes something like this:
...
@@ -489,8 +521,7 @@ that goes something like this:
artifacts back to GitLab
artifacts back to GitLab
4. GitLab fires a [webhook](https://gitlab.torproject.org/help/user/project/integrations/webhooks#pipeline-events), typically on [pipeline events](https://docs.gitlab.com/ee/user/project/integrations/webhooks.html#pipeline-events)
4. GitLab fires a [webhook](https://gitlab.torproject.org/help/user/project/integrations/webhooks#pipeline-events), typically on [pipeline events](https://docs.gitlab.com/ee/user/project/integrations/webhooks.html#pipeline-events)
5. webhook receives the ping and authenticates against a
5. webhook receives the ping and authenticates against a
configuration, mapping to a given `static-component` (TODO: allow
configuration, mapping to a given `static-component`
list for gitlab?)
6. after authentication, the webhook fires a script
6. after authentication, the webhook fires a script
(`static-gitlab-shim-pull`)
(`static-gitlab-shim-pull`)
7.`static-gitlab-shim-pull` parses the payload from the webhook and
7.`static-gitlab-shim-pull` parses the payload from the webhook and