[ARVADOS] updated: cbccf62a8f58b71f88606f66dbf57e2243caf0b9
git at public.curoverse.com
git at public.curoverse.com
Wed Feb 18 10:31:05 EST 2015
Summary of changes:
services/api/test/functional/arvados/v1/filters_test.rb | 3 +++
services/nodemanager/arvnodeman/computenode/__init__.py | 13 +++++++++++--
services/nodemanager/tests/testutil.py | 7 ++++---
3 files changed, 18 insertions(+), 5 deletions(-)
via cbccf62a8f58b71f88606f66dbf57e2243caf0b9 (commit)
from 9c8bad50218730ac2c640f8e1c00fd12f2f174e4 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
commit cbccf62a8f58b71f88606f66dbf57e2243caf0b9
Author: Brett Smith <brett at curoverse.com>
Date: Wed Feb 18 10:31:00 2015 -0500
4759: Update Node Manager to parse new Arvados API timestamps.
Refs #4759.
diff --git a/services/api/test/functional/arvados/v1/filters_test.rb b/services/api/test/functional/arvados/v1/filters_test.rb
index 2349993..9344b0b 100644
--- a/services/api/test/functional/arvados/v1/filters_test.rb
+++ b/services/api/test/functional/arvados/v1/filters_test.rb
@@ -72,6 +72,9 @@ class Arvados::V1::FiltersTest < ActionController::TestCase
%w(< > <= >= =).each do |operator|
test "timestamp #{operator} filters work with nanosecond precision" do
+ # Python clients like Node Manager rely on this exact format.
+ # If you must change this format for some reason, make sure you
+ # coordinate the change with them.
expect_match = !!operator.index('=')
mine = act_as_user users(:active) do
Collection.create!(manifest_text: '')
diff --git a/services/nodemanager/arvnodeman/computenode/__init__.py b/services/nodemanager/arvnodeman/computenode/__init__.py
index 30fe516..f518607 100644
--- a/services/nodemanager/arvnodeman/computenode/__init__.py
+++ b/services/nodemanager/arvnodeman/computenode/__init__.py
@@ -2,10 +2,13 @@
from __future__ import absolute_import, print_function
+import calendar
import itertools
+import re
import time
ARVADOS_TIMEFMT = '%Y-%m-%dT%H:%M:%SZ'
+ARVADOS_TIMESUBSEC_RE = re.compile(r'(\.\d+)Z$')
def arvados_node_fqdn(arvados_node, default_hostname='dynamic.compute'):
hostname = arvados_node.get('hostname') or default_hostname
@@ -15,8 +18,14 @@ def arvados_node_mtime(node):
return arvados_timestamp(node['modified_at'])
def arvados_timestamp(timestr):
- return time.mktime(time.strptime(timestr + 'UTC',
- ARVADOS_TIMEFMT + '%Z')) - time.timezone
+ subsec_match = ARVADOS_TIMESUBSEC_RE.search(timestr)
+ if subsec_match is None:
+ subsecs = .0
+ else:
+ subsecs = float(subsec_match.group(1))
+ timestr = timestr[:subsec_match.start()] + 'Z'
+ return calendar.timegm(time.strptime(timestr + 'UTC',
+ ARVADOS_TIMEFMT + '%Z'))
def timestamp_fresh(timestamp, fresh_time):
return (time.time() - timestamp) < fresh_time
diff --git a/services/nodemanager/tests/testutil.py b/services/nodemanager/tests/testutil.py
index d51aab2..1c53c68 100644
--- a/services/nodemanager/tests/testutil.py
+++ b/services/nodemanager/tests/testutil.py
@@ -2,6 +2,7 @@
from __future__ import absolute_import, print_function
+import datetime
import threading
import time
@@ -13,13 +14,13 @@ from . import pykka_timeout
no_sleep = mock.patch('time.sleep', lambda n: None)
def arvados_node_mock(node_num=99, job_uuid=None, age=0, **kwargs):
+ mod_time = datetime.datetime.utcnow() - datetime.timedelta(seconds=age)
if job_uuid is True:
job_uuid = 'zzzzz-jjjjj-jobjobjobjobjob'
crunch_worker_state = 'idle' if (job_uuid is None) else 'busy'
node = {'uuid': 'zzzzz-yyyyy-{:015x}'.format(node_num),
- 'created_at': '2014-01-01T01:02:03Z',
- 'modified_at': time.strftime('%Y-%m-%dT%H:%M:%SZ',
- time.gmtime(time.time() - age)),
+ 'created_at': '2014-01-01T01:02:03.04050607Z',
+ 'modified_at': mod_time.strftime('%Y-%m-%dT%H:%M:%S.%fZ'),
'slot_number': node_num,
'hostname': 'compute{}'.format(node_num),
'domain': 'zzzzz.arvadosapi.com',
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list