Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
cecc44d
Reapplying bg-worker
elland May 8, 2023
8fa3b8d
Updated tests that no longer made sense with rabbit in place
elland May 9, 2023
d6f2b9c
Restoring CI setup.
elland May 9, 2023
9ca845e
Added error handling to "flaky" dpop test
elland May 10, 2023
7a1ea7e
Changed rabbitmq values.yaml
elland May 15, 2023
67483a4
Added exception handler to rabbitmq
elland May 15, 2023
93179f9
Format
elland May 15, 2023
3d2f7e7
background-worker.integration.yaml: Add logLevel
akshaymankar May 15, 2023
298e5ee
brig: Rename rabbitMQ -> rabbitmq, RabbitMQOpts -> RabbitMqOpts
akshaymankar May 15, 2023
a122f26
background-worker: Deal with rabbitmq channel exceptions
akshaymankar May 15, 2023
f029344
Add logs
akshaymankar May 15, 2023
8d9e69b
Refactor rabbitmq / background worker life-cycle
elland May 15, 2023
5c28915
Remove unnecessary todos
akshaymankar May 16, 2023
6e8615e
Remove unnecessary comment
akshaymankar May 16, 2023
972173b
background-worker: Add retries to connect tor rabbitmq
akshaymankar May 16, 2023
8ec2d61
backgroun-worker: Move rabbitmq code to separate module, log retries
akshaymankar May 16, 2023
99bf675
Better logs when rabbitmq connection dies
akshaymankar May 16, 2023
e5726ea
background-notification-pusher: Ensure messages are consumed 1 by 1
akshaymankar May 16, 2023
cf92674
Dead code
akshaymankar May 16, 2023
a49bf2e
Remove unnecessary todo
akshaymankar May 16, 2023
aab1fda
Reject unparsable notifications
akshaymankar May 16, 2023
8376ff3
Reject more types of unknown messages
akshaymankar May 16, 2023
e4e0cd3
Retry sending notifications forever
akshaymankar May 16, 2023
75324d4
Log errors that might happen while pushing notifications
akshaymankar May 16, 2023
870bf9f
Better comment
akshaymankar May 16, 2023
5125691
Better exception messages
akshaymankar May 16, 2023
a348988
Add @elland to TODO
akshaymankar May 16, 2023
c81bc6b
Doesn't matter so much if we have just 1 channel for all domains
akshaymankar May 16, 2023
db1b5ed
Comment
akshaymankar May 16, 2023
ebe5622
Better error
akshaymankar May 16, 2023
184def4
Add todo
akshaymankar May 16, 2023
2eca594
Wire.BackgrounddWorker.RabbitMQ -> Network.AMQP.Extended
akshaymankar May 16, 2023
1e012b0
brig: Automatically reconnect with rabbitmq
akshaymankar May 16, 2023
f411c23
Typo
elland May 17, 2023
3f50267
Moved print to assertion failure for token test
elland May 17, 2023
49db146
fix: Flaky DPoP access token test
battermann May 17, 2023
43ab45f
brig-integration: Fix end2end test
akshaymankar May 17, 2023
f293252
Restore unrelated files from origin/develop
akshaymankar May 17, 2023
b58139c
Forgotten rename
akshaymankar May 17, 2023
4d9ad6f
background-worker: Add unit tests
akshaymankar May 17, 2023
5eb9c44
Already Done TODO
akshaymankar May 17, 2023
1a7be67
Fix last minute refactor
akshaymankar May 17, 2023
38f92a7
brig: Add retries to rabbitmq enqueuing code
akshaymankar May 17, 2023
568dbe7
No need to catch an error that never happens
akshaymankar May 17, 2023
5b50cde
brig: Better logging for rabbitmq errors
akshaymankar May 17, 2023
f01f0d4
brig: redundant deps
akshaymankar May 17, 2023
9c3181b
Recreate all background workers at once
akshaymankar May 22, 2023
da343ca
TODO -> FUTUREWORK
akshaymankar May 22, 2023
d668582
FederatorClient: Also include the Accept header
akshaymankar May 23, 2023
2a11487
Better serialization format for notifications
akshaymankar May 23, 2023
f9ab997
Retry pushing notifications on any exception
akshaymankar May 23, 2023
010c6da
Document how to install RabbitMQ
akshaymankar May 23, 2023
ef32b84
Add changelog
akshaymankar May 23, 2023
41d4c81
Harder to guess password for rabbitmq
akshaymankar May 24, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .envrc
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,7 @@ path_add "PYTHONPATH" "./hack/python"
# Locale
export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8

