Index: appengine/swarming/handlers_bot.py |
diff --git a/appengine/swarming/handlers_bot.py b/appengine/swarming/handlers_bot.py |
index f961b2cc8aae410dc31999441dfb5f93f72d3b67..a15ed7302dfdd1b862567273b1510b30e4e09956 100644 |
--- a/appengine/swarming/handlers_bot.py |
+++ b/appengine/swarming/handlers_bot.py |
@@ -92,22 +92,6 @@ def has_missing_keys(minimum_keys, actual_keys, name): |
return 'Unexpected %s%s; did you make a typo?' % (name, msg_missing) |
-def get_bot_contact_server(request): |
- """Gets the server contacted by the bot. |
- |
- Usually, this is the URL of the Swarming server itself, but if the bot |
- is communicating to the server by a gRPC intermediary, this will be the |
- IP address of the gRPC endpoint. The Native API will have an http or |
- https protocol, while gRPC endpoints will have a fake "grpc://" protocol. |
- This is to help consumers of this information (mainly the bot code |
- generators) distinguish between native and gRPC bots. |
- """ |
- server = request.host_url |
- if 'luci-grpc' in request.headers: |
- server = 'grpc://%s' % request.headers['luci-grpc'] |
- return server |
- |
- |
class _BotApiHandler(auth.ApiHandler): |
"""Like ApiHandler, but also implements machine authentication.""" |
@@ -174,10 +158,6 @@ class _BotAuthenticatingHandler(auth.AuthenticatingHandler): |
return bot_code.generate_bootstrap_token() if generate_token else None |
- def get_bot_contact_server(self): |
- """Gets the server contacted by the bot.""" |
- return get_bot_contact_server(self.request) |
- |
class BootstrapHandler(_BotAuthenticatingHandler): |
"""Returns python code to run to bootstrap a swarming bot.""" |
@@ -205,7 +185,7 @@ class BotCodeHandler(_BotAuthenticatingHandler): |
@auth.public # auth inside check_bot_code_access() |
def get(self, version=None): |
- server = self.get_bot_contact_server() |
+ server = self.request.host_url |
self.check_bot_code_access( |
bot_id=self.request.get('bot_id'), generate_token=False) |
if version: |
@@ -383,10 +363,6 @@ class _BotBaseHandler(_BotApiHandler): |
task_queues.assert_bot(dimensions) |
return result |
- def get_bot_contact_server(self): |
- """Gets the server contacted by the bot.""" |
- return get_bot_contact_server(self.request) |
- |
class BotHandshakeHandler(_BotBaseHandler): |
"""First request to be called to get initial data like bot code version. |
@@ -422,7 +398,7 @@ class BotHandshakeHandler(_BotBaseHandler): |
task_id='', task_name=None, message=res.quarantined_msg) |
data = { |
- 'bot_version': bot_code.get_bot_version(self.get_bot_contact_server())[0], |
+ 'bot_version': bot_code.get_bot_version(self.request.host_url)[0], |
'server_version': utils.get_app_version(), |
'bot_group_cfg_version': res.bot_group_cfg.version, |
'bot_group_cfg': { |
@@ -620,7 +596,7 @@ class BotPollHandler(_BotBaseHandler): |
# swarming_bot.zip |
logging.debug('Fetching bot code version') |
expected_version, _ = bot_code.get_bot_version( |
- self.get_bot_contact_server()) |
+ self.request.host_url) |
if res.version != expected_version: |
bot_event('request_update') |
self._cmd_update(expected_version) |