Skip to content

Commit

Permalink
docs: split homepage, add tasks docs
Browse files Browse the repository at this point in the history
  • Loading branch information
GabDug committed Jan 22, 2024
1 parent a417220 commit 12f043c
Show file tree
Hide file tree
Showing 14 changed files with 122 additions and 66 deletions.
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ CONFLUENCE_MOCK_CREATE_POSTMORTEM=True
## PagerDuty settings (optional) ## (5)

ENABLE_PAGERDUTY=False
PAGERDUTY_ACCOUNT_EMAIL="admin@manomano.com"
PAGERDUTY_ACCOUNT_EMAIL="admin@mycompany.com"
PAGERDUTY_API_KEY="u+XXXXXXXXXXXXXXXX-X"
PAGERDUTY_URL="https://api.pagerduty.com"

Expand Down
10 changes: 4 additions & 6 deletions docs/Deploy/XX-settings.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ Redis DBs:

## FireFighter settings



- [`BASE_URL`][firefighter.firefighter.settings.settings_utils.BASE_URL]
- [`FF_ROLE_REMINDER_MIN_DAYS_INTERVAL`][firefighter.firefighter.settings.components.common.FF_ROLE_REMINDER_MIN_DAYS_INTERVAL]
- [`FF_USER_ID_HEADER`][firefighter.firefighter.settings.components.common.FF_USER_ID_HEADER]
Expand Down Expand Up @@ -85,10 +83,10 @@ See [django-oauth2-codeflow](https://gitlab.com/systra/qeto/lib/django-oauth2-au

## Pagerduty integration

- `ENABLE_PAGERDUTY`: default: `False`
- `PAGERDUTY_API_KEY`
- `PAGERDUTY_ACCOUNT_EMAIL`
- `PAGERDUTY_URL`: default: `https://api.pagerduty.com`
- [`ENABLE_PAGERDUTY`][firefighter.firefighter.settings.components.pagerduty.ENABLE_PAGERDUTY]: default: `False`
- [`PAGERDUTY_API_KEY`][firefighter.firefighter.settings.components.pagerduty.PAGERDUTY_API_KEY]
- [`PAGERDUTY_ACCOUNT_EMAIL`][firefighter.firefighter.settings.components.pagerduty.PAGERDUTY_ACCOUNT_EMAIL]
- [`PAGERDUTY_URL`][firefighter.firefighter.settings.components.pagerduty.PAGERDUTY_URL]: default: `https://api.pagerduty.com`

## Other settings

Expand Down
28 changes: 28 additions & 0 deletions docs/Deploy/XX-tasks.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Celery tasks

This project uses [Celery](https://docs.celeryproject.org/en/stable/) to run asynchronous tasks.

## Running

You will need to run a Celery worker to run the tasks, and a Celery beat to schedule them.

```bash
pdm run celery-worker
```

```bash
pdm run celery-beat
```

!!! note
A Django management command is also available to run a specific task:

```bash
pdm run ff-manage task <task_name>
```

## Scheduling tasks

By default, no tasks are scheduled.

You can schedule tasks through the Django admin interface.
65 changes: 65 additions & 0 deletions docs/Usage/integrations.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@

# Integrations

## :simple-pagerduty: PagerDuty

### Features

Expose the current on-call schedule, and allow anyone to escalate to PagerDuty.

![PagerDuty integration](../assets/screenshots/pagerduty_web_oncall_overview.png)
_Exposing the on-call schedule, even for users with no PagerDuty access._

![PagerDuty integration](../assets/screenshots/pagerduty_web_oncall_overview.png)
_Trigger a PagerDuty incident from the Web UI, even with no PagerDuty access._

![PagerDuty integration](../assets/screenshots/pagerduty_slack_trigger.png)
_In a Slack conversation about an incident, anyone can escalate to PagerDuty, with `/incident oncall`._

### Tasks

Tasks are provided to regularly sync the on-call schedules, services and users from PagerDuty, as well as a task to trigger PagerDuty incidents.

If Confluence is enabled, there is a task to export the on-call schedule to a Confluence page set with environment variable `CONFLUENCE_ON_CALL_PAGE_ID`.

See the [available PagerDuty tasks][firefighter.pagerduty.tasks] that can be [scheduled from the Back-Office](../Deploy/XX-tasks.md).

### Settings and configuration

[Basic configuration with environment variables](../Deploy/XX-settings.md#pagerduty-integration).

No Back-Office configuration.

## :fontawesome-brands-confluence: Confluence

!!! warning
This integration is disabled by default, and is not yet documented.
It is specific to our internal use case.

## :fontawesome-brands-slack: Slack

### Tasks

Tasks are provided to regularly sync users, conversations, usergroups and channel members from Slack.

See the [available Slack tasks][firefighter.slack.tasks] that can be [scheduled from the Back-Office](../Deploy/XX-tasks.md).

### Settings and configuration

See [Slack environment variables settings](../Deploy/XX-settings.md#slack-integration).

#### Back-Office configuration

You can add custom tags to Slack conversations in the back-office.

Some tags have special meaning:

- `tech_incidents`: send incidents notifications to the channel
- `dev_firefighter`: Where users can get help with the bot. Will be shown in `/incident help` for instance.
- `it_deploy`: Where the bot send notifications for deployment freezes.

## :fontawesome-brands-jira: Jira

!!! warning
This integration is disabled by default, and is not yet documented.
It is specific to our internal use case.
52 changes: 1 addition & 51 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

Expose your on-call schedule, and allow anyone to escalate to PagerDuty.

<!-- [:octicons-arrow-right-24: Reference](#) -->
[:octicons-arrow-right-24: Learn more](Usage/integrations.md#pagerduty)

- :fontawesome-brands-jira:{ .lg .middle } __Follow on Jira__ _(optional)_

Expand Down Expand Up @@ -56,53 +56,3 @@
Please open an issue if you have any question, or if you need help.

The [FAQ](FAQ.md) may also answer some of your questions.

## Integrations

### PagerDuty

#### Features

Expose the current on-call schedule, and allow anyone to escalate to PagerDuty.

![PagerDuty integration](assets/screenshots/pagerduty_web_oncall_overview.png)
_Exposing the on-call schedule, even for users with no PagerDuty access._

![PagerDuty integration](assets/screenshots/pagerduty_web_oncall_overview.png)
_Trigger a PagerDuty incident from the Web UI, even with no PagerDuty access._

![PagerDuty integration](assets/screenshots/pagerduty_slack_trigger.png)
_In a Slack conversation about an incident, anyone can escalate to PagerDuty, with `/incident oncall`._


#### Tasks

Tasks are provided to regularly sync the on-call schedules, services and users from PagerDuty, as well as a task to trigger PagerDuty incidents.
<!-- See FIXME links to reference. -->\


If Confluence is enabled, there is a task to export the on-call schedule to a Confluence page set with `CONFLUENCE_ON_CALL_PAGE_ID`.

#### Settings and configuration

Basic ENV configuration.

No Back-Office configuration.

### Confluence

### Slack

#### Settings and configuration

See settings in [slack.py][firefighter.firefighter.settings.components.slack]

##### Back-Office configuration

You can add custom tags to Slack conversations in the back-office.

Some tags have special meaning:

- `tech_incidents`: send incidents notifications to the channel
- `dev_firefighter`: Where users can get help with the bot. Will be shown in `/incident help` for instance.
- `it_deploy`: Where the bot send notifications for deployment freezes.
11 changes: 7 additions & 4 deletions mkdocs.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
site_name: FireFighter Docs
site_description: FireFighter is ManoMano's incident management tool, built on top of Slack and Jira, with Django and Python.
site_url: https:/manomanotech.github.io/firefighter-incident/
site_url: https://manomanotech.github.io/firefighter-incident/

repo_url: https://github.com/ManoManoTech/firefighter-incident
repo_name: ManoManoTech/firefighter-incident
Expand Down Expand Up @@ -88,13 +88,16 @@ nav:
- License: license.md
- FAQ: FAQ.md
- Usage:
- Integrations: Usage/integrations.md
- Deployment:
- Deploy/00-intro.md
- Settings:
- Deploy/XX-settings.md
- Deploy/XX-custom-settings.md
- Deploy/XX-auth.md
- Deploy/XX-custom-settings.md
- Deploy/XX-i18n-l10.md
- Translation and timezone: Deploy/XX-i18n-l10.md
- Deploy/XX-logs-traces.md
- Deploy/XX-settings.md
- Deploy/XX-tasks.md
- Deploy/XX-support-policy.md

- Development:
Expand Down
4 changes: 2 additions & 2 deletions src/firefighter/firefighter/settings/components/celery.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@
"result_serializer": "json",
# http://docs.celeryproject.org/en/latest/userguide/configuration.html#task-time-limit
# set to whatever value is adequate in your circumstances
"task_time_limit": 3 * 60,
"task_time_limit": 3 * 60, # in seconds
# http://docs.celeryproject.org/en/latest/userguide/configuration.html#task-soft-time-limit
"task_soft_time_limit": 2 * 60,
"task_soft_time_limit": 2 * 60, # in seconds
# http://docs.celeryproject.org/en/latest/userguide/configuration.html#beat-scheduler
"beat_scheduler": "django_celery_beat.schedulers:DatabaseScheduler",
# https://docs.celeryq.dev/en/stable/userguide/configuration.html#std-setting-broker_connection_retry
Expand Down
4 changes: 4 additions & 0 deletions src/firefighter/firefighter/settings/components/pagerduty.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,14 @@
from firefighter.firefighter.settings.settings_utils import config

ENABLE_PAGERDUTY: bool = config("ENABLE_PAGERDUTY", cast=bool, default=False)
"""Enable PagerDuty integration."""

if ENABLE_PAGERDUTY:
INSTALLED_APPS.append("firefighter.pagerduty")

PAGERDUTY_API_KEY: str = config("PAGERDUTY_API_KEY")
"""PagerDuty API key."""
PAGERDUTY_ACCOUNT_EMAIL: str = config("PAGERDUTY_ACCOUNT_EMAIL")
"""PagerDuty account email, linked to the API key."""
PAGERDUTY_URL: str = config("PAGERDUTY_URL", default="https://api.pagerduty.com")
"""PagerDuty API URL."""
1 change: 1 addition & 0 deletions src/firefighter/pagerduty/tasks/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
"""PagerDuty Celery tasks."""
from __future__ import annotations

from firefighter.pagerduty.tasks.fetch_oncall import fetch_oncalls
Expand Down
3 changes: 3 additions & 0 deletions src/firefighter/pagerduty/tasks/fetch_oncall.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@

@celery_app.task(name="pagerduty.fetch_oncalls")
def fetch_oncalls() -> None:
"""Celery task to fetch PagerDuty oncalls and save them in the database.
Will try to update services, users, schedules and escalation policies if needed.
"""
services = pagerduty_service.get_all_oncalls()
return create_oncalls(services)

Expand Down
1 change: 1 addition & 0 deletions src/firefighter/pagerduty/tasks/fetch_services.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
@shared_task(name="pagerduty.fetch_services")
@transaction.atomic
def fetch_services() -> None:
"""Celery task to fetch PagerDuty services and save them in the database."""
fetched_services_key = []
for service in pagerduty_service.client.session.iter_all("services"):
fetched_services_key.append(service["id"])
Expand Down
1 change: 1 addition & 0 deletions src/firefighter/pagerduty/tasks/fetch_users.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

@shared_task(name="pagerduty.fetch_users")
def fetch_users(*, delete_stale_user: bool = True) -> None:
"""Celery task to fetch PagerDuty users and save them in the database."""
fetched_users_id = []
for user in pagerduty_service.client.get_all_users():
logger.debug(user)
Expand Down
4 changes: 3 additions & 1 deletion src/firefighter/pagerduty/tasks/trigger_oncall.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ def trigger_oncall(
incident_id: int | None = None,
triggered_by: User | None = None,
) -> PagerDutyIncident:
"""XXX Trigger from PD user if it exists, instead of admin.
"""Celery task to trigger an on-call in PagerDuty, from a FireFighter incident.
XXX Trigger from PD user if it exists, instead of admin.
XXX Should be a service ID instead of a service object.
"""
service = oncall_service
Expand Down
2 changes: 1 addition & 1 deletion src/firefighter/raid/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ def send_message_to_watchers(
)
except SlackApiError:
logger.warning(
f"Couldn't send private message to reporter with jira_id={watcher}"
f"Couldn't send private message to reporter with jira_id={watcher.get('accountId', watcher)}"
)
return True

Expand Down

0 comments on commit 12f043c

Please sign in to comment.