# RabbitMQ
export RABBITMQ_USERNAME=guest
export RABBITMQ_PASSWORD=alpaca-grapefruit
3 changes: 3 additions & 0 deletions cabal.project
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ packages:
, libs/wire-api-federation/
, libs/wire-message-proto-lens/
, libs/zauth/
, services/background-worker/
, services/brig/
, services/cannon/
, services/cargohold/
Expand Down Expand Up @@ -66,6 +67,8 @@ package assets
ghc-options: -Werror
package auto-whitelist
ghc-options: -Werror
package background-worker
ghc-options: -Werror
package bilge
ghc-options: -Werror
package billing-team-member-backfill
Expand Down
38 changes: 38 additions & 0 deletions changelog.d/0-release-notes/background-worker
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
This release introduces a new component: background-worker. This is currently
only used to forward notifications to federated backends. Enabling federation in
the wire-server helm chart automatically installs this component.

When federation is enabled, wire-server will require running RabbitMQ. The helm
chart in `rabbitmq` can be used to install RabbitMQ. Please refer to the
documentation at https://docs.wire.com to install RabbitMQ in Kubernetes. These
new configurations are required:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

move the yaml snippet to docs.wire.com? or if it's already there: link to it rather than redundantly copy it? on the other hand, that would complicate the situation in which we change docs.wire.com in a later release, and somebody upgrades to this release afterwards.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The way docs.wire.com tells people about these options is by telling them to copy some example config from wire-server-deploy. I think that is quite useless for people doing upgrades. So, I added this yaml here. As you say it is also useful for someone doing upgrades 1 version at a time, which something could have changed in future in docs.wire.com.


```yaml
brig:
config:
rabbitmq:
host: rabbitmq
port: 5672
vHost: /
secrets:
rabbitmq:
username: <YOUR_USERNAME>
password: <YOUR_PASSWORD>
background-worker:
config:
rabbitmq:
host: rabbitmq
port: 5672
vHost: /
remoteDomains: []
secrets:
rabbitmq:
username: <YOUR_USERNAME>
password: <YOUR_PASSWORD>
```

The above are the default values (except for secrets, which do not have
defaults), if they work they are not required to be configured.
`background-worker.config.remoteDomains` should contain all the remote domains
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this will change again with #3260, but let's worry about that there.

Comment on lines +35 to +36
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should help customers setting all the federation domain related configuration. We already have

  • federator.config.optSettings.federationStrategy.allowedDomains
  • setFederationDomain in various places
  • brig.config.optSettings.setFederationDomainConfigs
  • galley.config.settings.featureFlags.classifiedDomains

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe #3260 is going to solve this.

with which the wire-server instance allows federating. This change is
incompatible with open-federation.
9 changes: 4 additions & 5 deletions charts/background-worker/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,11 @@ metadata:
heritage: {{ .Release.Service }}
spec:
replicas: {{ .Values.replicaCount }}
# TODO(elland): Review this
strategy:
type: RollingUpdate
rollingUpdate:
maxUnavailable: 0
maxSurge: {{ .Values.replicaCount }}
# Ensures only one version of the background worker is running at any given
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# Ensures only one version of the background worker is running at any given
# Ensures only one instance (or k8s pod) of the background worker is running at any given

is that what you mean?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, many K8s pods can run at once. This way of deploying just deletes previous version before deploying the new version. Basically does the opposite of a rolling deployment.

