Skip to content

Commit f87103c

Browse files
authored
Restore behavior passing FlyteClient kwargs to gRPC channel creation (#3303)
Signed-off-by: Clint Harrison <clint@stripe.com>
1 parent 44af03f commit f87103c

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

flytekit/clients/raw.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,15 @@ def __init__(self, cfg: PlatformConfig, **kwargs):
4949
# StreamRemoved exception.
5050
# https://github.com/flyteorg/flyte/blob/e8588f3a04995a420559327e78c3f95fbf64dc01/flyteadmin/pkg/common/constants.go#L14
5151
# 32KB for error messages, 20MB for actual messages.
52-
options = (("grpc.max_metadata_size", 32 * 1024), ("grpc.max_receive_message_length", 20 * 1024 * 1024))
52+
options = [
53+
("grpc.max_metadata_size", 32 * 1024),
54+
("grpc.max_receive_message_length", 20 * 1024 * 1024),
55+
] + kwargs.pop("options", [])
5356
self._cfg = cfg
5457
self._channel = wrap_exceptions_channel(
5558
cfg,
5659
upgrade_channel_to_authenticated(
57-
cfg, upgrade_channel_to_proxy_authenticated(cfg, get_channel(cfg, options=options))
60+
cfg, upgrade_channel_to_proxy_authenticated(cfg, get_channel(cfg, options=options, **kwargs))
5861
),
5962
)
6063
self._stub = _admin_service.AdminServiceStub(self._channel)

tests/flytekit/unit/clients/test_raw.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,22 @@ def test_list_projects_paginated(mock_channel, mock_admin):
2020
project_list_request = _project_pb2.ProjectListRequest(limit=100, token="", filters=None, sort_by=None)
2121
client.list_projects(project_list_request)
2222
mock_admin.AdminServiceStub().ListProjects.assert_called_with(project_list_request, metadata=None)
23+
24+
25+
@mock.patch("flytekit.clients.raw.grpc.insecure_channel")
26+
def test_kwargs_passed_to_channel(mock_channel):
27+
RawSynchronousFlyteClient(
28+
PlatformConfig(endpoint="a.b.com", insecure=True),
29+
options=[("grpc.default_authority", "foo.b.net")],
30+
)
31+
32+
mock_channel.assert_called_with(
33+
"a.b.com",
34+
options=[
35+
# ensure we're always passing these defaults
36+
("grpc.max_metadata_size", mock.ANY),
37+
("grpc.max_receive_message_length", mock.ANY),
38+
# as well as the user-provided options
39+
("grpc.default_authority", "foo.b.net"),
40+
],
41+
)

0 commit comments

Comments
 (0)