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

Unified Diff: appengine/swarming/swarming_bot/api/os_utilities.py

Issue 2911193003: Expose named caches as dimensions. (Closed)
Patch Set: . Created 3 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « appengine/swarming/local_smoke_test.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: appengine/swarming/swarming_bot/api/os_utilities.py
diff --git a/appengine/swarming/swarming_bot/api/os_utilities.py b/appengine/swarming/swarming_bot/api/os_utilities.py
index 28710d916c0135d0bbd602314a48aaca87677906..202f565f45ffbee336c3914b514f517f390edd49 100644
--- a/appengine/swarming/swarming_bot/api/os_utilities.py
+++ b/appengine/swarming/swarming_bot/api/os_utilities.py
@@ -1,3 +1,4 @@
+# coding: utf-8
# Copyright 2014 The LUCI Authors. All rights reserved.
# Use of this source code is governed under the Apache License, Version 2.0
# that can be found in the LICENSE file.
@@ -514,6 +515,30 @@ def get_uptime():
return platforms.linux.get_uptime()
+def get_named_caches():
+ """Returns the list of named caches."""
+ # Strictly speaking, this is a layering violation. This data is managed by
+ # run_isolated.py but this is valuable to expose this as a Swarming bot
+ # dimensions so ¯\_(ツ)_/¯
+ #
+ # Assumptions:
+ # - ../__main__.py calls os.chdir(__file__)
+ # - ../bot_code/bot_main.py specifies
+ # --named-cache-root os.path.join(botobj.base_dir, 'c') to run_isolated.
+ # - ../client/named_cache.py behavior
+ #
+ # A better implementation would require:
+ # - Access to bot.Bot instance to query bot.base_dir
+ # - Access to named_cache.py to load state.json
+ # - Access to --named-cache-root hardcoded in bot_main.py
+ #
+ # but hey, the following code is 4 lines...
+ d = os.path.join(os.getcwd(), u'c', u'named')
nodir 2017/05/31 16:52:06 "named" symlinks are best effort. Better not to pu
M-A Ruel 2017/05/31 20:45:32 Then maybe we shouldn't create them. :/ Either we
nodir 2017/05/31 21:03:21 we keep them for troopers and alike. My point is t
+ if not os.path.isdir(d):
+ return []
+ return [i for i in os.listdir(d)]
+
+
class AuthenticatedHttpRequestFailure(Exception):
pass
@@ -849,6 +874,9 @@ def get_dimensions():
u'os': [os_name],
u'pool': [u'default'],
}
+ caches = get_named_caches()
+ if caches:
+ dimensions[u'caches'] = caches
if u'avx2' in cpuinfo.get(u'flags', []):
dimensions[u'cpu'].append(cpu_type + u'-' + cpu_bitness + u'-avx2')
if any(u'avx512' in x for x in cpuinfo.get(u'flags', [])):
« no previous file with comments | « appengine/swarming/local_smoke_test.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698