# moment. This means small downtime, but the background workers should be
# able to catch up.
type: Recreate
selector:
matchLabels:
app: background-worker
Expand Down
3 changes: 1 addition & 2 deletions charts/background-worker/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,11 @@ resources:
cpu: "100m"
limits:
memory: "512Mi"
# TODO(elland): Create issue for a metrics endpoint
# FUTUREWORK: Implement metrics
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can do this in a separate PR, but we should make sure we won't forget and have a ticket:

https://wearezeta.atlassian.net/browse/FS-2020

btw, which ticket is this PR about?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is this: https://wearezeta.atlassian.net/browse/FS-1940
It was in the title, also added it to description now.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for creating the issue, I had asked Marco Conti to create it as I wasn't sure how to get it in right JIRA places. The one you create doesn't seem to be in the right epic. Maybe someone will notice and put it there? Is this our process?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a parent of relation, maybe that's all that was needed 🤞

# metrics:
# serviceMonitor:
# enabled: false
config:
# TODO(elland): Proper logging
logLevel: Info
logFormat: StructuredJSON
rabbitmq:
Expand Down
10 changes: 8 additions & 2 deletions charts/integration/templates/integration-integration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,12 @@ spec:
- name: AWS_REGION
value: "eu-west-1"
- name: RABBITMQ_USERNAME
value: "guest"
valueFrom:
secretKeyRef:
name: brig
key: rabbitmqUsername
- name: RABBITMQ_PASSWORD
value: "guest"
valueFrom:
secretKeyRef:
name: brig
key: rabbitmqPassword
8 changes: 8 additions & 0 deletions charts/wire-server/requirements.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,14 @@ dependencies:
- federation
- haskellServices
- services
- name: background-worker
version: "0.0.42"
repository: "file://../background-worker"
tags:
- background-worker
- federation
- haskellServices
- services
- name: sftd
version: "0.0.42"
repository: "file://../sftd"
Expand Down
33 changes: 30 additions & 3 deletions docs/src/how-to/install/helm-prod.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,32 @@ cp values/wire-server/prod-secrets.example.yaml my-wire-server/secrets.yaml
cp values/wire-server/prod-values.example.yaml my-wire-server/values.yaml
```

## How to install RabbitMQ

This is only required when federation needs to be enabled.

1. Generate password for rabbitmq:

```shell
openssl rand -base64 64 | env LC_CTYPE=C tr -dc a-zA-Z0-9 | head -c 42 > my-wire-server/rabbitmq-password
```

2. Copy example values

```shell
cp values/rabbitmq/prod-secrets.example.yaml values/rabbitmq/secrets.yaml
cp values/rabbitmq/prod-values.example.yaml values/rabbitmq/values.yaml
```

3. Add the generated secret from `my-wire-server/rabbitmq-password` to
`values/rabbitmq/secrets.yaml` under `rabbitmq.auth.password`.

4. Install the helm chart using:

```shell
helm upgrade --install rabbitmq wire/rabbitmq -f values/rabbitmq/values.yaml -f values/rabbitmq/secrets.yaml
```

## How to configure real SMTP (email) services

In order for users to interact with their wire account, they need to receive mail from your wire server.
Expand Down Expand Up @@ -189,9 +215,10 @@ apt install docker-ce
sudo docker run --rm quay.io/wire/alpine-intermediate /dist/zauth -m gen-keypair -i 1 > my-wire-server/zauth.txt
```

1. Add the generated secret from my-wire-server/restund.txt to my-wire-serwer/secrets.yaml under `brig.secrets.turn.secret`
2. add **both** the public and private parts from zauth.txt to secrets.yaml under `brig.secrets.zAuth`
3. Add the public key from zauth.txt to secrets.yaml under `nginz.secrets.zAuth.publicKeys`
1. Add the generated secret from `my-wire-server/restund.txt` to `my-wire-server/secrets.yaml` under `brig.secrets.turn.secret`.
2. add **both** the public and private parts from `my-wire-server/zauth.txt` to `my-wire-server/secrets.yaml` under `brig.secrets.zAuth`.
3. Add the public key from `my-wire-server/zauth.txt` to `my-wire-server/secrets.yaml` under `nginz.secrets.zAuth.publicKeys`.
4. Add the generated secret from my-wire-server/rabbitmq-password to `my-wire-server/secerts.yaml` under `brig.secrets.rabbitmq.password` and `background-worker.secrets.rabbitmq.password`.

