Skip to content

Commit

Permalink
[ConnectedK8s] Add support for multiple proxy instances running on th…
Browse files Browse the repository at this point in the history
…e same machine using different ports (#7455)
  • Loading branch information
RyanBDB committed Apr 9, 2024
1 parent 4aa3324 commit 7087f56
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
4 changes: 4 additions & 0 deletions src/connectedk8s/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
Release History
===============

1.6.8
++++++
* Add support for running multiple proxy instances on the same machine using different ports.

1.6.7
++++++
* Improve Error logs during Arc Onboarding scenarios, Style fixes.
Expand Down
12 changes: 9 additions & 3 deletions src/connectedk8s/azext_connectedk8s/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -1951,8 +1951,14 @@ def client_side_proxy_wrapper(cmd,
tenant_id = profile.get_subscription()['tenantId']

client_proxy_port = consts.CLIENT_PROXY_PORT

# Check if the internal port is already open. If so and the user has specified a port,
# try using the port before the user specified port instead.
if clientproxyutils.check_if_port_is_open(client_proxy_port) and api_server_port != consts.API_SERVER_PORT:
client_proxy_port = int(api_server_port) - 1

if int(client_proxy_port) == int(api_server_port):
raise ClientRequestError('Proxy uses port 47010 internally.', recommendation='Please pass some other unused port through --port option.')
raise ClientRequestError(f'Proxy uses port {client_proxy_port} internally.', recommendation='Please pass some other unused port through --port option.')

args = []
operating_system = platform.system()
Expand All @@ -1961,8 +1967,8 @@ def client_side_proxy_wrapper(cmd,
telemetry.set_debug_info('CSP Version is ', consts.CLIENT_PROXY_VERSION)
telemetry.set_debug_info('OS is ', operating_system)

if (clientproxyutils.check_process(proc_name)):
raise ClientRequestError('Another instance of proxy already running')
if (clientproxyutils.check_process(proc_name)) and clientproxyutils.check_if_port_is_open(api_server_port):
raise ClientRequestError('The proxy port is already in use, potentially by another proxy instance.', recommendation='Please stop the existing proxy instance or pass a different port through --port option.')

port_error_string = ""
if clientproxyutils.check_if_port_is_open(api_server_port):
Expand Down
2 changes: 1 addition & 1 deletion src/connectedk8s/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
# TODO: Confirm this is the right version number you want and it matches your
# HISTORY.rst entry.

VERSION = '1.6.7'
VERSION = '1.6.8'

# The full list of classifiers is available at
# https://pypi.python.org/pypi?%3Aaction=list_classifiers
Expand Down

0 comments on commit 7087f56

Please sign in to comment.