Skip to content
This repository was archived by the owner on Apr 26, 2024. It is now read-only.

Commit 0d3b625

Browse files
committed
Merge remote-tracking branch 'origin/develop' into clokep/bundled-agg-fix-2
2 parents 9f3d783 + 6911604 commit 0d3b625

File tree

15 files changed

+208
-36
lines changed

15 files changed

+208
-36
lines changed

CHANGES.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
Synapse 1.51.0 (2022-01-25)
2+
===========================
3+
4+
No significant changes since 1.51.0rc2.
5+
6+
Synapse 1.51.0 deprecates `webclient` listeners and non-HTTP(S) `web_client_location`s. Support for these will be removed in Synapse 1.53.0, at which point Synapse will not be capable of directly serving a web client for Matrix. See the [upgrade notes](https://matrix-org.github.io/synapse/develop/upgrade#upgrading-to-v1510).
7+
18
Synapse 1.51.0rc2 (2022-01-24)
29
==============================
310

@@ -66,7 +73,7 @@ Deprecations and Removals
6673
- Remove the unstable `/send_relation` endpoint. ([\#11682](https://github.com/matrix-org/synapse/issues/11682))
6774
- Remove `python_twisted_reactor_pending_calls` Prometheus metric. ([\#11724](https://github.com/matrix-org/synapse/issues/11724))
6875
- Remove the `password_hash` field from the response dictionaries of the [Users Admin API](https://matrix-org.github.io/synapse/latest/admin_api/user_admin_api.html). ([\#11576](https://github.com/matrix-org/synapse/issues/11576))
69-
- Deprecate support for `webclient` listeners and non-HTTP(S) `web_client_location` configuration. ([\#11774](https://github.com/matrix-org/synapse/issues/11774), [\#11783](https://github.com/matrix-org/synapse/issues/11783))
76+
- **Deprecate support for `webclient` listeners and non-HTTP(S) `web_client_location` configuration. ([\#11774](https://github.com/matrix-org/synapse/issues/11774), [\#11783](https://github.com/matrix-org/synapse/issues/11783))**
7077

7178

7279
Internal Changes

changelog.d/11639.feature

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Add admin API to reset connection timeouts for remote server.

changelog.d/11817.misc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Compatibility with updated type hints for jsonschema 4.4.0.

debian/changelog

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,21 @@
1+
matrix-synapse-py3 (1.51.0) stable; urgency=medium
2+
3+
* New synapse release 1.51.0.
4+
5+
-- Synapse Packaging team <[email protected]> Tue, 25 Jan 2022 11:28:51 +0000
6+
17
matrix-synapse-py3 (1.51.0~rc2) stable; urgency=medium
28

39
* New synapse release 1.51.0~rc2.
410

511
-- Synapse Packaging team <[email protected]> Mon, 24 Jan 2022 12:25:00 +0000
612

13+
matrix-synapse-py3 (1.51.0~rc1) stable; urgency=medium
14+
15+
* New synapse release 1.51.0~rc1.
16+
17+
-- Synapse Packaging team <[email protected]> Fri, 21 Jan 2022 10:46:02 +0000
18+
719
matrix-synapse-py3 (1.50.2) stable; urgency=medium
820

921
* New synapse release 1.50.2.

docs/usage/administration/admin_api/federation.md

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ The following fields are returned in the JSON response body:
8686
- `next_token`: string representing a positive integer - Indication for pagination. See above.
8787
- `total` - integer - Total number of destinations.
8888

89-
# Destination Details API
89+
## Destination Details API
9090

9191
This API gets the retry timing info for a specific remote server.
9292

@@ -108,7 +108,45 @@ A response body like the following is returned:
108108
}
109109
```
110110

111+
**Parameters**
112+
113+
The following parameters should be set in the URL:
114+
115+
- `destination` - Name of the remote server.
116+
111117
**Response**
112118

113119
The response fields are the same like in the `destinations` array in
114120
[List of destinations](#list-of-destinations) response.
121+
122+
## Reset connection timeout
123+
124+
Synapse makes federation requests to other homeservers. If a federation request fails,
125+
Synapse will mark the destination homeserver as offline, preventing any future requests
126+
to that server for a "cooldown" period. This period grows over time if the server
127+
continues to fail its responses
128+
([exponential backoff](https://en.wikipedia.org/wiki/Exponential_backoff)).
129+
130+
Admins can cancel the cooldown period with this API.
131+
132+
This API resets the retry timing for a specific remote server and tries to connect to
133+
the remote server again. It does not wait for the next `retry_interval`.
134+
The connection must have previously run into an error and `retry_last_ts`
135+
([Destination Details API](#destination-details-api)) must not be equal to `0`.
136+
137+
The connection attempt is carried out in the background and can take a while
138+
even if the API already returns the http status 200.
139+
140+
The API is:
141+
142+
```
143+
POST /_synapse/admin/v1/federation/destinations/<destination>/reset_connection
144+
145+
{}
146+
```
147+
148+
**Parameters**
149+
150+
The following parameters should be set in the URL:
151+
152+
- `destination` - Name of the remote server.

synapse/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
except ImportError:
4848
pass
4949

50-
__version__ = "1.51.0rc2"
50+
__version__ = "1.51.0"
5151

5252
if bool(os.environ.get("SYNAPSE_TEST_PATCH_LOG_CONTEXTS", False)):
5353
# We import here so that we don't have to install a bunch of deps when

synapse/events/validator.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,9 @@ def _ensure_state_event(self, event: Union[EventBase, EventBuilder]) -> None:
246246

247247
# This could return something newer than Draft 7, but that's the current "latest"
248248
# validator.
249-
def _create_power_level_validator() -> jsonschema.Draft7Validator:
249+
#
250+
# See https://github.com/python/typeshed/issues/7028 for the ignored return type.
251+
def _create_power_level_validator() -> jsonschema.Draft7Validator: # type: ignore[valid-type]
250252
validator = jsonschema.validators.validator_for(POWER_LEVELS_SCHEMA)
251253

252254
# by default jsonschema does not consider a frozendict to be an object so

synapse/federation/transport/server/__init__.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515
import logging
16-
from typing import Dict, Iterable, List, Optional, Tuple, Type
16+
from typing import TYPE_CHECKING, Dict, Iterable, List, Optional, Tuple, Type
1717

1818
from typing_extensions import Literal
1919

@@ -36,17 +36,19 @@
3636
parse_integer_from_args,
3737
parse_string_from_args,
3838
)
39-
from synapse.server import HomeServer
4039
from synapse.types import JsonDict, ThirdPartyInstanceID
4140
from synapse.util.ratelimitutils import FederationRateLimiter
4241

42+
if TYPE_CHECKING:
43+
from synapse.server import HomeServer
44+
4345
logger = logging.getLogger(__name__)
4446

4547

4648
class TransportLayerServer(JsonResource):
4749
"""Handles incoming federation HTTP requests"""
4850

49-
def __init__(self, hs: HomeServer, servlet_groups: Optional[List[str]] = None):
51+
def __init__(self, hs: "HomeServer", servlet_groups: Optional[List[str]] = None):
5052
"""Initialize the TransportLayerServer
5153
5254
Will by default register all servlets. For custom behaviour, pass in
@@ -113,7 +115,7 @@ class PublicRoomList(BaseFederationServlet):
113115

114116
def __init__(
115117
self,
116-
hs: HomeServer,
118+
hs: "HomeServer",
117119
authenticator: Authenticator,
118120
ratelimiter: FederationRateLimiter,
119121
server_name: str,
@@ -203,7 +205,7 @@ class FederationGroupsRenewAttestaionServlet(BaseFederationServlet):
203205

204206
def __init__(
205207
self,
206-
hs: HomeServer,
208+
hs: "HomeServer",
207209
authenticator: Authenticator,
208210
ratelimiter: FederationRateLimiter,
209211
server_name: str,
@@ -251,7 +253,7 @@ class OpenIdUserInfo(BaseFederationServlet):
251253

252254
def __init__(
253255
self,
254-
hs: HomeServer,
256+
hs: "HomeServer",
255257
authenticator: Authenticator,
256258
ratelimiter: FederationRateLimiter,
257259
server_name: str,
@@ -297,7 +299,7 @@ async def on_GET(
297299

298300

299301
def register_servlets(
300-
hs: HomeServer,
302+
hs: "HomeServer",
301303
resource: HttpServer,
302304
authenticator: Authenticator,
303305
ratelimiter: FederationRateLimiter,

synapse/federation/transport/server/_base.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
import functools
1616
import logging
1717
import re
18-
from typing import Any, Awaitable, Callable, Optional, Tuple, cast
18+
from typing import TYPE_CHECKING, Any, Awaitable, Callable, Optional, Tuple, cast
1919

2020
from synapse.api.errors import Codes, FederationDeniedError, SynapseError
2121
from synapse.api.urls import FEDERATION_V1_PREFIX
@@ -29,11 +29,13 @@
2929
start_active_span_follows_from,
3030
whitelisted_homeserver,
3131
)
32-
from synapse.server import HomeServer
3332
from synapse.types import JsonDict
3433
from synapse.util.ratelimitutils import FederationRateLimiter
3534
from synapse.util.stringutils import parse_and_validate_server_name
3635

36+
if TYPE_CHECKING:
37+
from synapse.server import HomeServer
38+
3739
logger = logging.getLogger(__name__)
3840

3941

@@ -46,7 +48,7 @@ class NoAuthenticationError(AuthenticationError):
4648

4749

4850
class Authenticator:
49-
def __init__(self, hs: HomeServer):
51+
def __init__(self, hs: "HomeServer"):
5052
self._clock = hs.get_clock()
5153
self.keyring = hs.get_keyring()
5254
self.server_name = hs.hostname
@@ -114,11 +116,11 @@ async def authenticate_request(
114116
# alive
115117
retry_timings = await self.store.get_destination_retry_timings(origin)
116118
if retry_timings and retry_timings.retry_last_ts:
117-
run_in_background(self._reset_retry_timings, origin)
119+
run_in_background(self.reset_retry_timings, origin)
118120

119121
return origin
120122

121-
async def _reset_retry_timings(self, origin: str) -> None:
123+
async def reset_retry_timings(self, origin: str) -> None:
122124
try:
123125
logger.info("Marking origin %r as up", origin)
124126
await self.store.set_destination_retry_timings(origin, None, 0, 0)
@@ -227,7 +229,7 @@ class BaseFederationServlet:
227229

228230
def __init__(
229231
self,
230-
hs: HomeServer,
232+
hs: "HomeServer",
231233
authenticator: Authenticator,
232234
ratelimiter: FederationRateLimiter,
233235
server_name: str,

synapse/federation/transport/server/federation.py

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,17 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414
import logging
15-
from typing import Dict, List, Mapping, Optional, Sequence, Tuple, Type, Union
15+
from typing import (
16+
TYPE_CHECKING,
17+
Dict,
18+
List,
19+
Mapping,
20+
Optional,
21+
Sequence,
22+
Tuple,
23+
Type,
24+
Union,
25+
)
1626

1727
from typing_extensions import Literal
1828

@@ -30,11 +40,13 @@
3040
parse_string_from_args,
3141
parse_strings_from_args,
3242
)
33-
from synapse.server import HomeServer
3443
from synapse.types import JsonDict
3544
from synapse.util.ratelimitutils import FederationRateLimiter
3645
from synapse.util.versionstring import get_version_string
3746

47+
if TYPE_CHECKING:
48+
from synapse.server import HomeServer
49+
3850
logger = logging.getLogger(__name__)
3951
issue_8631_logger = logging.getLogger("synapse.8631_debug")
4052

@@ -47,7 +59,7 @@ class BaseFederationServerServlet(BaseFederationServlet):
4759

4860
def __init__(
4961
self,
50-
hs: HomeServer,
62+
hs: "HomeServer",
5163
authenticator: Authenticator,
5264
ratelimiter: FederationRateLimiter,
5365
server_name: str,
@@ -596,7 +608,7 @@ class FederationSpaceSummaryServlet(BaseFederationServlet):
596608

597609
def __init__(
598610
self,
599-
hs: HomeServer,
611+
hs: "HomeServer",
600612
authenticator: Authenticator,
601613
ratelimiter: FederationRateLimiter,
602614
server_name: str,
@@ -670,7 +682,7 @@ class FederationRoomHierarchyServlet(BaseFederationServlet):
670682

671683
def __init__(
672684
self,
673-
hs: HomeServer,
685+
hs: "HomeServer",
674686
authenticator: Authenticator,
675687
ratelimiter: FederationRateLimiter,
676688
server_name: str,
@@ -706,7 +718,7 @@ class RoomComplexityServlet(BaseFederationServlet):
706718

707719
def __init__(
708720
self,
709-
hs: HomeServer,
721+
hs: "HomeServer",
710722
authenticator: Authenticator,
711723
ratelimiter: FederationRateLimiter,
712724
server_name: str,

synapse/federation/transport/server/groups_local.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,20 @@
1111
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
14-
from typing import Dict, List, Tuple, Type
14+
from typing import TYPE_CHECKING, Dict, List, Tuple, Type
1515

1616
from synapse.api.errors import SynapseError
1717
from synapse.federation.transport.server._base import (
1818
Authenticator,
1919
BaseFederationServlet,
2020
)
2121
from synapse.handlers.groups_local import GroupsLocalHandler
22-
from synapse.server import HomeServer
2322
from synapse.types import JsonDict, get_domain_from_id
2423
from synapse.util.ratelimitutils import FederationRateLimiter
2524

25+
if TYPE_CHECKING:
26+
from synapse.server import HomeServer
27+
2628

2729
class BaseGroupsLocalServlet(BaseFederationServlet):
2830
"""Abstract base class for federation servlet classes which provides a groups local handler.
@@ -32,7 +34,7 @@ class BaseGroupsLocalServlet(BaseFederationServlet):
3234

3335
def __init__(
3436
self,
35-
hs: HomeServer,
37+
hs: "HomeServer",
3638
authenticator: Authenticator,
3739
ratelimiter: FederationRateLimiter,
3840
server_name: str,

synapse/federation/transport/server/groups_server.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
14-
from typing import Dict, List, Tuple, Type
14+
from typing import TYPE_CHECKING, Dict, List, Tuple, Type
1515

1616
from typing_extensions import Literal
1717

@@ -22,10 +22,12 @@
2222
BaseFederationServlet,
2323
)
2424
from synapse.http.servlet import parse_string_from_args
25-
from synapse.server import HomeServer
2625
from synapse.types import JsonDict, get_domain_from_id
2726
from synapse.util.ratelimitutils import FederationRateLimiter
2827

28+
if TYPE_CHECKING:
29+
from synapse.server import HomeServer
30+
2931

3032
class BaseGroupsServerServlet(BaseFederationServlet):
3133
"""Abstract base class for federation servlet classes which provides a groups server handler.
@@ -35,7 +37,7 @@ class BaseGroupsServerServlet(BaseFederationServlet):
3537

3638
def __init__(
3739
self,
38-
hs: HomeServer,
40+
hs: "HomeServer",
3941
authenticator: Authenticator,
4042
ratelimiter: FederationRateLimiter,
4143
server_name: str,

synapse/rest/admin/__init__.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@
4141
EventReportsRestServlet,
4242
)
4343
from synapse.rest.admin.federation import (
44-
DestinationsRestServlet,
44+
DestinationResetConnectionRestServlet,
45+
DestinationRestServlet,
4546
ListDestinationsRestServlet,
4647
)
4748
from synapse.rest.admin.groups import DeleteGroupAdminRestServlet
@@ -267,7 +268,8 @@ def register_servlets(hs: "HomeServer", http_server: HttpServer) -> None:
267268
ListRegistrationTokensRestServlet(hs).register(http_server)
268269
NewRegistrationTokenRestServlet(hs).register(http_server)
269270
RegistrationTokenRestServlet(hs).register(http_server)
270-
DestinationsRestServlet(hs).register(http_server)
271+
DestinationResetConnectionRestServlet(hs).register(http_server)
272+
DestinationRestServlet(hs).register(http_server)
271273
ListDestinationsRestServlet(hs).register(http_server)
272274

273275
# Some servlets only get registered for the main process.

0 commit comments

Comments
 (0)