Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Log a warning if the homeserver is unreachable at startup #314

Merged
merged 2 commits into from
Sep 26, 2023

Conversation

DMRobertson
Copy link
Contributor

@DMRobertson DMRobertson commented Sep 26, 2023

Closes #286.

Tested as follows (see line 4):

Sync v3 [0.99.10] (6fe9b18)
Debug=true LogLevel= MaxConns=0
Starting prometheus listener on :6060
13:23:33 WRN Could not contact upstream homeserver. Is SYNCV3_SERVER set correctly? error="Get \"http://localhost:8888/_matrix/client/versions\": dial tcp [::1]:8888: connect: connection refused" dest=http://localhost:8888
2023/09/26 13:23:33 OK   20230728114555_device_data_drop_id.sql (7.48ms)
2023/09/26 13:23:33 OK   20230802121023_device_data_jsonb.go (13.85ms)
2023/09/26 13:23:33 OK   20230814183302_cbor_device_data.go (9.01ms)
2023/09/26 13:23:33 OK   20230822180807_bogus_snapshot_cleanup.go (7.64ms)
2023/09/26 13:23:33 OK   20230913120537_events_missing_previous.sql (7.15ms)
2023/09/26 13:23:33 goose: successfully migrated database to version: 20230913120537
13:23:33 INF creating handler
13:23:33 INF retrieved global snapshot from database
13:23:33 INF listening on 0.0.0.0:8844
13:23:33 INF StartV2Pollers num_devices=0 num_fail_decrypt=0
13:23:33 INF StartV2Pollers finished

Or for another example:

$ SYNCV3_SERVER=http://example.com SYNCV3_DB="user=$(whoami) dbname=syncv3_test sslmode=disable" SYNCV3_SECRET=secret SYNCV3_BINDADDR=0.0.0.0:8844 ./syncv3
Sync v3 [0.99.10] (7111ab1)
Debug=false LogLevel= MaxConns=0
13:28:24 WRN Could not contact upstream homeserver. Is SYNCV3_SERVER set correctly? error="/versions returned HTTP 404" dest=http://example.com
2023/09/26 13:28:24 goose: no migrations to run. current version: 20230913120537
13:28:24 INF creating handler
13:28:24 INF retrieved global snapshot from database
13:28:24 INF listening on 0.0.0.0:8844
13:28:24 INF StartV2Pollers num_devices=0 num_fail_decrypt=0
13:28:24 INF StartV2Pollers finished

Closes #286.

Tested as follows (see line 4):

```
Sync v3 [0.99.10] (6fe9b18)
Debug=true LogLevel= MaxConns=0
Starting prometheus listener on :6060
13:23:33 WRN Could not contact upstream homeserver. Is SYNCV3_SERVER set correctly? error="Get \"http://localhost:8888/_matrix/client/versions\": dial tcp [::1]:8888: connect: connection refused" dest=http://localhost:8888
2023/09/26 13:23:33 OK   20230728114555_device_data_drop_id.sql (7.48ms)
2023/09/26 13:23:33 OK   20230802121023_device_data_jsonb.go (13.85ms)
2023/09/26 13:23:33 OK   20230814183302_cbor_device_data.go (9.01ms)
2023/09/26 13:23:33 OK   20230822180807_bogus_snapshot_cleanup.go (7.64ms)
2023/09/26 13:23:33 OK   20230913120537_events_missing_previous.sql (7.15ms)
2023/09/26 13:23:33 goose: successfully migrated database to version: 20230913120537
13:23:33 INF creating handler
13:23:33 INF retrieved global snapshot from database
13:23:33 INF listening on 0.0.0.0:8844
13:23:33 INF StartV2Pollers num_devices=0 num_fail_decrypt=0
13:23:33 INF StartV2Pollers finished
```
@DMRobertson DMRobertson changed the title Check that the homeserver is reachable at startup Log a warning if the homeserver is unreachable at startup Sep 26, 2023
}
var parsedRes struct {
Result []string `json:"versions"`
}
Copy link
Member

Choose a reason for hiding this comment

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

Why bother parsing when we do nothing with it? Just waiting for a 200 OK is enough.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm sanity checking that you're receiving a proper Matrix /versions response and not just e.g. some Apache "it works" webpage.

@DMRobertson DMRobertson merged commit 2e6249a into main Sep 26, 2023
6 of 7 checks passed
@DMRobertson DMRobertson deleted the dmr/warn-if-hs-unreachable branch September 26, 2023 13:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Get the proxy to sanity-check it can contact the homeserver on startup
2 participants