Skip to content

Commit fb398ef

Browse files
authored
Merge branch 'main' into discourse-gatekeeper/migrate
2 parents eccce6a + eda2d05 commit fb398ef

File tree

102 files changed

+11624
-2188
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

102 files changed

+11624
-2188
lines changed

.github/ISSUE_TEMPLATE/matrix_bug_report.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: Matrix Deployment Bug Report
22
description: Report a bug with the chat.ubuntu.com deployment
3-
labels: ["Type: Bug", "Status: Triage", "Context: deployment"]
3+
labels: ["Type: Bug", "Status: Triage", "Context: Deployment"]
44
body:
55
- type: markdown
66
attributes:

.github/ISSUE_TEMPLATE/matrix_enhancement.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: Matrix Deployment Enhancement
22
description: Suggest a feature for the chat.ubuntu.com deployment
3-
labels: ["Type: Enhancement", "Status: Triage", "deployment"]
3+
labels: ["Type: Enhancement", "Status: Triage", "Context: Deployment"]
44
body:
55
- type: markdown
66
attributes:
+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
name: Provide approval for bot PRs
2+
3+
on:
4+
pull_request:
5+
6+
jobs:
7+
bot_pr_approval:
8+
uses: canonical/operator-workflows/.github/workflows/bot_pr_approval.yaml@main
9+
secrets: inherit

.github/workflows/integration_test.yaml

+6-3
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,12 @@ jobs:
88
uses: canonical/operator-workflows/.github/workflows/integration_test.yaml@main
99
secrets: inherit
1010
with:
11-
chaos-app-label: app.kubernetes.io/name=synapse
12-
chaos-enabled: false
13-
chaos-experiments: pod-delete
11+
extra-arguments: -x --localstack-address 172.17.0.1
12+
pre-run-script: localstack-installation.sh
1413
trivy-image-config: "trivy.yaml"
14+
juju-channel: 3.1/stable
15+
channel: 1.28-strict/stable
16+
modules: '["test_charm", "test_nginx", "test_s3", "test_redis"]'
1517
self-hosted-runner: true
1618
self-hosted-runner-label: "edge"
19+
tmate-debug: true

.github/workflows/promote_charm.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,5 @@ jobs:
2323
with:
2424
origin-channel: ${{ github.event.inputs.origin-channel }}
2525
destination-channel: ${{ github.event.inputs.destination-channel }}
26+
doc-automation-disabled: false
2627
secrets: inherit

.licenserc.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,6 @@ header:
3535
- 'zap_rules.tsv'
3636
- 'lib/**'
3737
- 'templates/**'
38+
- 'synapse_rock/cron/**/*.py'
39+
- 'synapse_rock/scripts/**/*.py'
3840
comment: on-failure

.woke.yaml

