Skip to content

Openverse is a search engine for openly-licensed media. This monorepo includes all application code.

Incident Response Plan (#2679)

Zack Krida126f2031c307
diff --git a/documentation/meta/incidents/index.md b/documentation/meta/incidents/index.md
new file mode 100644
index 000000000..3735303ae
--- /dev/null
+++ b/documentation/meta/incidents/index.md
@@ -0,0 +1,171 @@
+# Responding to Incidents
+
+```{note}
+Currently experiencing an issue with Openverse? For maintainers, please jump to the [Incident Response Runbook](/meta/incidents/runbooks/incident_response_runbook). Otherwise,
+please [file a bug report](https://github.com/WordPress/openverse/issues/new?template=bug_report.md&title=Production+Incident:+Describe+the+incident) in GitHub,
+[submit a security advisory](https://github.com/WordPress/openverse/security/advisories/new), or send a message in the
+[Making WordPress Chat](https://make.wordpress.org/chat/), to the `#openverse`
+channel.
+```
+
+This document defines the policy for handling technical production incidents
+that occur within Openverse. The goal is to ensure that user-facing service
+disruptions are handled promptly, efficiently, and effectively, mitigating
+impact on our users and maintaining the highest level of service availability
+possible.
+
+## What is an incident?
+
+This document and the referenced runbooks refer to incidents as technical
+problems with our services (Openverse.org, the Openverse API, and "official"
+integrations like the WP core integration and pattern directory integrations).
+Here are some example incidents:
+
+- The API is serving slower-than-typical responses which occasionally time out
+- Openverse.org has a critical bug preventing search for mobile users using RTL
+ languages
+- Openverse.org is completely offline
+- Production resource usage is skyrocketing and could lead to downtime, but
+ users are not impacted yet
+
+```{note}
+There may be other issues that Openverse and its maintainers face related to its reputation or the community.
+Those issues require a different approach which is not covered in the scope of this document.
+```
+
+It is crucial to be proactive here; if something _might_ be an incident, but
+you’re not certain, it is better to record it than to ignore it. Do not assume
+"someone else" is handling an incident unless they have explicitly recorded it
+using the process defined here.
+
+## How do we _identify_ incidents?
+
+Incidents are detected through various channels such as automated alerts, user
+reports, or through manual checks by maintainers. The Mini Support Rotation
+(MSR) runner makes these checks as part of their daily responsibilities.
+
+While the MSR runner monitors our communication channels closely, **any online
+maintainer who sees something that might be an incident should follow the
+incident recording process outlined here.** This does not mean that the
+reporting maintainer is inherently responsible for stabilizing the incident or
+investigating the root cause. It only means that they are responsible for making
+the initial report on the incident. Additionally, maintainers who stabilize
+services may not be the ones to perform the investigation after stabilization
+has been reached. Every incident has a [**Lead**](#how-do-we-determine-the-lead)
+who is the person responsible for providing updates on the incident and
+delegating tasks. The Lead is also responsible for hosting the retrospective
+after the incident is resolved.
+
+## How do we _classify_ incidents?
+
+Incidents are classified in two ways:
+
+- **Severity** - The impact of the incident
+- **Status** - The current state of the incident
+
+### Severity
+
+Incidents are classified using one of three levels of severity. It is important
+to note that regardless of severity, working to stabilize services (or whatever
+harm mitigation is relevant for the incident) always **takes priority over
+regular project work and MSR duties.** Once services are stabilized, any ongoing
+investigations, preventative measures, or documentation changes will be
+prioritized by the team alongside our other work.
+
+This severity scale is intentionally distinct from our GitHub priority scale.
+Any GitHub issues created to _stabilize_ a Severity 1 or Severity 2 incident are
+marked as "critical" in GitHub. Other issues are prioritized at your own
+discretion.
+
+- **Severity 1**: Critical issue affecting all/most users and all/most
+ functionalities of Openverse.
+- **Severity 2**: Major issue affecting a large number of users or critical
+ functionality of Openverse.
+- **Severity 3**: Minor issue affecting a limited number of users or
+ non-critical functionality of Openverse.
+
+### Status
+
+- **Stabilization pending** - The incident is actively disrupting service.
+- **Stabilized** - The incident is no longer directly disrupting service. Root
+ causes may still be unknown.
+- **Under investigation** - The root causes of the incident are being
+ researched. Stabilized but not yet resolved. Fixes may be identified but not
+ yet implemented.
+- **Resolved** - The incident is stable, and short-term/immediate fixes to
+ prevent future occurrences have been implemented. Long-term fixes and
+ improvements may still be open for work to be prioritized along with all other
+ work.
+- **Reviewed** - A retrospective has been completed for the incident.
+
+As you might expect, incidents can be _destabilized_ if they reoccur, and the
+state should roll back to "Stabilization pending". Some incidents may not
+require further investigation once they are stabilized and can be immediately
+resolved. If more than 48 hours have elapsed from the resolution of an incident
+and it recurs, a new incident should be created.
+
+```{mermaid}
+graph LR
+ A[Stabilization pending]
+ B[Stabilized]
+ C[Under investigation]
+ D[Resolved]
+
+ A --> B
+ B --> C
+ B --> A
+ C --> A
+ C --> D
+ B --> D
+ D --> A
+```
+
+## How do we _handle_ incidents?
+
+```{warning}
+Dealing with an incident now? Go to the [Incident Response Runbook](/meta/incidents/runbooks/incident_response_runbook).
+```
+
+This section addresses the philosophy of our approach to incident management and
+explanation behind the steps in the
+[runbook](/meta/incidents/runbooks/incident_response_runbook).
+
+There are five main steps to handling production incidents:
+
+<!-- prettier-ignore -->
+| # | Name | Goal | Tag | Status After |
+|---|-------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------|------------------------------------------------------|
+| 1 | Record | Visibly acknowledge the incident and create the communication threads necessary for ongoing discussion and investigation. Understand how bad the situation is based on our severity definitions. | `#status-recorded` | Stabilization pending OR Stabilized (as appropriate) |
+| 2 | Stabilize | If there is a total or partial outage, identify service stabilization options and action them. | `#status-stabilized` | Stabilized |
+| 3 | Investigate | Identify outstanding improvements to the service that would mitigate the issue in the future and create tickets to implement. | `#status-investigating` | Under investigation OR Resolved (as appropriate) |
+| 4 | Resolve | Complete the immediately necessary work to prevent this issue from recurring in the future. | `#status-resolved` | Review (if needed) |
+| 5 | Review | Identify process improvements. If the underlying cause is still unknown, identify further steps to resolve or continue investigation of the issue via 5-whys. | `#status-reviewed` | |
+
+### How do we determine the lead?
+
+The current MSR runner is the default incident lead. If it is outside the MSR
+runner’s working hours, or they are unable to lead the incident response, then
+someone else will need to be the lead. It is the recorder’s job to find this
+lead or act as this lead; for incidents that are severity 1 or 2, stabilizing
+the service may be the highest priority and take precedence over finding a lead.
+Factors which should be considered in finding a lead are:
+
+- Availability
+ - Has one person been handling most incidents and this time, someone new
+ should take on?
+ - Consult threads for past incidents to see the distribution of recent
+ incident leadership and find someone who hasn’t recently lead an incident.
+- Expertise. Is anyone online uniquely qualified to guide the resolution?
+
+This process is intentionally flexible to allow for the rapidly evolving nature
+of incidents and to avoid too much rigidity. If the distribution of lead
+responsibilities is inequitably distributed, we will develop alternative
+processes for assigning leads.
+
+## Runbooks
+
+```{toctree}
+:titlesonly:
+
+runbooks/index
+```
diff --git a/documentation/meta/incidents/runbooks/incident_response_runbook.md b/documentation/meta/incidents/runbooks/incident_response_runbook.md
new file mode 100644
index 000000000..2c1e40ec6
--- /dev/null
+++ b/documentation/meta/incidents/runbooks/incident_response_runbook.md
@@ -0,0 +1,141 @@
+# Incident Response Runbook
+
+```{note}
+**Recording** an incident is a standalone task which can be performed by any maintainer. This recorder is not necessarily the one to stabilize the service or continue to work on incident triage.
+```
+
+```{warning}
+This runbook is intended to be used by Openverse maintainers, and references some resources that only Openverse staff have access to.
+```
+
+## 1. Record the incident
+
+When you observe a potential incident, you are responsible for recording it. Run
+the `/Incident Report` command in the maintainer’s `#openverse` Slack channel.
+This command will prompt for some basic information about the incident and then
+guide you into creating an incident report in the maintainer P2 blog.
+
+The command can also be run with a bookmarked "Report an Incident" link inside
+of Slack, which is found at the top of all `#openverse-` maintainer channels.
+
+### Determining an estimated severity
+
+You will be asked to provide an estimated
+[severity](/meta/incidents/index.md#severity) for the incident. You are expected
+to use your best judgement here, but here are some examples to help you:
+
+- **Severity 1** examples:
+ - <https://openverse.org> is completely down.
+ - Frontend searches aren't returning any results
+ - The API is serving error codes for all searches
+- **Severity 2** examples:
+ - Frontend keyboard navigation is broken
+ - A particular provider with ~1.5m images is not returning any API results
+ - Users based in the UK, comprising 6% of all visitors, are unable to view
+ <https://openverse.org>
+- **Severity 3** examples:
+ - A piece of our staging infrastructure has completely failed.
+ - A staging site is down
+ - Greek frontend translations are not displaying, instead falling back to
+ English
+
+### Concluding Reporting
+
+Monitor the incident until a lead has been identified. This will be the MSR, by
+default or another online member of the team (perhaps even yourself). At this
+point, reporting the incident is complete.
+
+## 2. Stabilize service
+
+1. Complete any necessary communication work. For Severity 1, this means
+ messaging the maintainers via Signal that an outage is occurring. Depending
+ on the severity, a Make post announcing that the outage is being investigated
+ may also be warranted.
+ 1. If the incident was discovered by a user in a communication channel,
+ please reply to them, and thank them for their report. Let them know the
+ team is investigating the issue.
+2. The point person should always have an up-to-date understanding of the
+ situation. Post updates to P2 regularly depending on severity (ideally hourly
+ for severity 1, but daily or otherwise for severity >= 2). Anyone who signs
+ on for the day while the incident is being triaged should jump into
+ stabilizing the service with the team. Be proactive! Ask how you can help.
+3. Perform any necessary tasks to triage/mitigate the incident. Delegate what
+ you can to online developers. It is assumed that anyone online can and will
+ help, and that incidents take precedence over regular work. Some tips for
+ triaging:
+ 1. It’s possible we have an existing runbook related to the type of incident
+ you’re dealing with, particularly if it was triggered by a monitoring
+ alarm. Search the
+ [runbook documentation](/meta/monitoring/runbooks/index.md) for useful
+ information.
+ 1. Understanding [service deployment mechanisms](/general/deployment.md)
+ will likely be useful.
+ 2. Traffic anomalies? See
+ [this guide](/meta/monitoring/traffic/runbooks/identifying-and-blocking-traffic-anomalies.md)
+ for suggestions.
+ 2. Be prepared to check logs in AWS, observe traffic in Cloudflare, and look
+ at dashboards for information on server resources. A useful guide on logs
+ [can be found here](/meta/monitoring/cloudwatch_logs/index.md).
+ 3. Checking for differences between staging and production can also be
+ illuminating.
+ 4. Record _everything_. Keep a local file as a scratchpad for notes, post
+ them to the Slack thread. The more retained raw information the better.
+ Before deleting or restarting anything: make backups, take screenshots or
+ copy/paste important text wherever you can.
+ 5. If something is related to a 3rd party API, like a provider or SaaS
+ offering used in Openverse, contact them as soon as possible.
+ 6. Start a Slack huddle if real time audio or video would be useful.
+ 7. For incidents that may last several hours, consider silencing any AWS
+ alarms that are actively being investigated - the extra noise can distract
+ and detract from the stabilization work. For any AWS alarms, this can be
+ done by setting the "Alarm action" to "Disabled" in the AWS UI.
+4. When the service has become stable again, update the status tag of the P2 to
+ `#status-stabilized` and leave a comment summarizing the mitigation. Usually
+ at this time the urgency of the incident will be reduced, and time may be
+ required to observe that the incident is fully resolved.
+
+```{note}
+Once services are stabilized, the urgency of the incident is usually reduced. The next steps can happen asynchronously and with priority commenserate to incident severity.
+```
+
+## 3. Investigate or resolve
+
+Depending on the nature of the incident, services may be stable but require
+further investigation into a root cause. If a root cause is already known,
+resolved, or no additional action can/should be taken, the incident can be
+marked as resolved.
+
+**Investigating**:
+
+1. If more investigation is required, update the status tag of the P2 to
+ `#status-investigating`. Share the outcome of the investigation in the P2 and
+ any issues that were created as a result of it.
+2. Prioritize the work on the created issues alongside existing workstreams, and
+ complete as appropriate.
+3. Once the related issues are complete, move on to resolving the incident.
+
+**Resolving**:
+
+1. Once enough time has passed without disturbance that the incident seems
+ resolved, update the status tag of the P2 to `#status-resolved`, leave a P2
+ comment summarizing the solution, adding any relevant points to the timeline,
+ and unpin the Slack thread. Re-enable any alarms that were disabled.
+2. Update all communication postings, editing them so that the incident is
+ clearly resolved in the title and body of the post. This includes the Make
+ post for Severity 1 incidents along with any other outreach.
+
+## 4. Review the incident
+
+Once the incident is resolved, the point person should host a retrospective as
+soon as possible. The closer to the actual incident, the better. Make sure
+everyone relevant attends, including anyone who recorded or helped triage the
+incident. Postmortems should be blameless, and we typically use the
+["5 Whys?"](https://www.mindtools.com/a3mi00v/5-whys) method to identify root
+causes of the incident and/or gaps in the incident response process.
+[Here is a recent example.](https://docs.google.com/document/d/1VGCWR85ipt_grLbDu_mKN31RAPTNEL_emvqDj1vcg20/edit)
+The postmortem process should generate action items and follow-up work that must
+be managed and prioritized appropriately. The team may not have capacity to
+perform a postmortem on each incident, but should do so for any incident that is
+particularly severe or has a high likelihood of recurrence. Once a postmortem
+has been completed, the status tag of the P2 should be updated to
+`#status-reviewed`.
diff --git a/documentation/meta/incidents/runbooks/index.md b/documentation/meta/incidents/runbooks/index.md
new file mode 100644
index 000000000..2afa3229e
--- /dev/null
+++ b/documentation/meta/incidents/runbooks/index.md
@@ -0,0 +1,9 @@
+# Runbooks
+
+This section collects runbooks for responding to Openverse incidents.
+
+```{toctree}
+:titlesonly:
+
+incident_response_runbook
+```
diff --git a/documentation/meta/index.md b/documentation/meta/index.md
index abddfa998..ef13fa64e 100644
--- a/documentation/meta/index.md
+++ b/documentation/meta/index.md
@@ -3,6 +3,7 @@
```{toctree}
:titlesonly:
+incidents/index
github_contribution_practices
dev_flow
maintainer_tasks