Great, now try the installation:

Expand Down
2 changes: 1 addition & 1 deletion hack/bin/set-wire-server-image-version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ target_version=${1?$USAGE}
TOP_LEVEL="$( cd "$( dirname "${BASH_SOURCE[0]}" )/../.." && pwd )"
CHARTS_DIR="$TOP_LEVEL/.local/charts"

charts=(brig cannon galley gundeck spar cargohold proxy cassandra-migrations elasticsearch-index federator backoffice integration)
charts=(brig cannon galley gundeck spar cargohold proxy cassandra-migrations elasticsearch-index federator backoffice background-worker integration)

for chart in "${charts[@]}"; do
sed -i "s/^ tag: .*/ tag: $target_version/g" "$CHARTS_DIR/$chart/values.yaml"
Expand Down
13 changes: 13 additions & 0 deletions hack/helm_vars/wire-server/values.yaml.gotmpl
Original file line number Diff line number Diff line change
Expand Up @@ -300,3 +300,16 @@ federator:
federationStrategy:
allowAll: true
useSystemCAStore: false

background-worker:
replicaCount: 1
resources:
requests: {}
imagePullPolicy: {{ .Values.imagePullPolicy }}
config:
# See helmfile for the real value
remoteDomains: []
secrets:
rabbitmq:
username: {{ .Values.rabbitmqUsername }}
password: {{ .Values.rabbitmqPassword }}
6 changes: 6 additions & 0 deletions hack/helmfile.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,9 @@ releases:
value: {{ .Values.federationDomain1 }}
- name: brig.config.optSettings.setFederationDomainConfigs[0].domain
value: {{ .Values.federationDomain2 }}
- name: background-worker.config.remoteDomains
values:
- {{ .Values.federationDomain2 }}
needs:
- 'databases-ephemeral'

Expand All @@ -159,5 +162,8 @@ releases:
value: {{ .Values.federationDomain2 }}
- name: brig.config.optSettings.setFederationDomainConfigs[0].domain
value: {{ .Values.federationDomain1 }}
- name: background-worker.config.remoteDomains
values:
- {{ .Values.federationDomain1 }}
needs:
- 'databases-ephemeral'
8 changes: 8 additions & 0 deletions libs/extended/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
# dependencies are added or removed.
{ mkDerivation
, aeson
, amqp
, base
, bytestring
, cassandra-util
Expand All @@ -18,13 +19,16 @@
, imports
, lib
, metrics-wai
, monad-control
, optparse-applicative
, resourcet
, retry
, servant
, servant-server
, servant-swagger
, string-conversions
, temporary
, text
, tinylog
, wai
}:
Expand All @@ -34,6 +38,7 @@ mkDerivation {
src = gitignoreSource ./.;
libraryHaskellDepends = [
aeson
amqp
base
bytestring
cassandra-util
Expand All @@ -44,12 +49,15 @@ mkDerivation {
http-types
imports
metrics-wai
monad-control
optparse-applicative
resourcet
retry
servant
servant-server
servant-swagger
string-conversions
text
tinylog
wai
];
Expand Down
6 changes: 6 additions & 0 deletions libs/extended/extended.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ license-file: LICENSE
build-type: Simple

library
-- cabal-fmt: expand src
exposed-modules:
Network.AMQP.Extended
Options.Applicative.Extended
Servant.API.Extended
Servant.API.Extended.RawM
Expand Down Expand Up @@ -74,6 +76,7 @@ library

build-depends:
aeson
, amqp
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this package is starting to bundle a lot of unrelated dependencies together, and inheriting them to a lot of places. but i don't think we should worry about this yet.

, base
, bytestring
, cassandra-util
Expand All @@ -84,12 +87,15 @@ library
, http-types
, imports
, metrics-wai
, monad-control
, optparse-applicative
, resourcet
, retry
, servant
, servant-server
, servant-swagger
, string-conversions
, text
, tinylog
, wai

Expand Down
Loading