+3
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ ignore_files:
55
- tests/unit/test_synapse_workload.py
66
- docs/reference/integrations.md
77
rules:
8+
# Ignore "master" - While https://github.com/canonical/redis-k8s-operator/pull/78
9+
# is not merged
10+
- name: master
811
# Ignore "grandfathered" used by SAML configuration.
912
- name: grandfathered
1013
# Ignore "whitelist" used by Synapse configuration.

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ project that warmly welcomes community projects, contributions, suggestions,
3030
fixes and constructive feedback.
3131
* [Code of conduct](https://ubuntu.com/community/code-of-conduct)
3232
* [Get support](https://discourse.charmhub.io/)
33-
* [Join our online chat](https://chat.charmhub.io/charmhub/channels/charm-dev)
33+
* [Join our online chat](https://matrix.to/#/#charmhub-charmdev:ubuntu.com)
3434
* [Contribute](https://charmhub.io/synapse/docs/contributing)
3535
* [Getting Started](https://charmhub.io/synapse/docs/getting-started)
36-
Thinking about using the Synapse Operator for your next project? [Get in touch](https://chat.charmhub.io/charmhub/channels/charm-dev)!
36+
Thinking about using the Synapse Operator for your next project? [Get in touch](https://matrix.to/#/#charmhub-charmdev:ubuntu.com)!
3737

3838
---

actions.yaml

+27
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,30 @@ promote-user-admin:
4141
description: |
4242
User name to be promoted to admin.
4343
type: string
44+
create-backup:
45+
description: |
46+
Creates a backup to s3 storage.
47+
list-backups:
48+
description: |
49+
Lists backups in s3 storage.
50+
restore-backup:
51+
description: |
52+
Restore a Synapse backup.
53+
S3 credentials are retrieved from the relation with the S3 integrator charm.
54+
The server_name and filesystem configuration for the application should be
55+
identical to the application restored.
56+
params:
57+
backup-id:
58+
type: string
59+
description: The backup-id to identify the backup to restore.
60+
required:
61+
- backup-id
62+
delete-backup:
63+
description: |
64+
Delete a backup in s3 storage by backup-id.
65+
params:
66+
backup-id:
67+
type: string
68+
description: The backup-id to identify the backup to delete.
69+
required:
70+
- backup-id

config.yaml

+18-25
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,21 @@ options:
88
description: |
99
Allows any other homeserver to fetch the server's public rooms directory
1010
via federation.
11+
backup_passphrase:
12+
type: string
13+
description: Passphrase used to encrypt a backup using gpg with symmetric key.
1114
enable_mjolnir:
1215
type: boolean
1316
default: false
1417
description: |
1518
Configures whether to enable Mjolnir - moderation tool for Matrix.
1619
Reference: https://github.com/matrix-org/mjolnir
20+
enable_irc_bridge:
21+
type: boolean
22+
default: false
23+
description: |
24+
Configures whether to enable IRC bridging for Matrix.
25+
Reference: https://github.com/matrix-org/matrix-appservice-irc
1726
enable_password_config:
1827
type: boolean
1928
default: true
@@ -36,6 +45,15 @@ options:
3645
Comma separated list of IP address CIDR ranges that should be allowed for
3746
federation, identity servers, push servers, and for checking key validity
3847
for third-party invite events.
48+
irc_bridge_admins:
49+
type: string
50+
description: |
51+
Comma separated list of admins to be allowed to manage the bridge.
52+
This takes the form of @user1:domainX.com,@user2:domainY.com...
53+
notif_from:
54+
type: string
55+
description: defines the "From" address to use when sending emails.
56+
It must be set if the SMTP integration is enabled. Defaults to server_name.
3957
public_baseurl:
4058
type: string
4159
description: |
@@ -53,31 +71,6 @@ options:
5371
Synapse server name. Must be set to deploy the charm. Corresponds to the
5472
server_name option on Synapse configuration file and sets the
5573
public-facing domain of the server.
56-
smtp_enable_tls:
57-
type: boolean
58-
description: If enabled, STARTTLS will be used to use an encrypted SMTP
59-
connection.
60-
default: true
61-
smtp_host:
62-
type: string
63-
description: The hostname of the SMTP host used for sending emails.
64-
default: ''
65-
smtp_notif_from:
66-
type: string
67-
description: defines the "From" address to use when sending emails.
68-
It must be set if email sending is enabled. Defaults to server_name.
69-
smtp_pass:
70-
type: string
71-
description: The password if the SMTP server requires authentication.
72-
default: ''
73-
smtp_port:
74-
type: int
75-
description: The port of the SMTP server used for sending emails.
76-
default: 25
77-
smtp_user:
78-
type: string
79-
description: The username if the SMTP server requires authentication.
80-
default: ''
8174
trusted_key_servers:
8275
type: string
8376
description: Comma separated list of trusted servers to download signing

docs/explanation/charm-architecture.md

+6-1
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,11 @@ forward non-static traffic to it.
7474

7575
The workload that this container is running is defined in the [Synapse ROCK](https://github.com/canonical/synapse-operator/tree/main/synapse_rock).
7676

77+
If Synapse is integrated with PostgreSQL, [Synapse Stats Exporter](https://github.com/canonical/synapse_stats_exporter) will be enabled.
78+
Synapse Stats Exporter listens to non-TLS port `9877` and will be configured as a
79+
target if the charm is integrated with Prometheus. It will provide two metrics: number of rooms and
80+
number of users.
81+
7782
## Integrations
7883

7984
See [Integrations](https://charmhub.io/synapse/docs/reference/integrations).
@@ -103,4 +108,4 @@ juju config synapse server_name=myserver.myserver.com
103108
self.framework.observe(self.on.config_changed, self._on_config_changed)
104109
4. The method `_on_config_changed` will take the necessary actions.
105110
The actions include waiting for all the relations to be ready and then configuring
106-
the containers.
111+
the containers.

docs/how-to/backup-and-restore.md

+126
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
# How to back up and restore Synapse
2+
3+
This document shows how to back up and restore Synapse.
4+
5+
The process of backing up and restoring depends on whether an external database
6+
is used, so the step to run the backup for PostgreSQL must be done only if PostgreSQL
7+
is used in the original Synapse application.
8+
9+
It is important to note that data inside the s3 bucket for media storage is essential
10+
to be included as part of the backup/restore.
11+
12+
## Back up Synapse
13+
14+
### Deploy s3-integrator charm
15+
16+
Synapse gets backed up to a S3 compatible object storage. The bucket for the backup should be provisioned before the backup is performed.
17+
18+
For Synapse to get the credentials, the `s3-integrator` is used. Refer to [s3-integrator](https://charmhub.io/s3-integrator/) for specific configuration options.
19+
20+
```
21+
juju deploy s3-integrator --channel edge
22+
juju config s3-integrator endpoint=<s3 endpoint> bucket=<bucket name> path=<optional-path> region=<region> s3-uri-style=<path or host>
23+
juju run s3-integrator/leader sync-s3-credentials access-key=<access-key> secret-key=<secret-key>
24+
```
25+
26+
Integrate with Synapse with:
27+
28+
`juju integrate synapse:backup s3-integrator`
29+
30+
### Configure the passphrase
31+
32+
The backup will be encrypted before being sent using symmetric encryption. You need
33+
to set the desired password with:
34+
```
35+
juju config synapse backup_passphrase=<secret passphase>
36+
```
37+
38+
### Create the backup
39+
40+
Create the backup with the next command:
41+
```
42+
juju run synapse/leader create-backup
43+
```
44+
45+
A new object should be placed in the S3 compatible object storage, a tar file encrypted with the `gpg` command.
46+
47+
48+
You can list the available backups with the `list-backups` command:
49+
```
50+
juju run synapse/leader list-backups
51+
```
52+
53+
### Back up PostgreSQL
54+
55+
Follow the instructions of the PostgreSQL charm:
56+
- For [postgresql-k8s](https://charmhub.io/postgresql-k8s/docs/h-create-and-list-backups).
57+
- For [postgresql](https://charmhub.io/postgresql/docs/h-create-and-list-backups).
58+
59+
If you plan to restore PostgreSQL in a different model or cluster, you will need
60+
to also back up the cluster passwords. See:
61+
- For [postgresql-k8s](https://charmhub.io/postgresql-k8s/docs/h-migrate-cluster-via-restore).
62+
- For [postgresql](https://charmhub.io/postgresql/docs/h-migrate-cluster-via-restore).
63+
64+
65+
## Restore
66+
67+
The recommendation is to first restore PostgreSQL if necessary. Then deploying,
68+
configuring and integrating Synapse with other charms as done in a normal deployment
69+
and finally restoring Synapse.
70+
71+
The PostgreSQL and Synapse charm revisions should be the same ones as the ones used
72+
for the backup. The configuration for Synapse before restoring the backup should also
73+
match the configuration in the original application. This is specially important for
74+
the configuration option `server_name` and any other configuration related to the filesystem.
75+
76+
77+
### Restore PostgreSQL
78+
79+
80+
If you use the PostgreSQL integration, follow the instructions given by PostgreSQL:
81+
- For postgresql-k8s: [local restore](https://charmhub.io/postgresql/docs/h-restore-backup), [foreign backup](https://charmhub.io/postgresql/docs/h-migrate-cluster-via-restore).
82+
- for postgresql: [local restore](https://charmhub.io/postgresql/docs/h-restore-backup), [foreign backup](https://charmhub.io/postgresql/docs/h-migrate-cluster-via-restore).
83+
84+
If you used the foreign backup, once the backup for PostgreSQL is restored, you should remove the S3 integration,
85+
as it was created in a different cluster, by running:
86+
87+
```
88+
juju remove-relation s3-integrator postgresql
89+
```
90+
91+
### Deploy Synapse
92+
93+
Synapse should be deployed, integrated with all necessary charms and configured. If necessary, Synapse should be integrated with the PostgreSQL charm that
94+
has already being restored.
95+
96+
### Restore Synapse
97+
98+
99+
Set the `backup_passphrase` to the passphrase used for the backup.
100+
```
101+
juju config synapse backup_passphrase=<secret passphase>
102+
```
103+
104+
Integrate with S3, following the same instructions as in the backup procedure, that is, similar to:
105+
106+
```
107+
juju deploy s3-integrator --channel edge
108+
juju config s3-integrator endpoint=<s3 endpoint> bucket=<bucket name> path=<optional-path> region=<region> s3-uri-style=<path or host>
109+
juju run s3-integrator/leader sync-s3-credentials access-key=<access-key> secret-key=<secret-key>
110+
```
111+
112+
Integrate with Synapse with:
113+
114+
`juju integrate synapse:backup s3-integrator`
115+
116+
List the backups and take note of the desired `backup-id`
117+
```
118+
juju run synapse/leader list-backups
119+
```
120+
121+
Restore the backup:
122+
```
123+
juju run synapse/leader restore-backup backup-id=<backup-id from the list of backups>
124+
```
125+
126+
At this point, Synapse should be active and the restore procedure complete.

docs/how-to/configure-smtp.md

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# How to integrate with SMTP for sending notifications
2+
3+
This document shows how to integrate Synapse with SMTP for sending
4+
emails. Synapse should be deployed beforehand.
5+
6+
## Deploy smtp-integrator charm
7+
8+
For synapse to use SMTP, it uses the smtp-integrator charm. Replace the configuration options with your specific configuration.
9+
Configuring SMTP without tls or starttls or without authentication is not supported.
10+
11+
```
12+
juju deploy smtp-integrator --channel edge
13+
juju config smtp-integrator host=<smtp host> port=<smtp port> user=<smtp auth user> password=<smtp auth password> auth_type=plain transport_security=tls
14+
```
15+
16+
## Configure email to use in `From`
17+
18+
Configure the "From" mail for Synapse with:
19+
```
20+
juju config synapse notif_from=<email to use in the "From" address>
21+
```
22+
23+
## Integrate with Synapse
24+
25+
You can run it with the legacy integration `smtp-legacy` or with
26+
the new integration using secrets `smtp`. A Juju version
27+
with secrets is required for the `smtp` integration.
28+
29+
With the old integration without using secrets, run:
30+
```
31+
juju integrate smtp-integrator:smtp-legacy synapse:smtp
32+
```
33+
For the new integration with secrets, run:
34+
```
35+
juju integrate smtp-integrator:smtp synapse:smtp
36+
```

docs/how-to/contribute.md

+6-8
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ enhancements to the Synapse operator.
99
[opening an issue](https://github.com/canonical/synapse-operator/issues)
1010
explaining your use case.
1111
- If you would like to chat with us about your use-cases or proposed
12-
implementation, you can reach us at [Canonical Mattermost public channel](https://chat.charmhub.io/charmhub/channels/charm-dev)
12+
implementation, you can reach us at [Canonical Matrix public channel](https://matrix.to/#/#charmhub-charmdev:ubuntu.com)
1313
or [Discourse](https://discourse.charmhub.io/).
1414
- Familiarising yourself with the [Charmed Operator Framework](https://juju.is/docs/sdk)
1515
library will help you a lot when working on new features or bug fixes.
@@ -80,12 +80,10 @@ and synapse-nginx images are required in the microk8s registry. To enable it:
8080
The following commands import the images in the Docker daemon and push them into
8181
the registry:
8282

83-
cd [project_dir]/synapse_rock && rockcraft pack rockcraft.yaml
84-
skopeo --insecure-policy copy oci-archive:synapse_1.0_amd64.rock docker-daemon:localhost:32000/synapse:latest
85-
docker push localhost:32000/synapse:latest
86-
cd [project_dir]/nginx_rock && rockcraft pack rockcraft.yaml
87-
skopeo --insecure-policy copy oci-archive:synapse_nginx_1.0_amd64.rock docker-daemon:localhost:32000/synapse-nginx:latest
88-
docker push localhost:32000/synapse-nginx:latest
83+
cd [project_dir]/synapse_rock && rockcraft pack
84+
skopeo --insecure-policy copy --dest-tls-verify=false oci-archive:synapse_1.0_amd64.rock docker://localhost:32000/synapse:latest
85+
cd [project_dir]/nginx_rock && rockcraft pack
86+
skopeo --insecure-policy copy --dest-tls-verify=false oci-archive:synapse-nginx_1.0_amd64.rock docker://localhost:32000/synapse-nginx:latest
8987

9088
### Deploy
9189

@@ -95,7 +93,7 @@ juju add-model synapse-dev
9593
# Enable DEBUG logging
9694
juju model-config logging-config="<root>=INFO;unit=DEBUG"
9795
# Deploy the charm (assuming you're on amd64)
98-
juju deploy ./synapse_ubuntu-20.04-amd64.charm \
96+
juju deploy ./synapse_ubuntu-22.04-amd64.charm \
9997
--resource synapse-image=localhost:32000/synapse:latest \
10098
--resource synapse-nginx-image=localhost:32000/synapse-nginx:latest
10199
```

0 commit comments

Comments
 (0)