Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7)

Side by Side Diff: appengine/swarming/handlers_endpoints.py

Issue 2661173004: Make deleted bots still show up when searched for by id (Closed)
Patch Set: Don't forget MP stuff Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 # Copyright 2015 The LUCI Authors. All rights reserved. 1 # Copyright 2015 The LUCI Authors. All rights reserved.
2 # Use of this source code is governed under the Apache License, Version 2.0 2 # Use of this source code is governed under the Apache License, Version 2.0
3 # that can be found in the LICENSE file. 3 # that can be found in the LICENSE file.
4 4
5 """This module defines Swarming Server endpoints handlers.""" 5 """This module defines Swarming Server endpoints handlers."""
6 6
7 import logging 7 import logging
8 import os 8 import os
9 9
10 from google.appengine.api import datastore_errors 10 from google.appengine.api import datastore_errors
(...skipping 537 matching lines...) Expand 10 before | Expand all | Expand 10 after
548 path='{bot_id}/get', 548 path='{bot_id}/get',
549 http_method='GET') 549 http_method='GET')
550 @auth.require(acl.is_privileged_user) 550 @auth.require(acl.is_privileged_user)
551 def get(self, request): 551 def get(self, request):
552 """Returns information about a known bot. 552 """Returns information about a known bot.
553 553
554 This includes its state and dimensions, and if it is currently running a 554 This includes its state and dimensions, and if it is currently running a
555 task. 555 task.
556 """ 556 """
557 logging.info('%s', request) 557 logging.info('%s', request)
558 bot = get_or_raise(bot_management.get_info_key(request.bot_id)) 558 bot_id = request.bot_id
559 bot = bot_management.get_info_key(bot_id).get()
560
M-A Ruel 2017/01/31 18:45:04 remove one line or even better both :)
kjlubick 2017/01/31 19:04:40 Done.
561
562 if not bot:
563 # If there is not BotInfo, look if there are BotEvent child of this
564 # entity. If this is the case, it means the bot was deleted but it's
565 # useful to show information about it to the user even if the bot was
566 # deleted. For example, it could be an machine-provider bot.
567 events = bot_management.get_events_query(bot_id, True).fetch(1)
568 if not events:
569 raise endpoints.NotFoundException('%s not found.' % bot_id)
570 bot = bot_management.BotInfo(
571 key=bot_management.get_info_key(bot_id),
572 dimensions_flat=bot_management.dimensions_to_flat(
573 events[0].dimensions),
574 state=events[0].state,
575 external_ip=events[0].external_ip,
576 authenticated_as=events[0].authenticated_as,
577 version=events[0].version,
578 quarantined=events[0].quarantined,
579 task_id=events[0].task_id,
580 last_seen_ts=events[0].ts,
581 lease_id=events[0].lease_id,
582 lease_expiration_ts=events[0].lease_expiration_ts,
583 machine_type=events[0].machine_type,
584 deleted=True)
585
559 return message_conversion.bot_info_to_rpc(bot, utils.utcnow()) 586 return message_conversion.bot_info_to_rpc(bot, utils.utcnow())
M-A Ruel 2017/01/31 18:45:04 modify bot_info_to_rpc instead to accept a new fla
kjlubick 2017/01/31 19:04:40 Done.
560 587
561 @gae_ts_mon.instrument_endpoint() 588 @gae_ts_mon.instrument_endpoint()
562 @auth.endpoints_method( 589 @auth.endpoints_method(
563 BotId, swarming_rpcs.DeletedResponse, 590 BotId, swarming_rpcs.DeletedResponse,
564 name='delete', 591 name='delete',
565 path='{bot_id}/delete') 592 path='{bot_id}/delete')
566 @auth.require(acl.is_admin) 593 @auth.require(acl.is_admin)
567 def delete(self, request): 594 def delete(self, request):
568 """Deletes the bot corresponding to a provided bot_id. 595 """Deletes the bot corresponding to a provided bot_id.
569 596
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
773 def get_routes(): 800 def get_routes():
774 return ( 801 return (
775 endpoints_webapp2.api_routes(SwarmingServerService) + 802 endpoints_webapp2.api_routes(SwarmingServerService) +
776 endpoints_webapp2.api_routes(SwarmingTaskService) + 803 endpoints_webapp2.api_routes(SwarmingTaskService) +
777 endpoints_webapp2.api_routes(SwarmingTasksService) + 804 endpoints_webapp2.api_routes(SwarmingTasksService) +
778 endpoints_webapp2.api_routes(SwarmingBotService) + 805 endpoints_webapp2.api_routes(SwarmingBotService) +
779 endpoints_webapp2.api_routes(SwarmingBotsService) + 806 endpoints_webapp2.api_routes(SwarmingBotsService) +
780 # components.config endpoints for validation and configuring of luci-config 807 # components.config endpoints for validation and configuring of luci-config
781 # service URL. 808 # service URL.
782 endpoints_webapp2.api_routes(config.ConfigApi)) 809 endpoints_webapp2.api_routes(config.ConfigApi))
OLDNEW
« no previous file with comments | « no previous file | appengine/swarming/handlers_endpoints_test.py » ('j') | appengine/swarming/server/bot_management.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698