12061: Don't round down to 1s in timestamp parser.
authorTom Clegg <tclegg@veritasgenetics.com>
Wed, 30 May 2018 20:32:20 +0000 (16:32 -0400)
committerTom Clegg <tclegg@veritasgenetics.com>
Wed, 30 May 2018 20:32:20 +0000 (16:32 -0400)
ComputeNodeMonitorActor.offer_arvados_pair() pairs nodes only if

  first_ping_time >= cloud_node_start_time

However, first_ping_time is passed through arvados_timestamp() before
this comparison, which was truncating the subsecond part -- so the
comparison was effectively

  floor(first_ping_time) >= cloud_node_start_time

When FPT and CNST differed only in the subsecond part, this comparison
failed, and the nodes could never be paired. This caused sporadic
failures in tests, where the two values are often separated by less
than a second.

Arvados-DCO-1.1-Signed-off-by: Tom Clegg <tclegg@veritasgenetics.com>

services/nodemanager/arvnodeman/computenode/__init__.py
services/nodemanager/tests/test_computenode.py

index 3c04118abe2ec2bb3f5fee4c1a74e078d61119ed..b124c66540aab804db3ad555b048c9ef5097e8d0 100644 (file)
@@ -33,7 +33,7 @@ def arvados_timestamp(timestr):
         subsecs = float(subsec_match.group(1))
         timestr = timestr[:subsec_match.start()] + 'Z'
     return calendar.timegm(time.strptime(timestr + 'UTC',
-                                         ARVADOS_TIMEFMT + '%Z'))
+                                         ARVADOS_TIMEFMT + '%Z')) + subsecs
 
 def timestamp_fresh(timestamp, fresh_time):
     return (time.time() - timestamp) < fresh_time
index 3f11ff6c2b22d02a47b8f8e9a6bfe246479d10ed..898112bdd8a8c8df86bf80e0a4af1aac3c592ec8 100644 (file)
@@ -37,3 +37,9 @@ class ShutdownTimerTestCase(unittest.TestCase):
         time_mock.return_value += 200
         self.assertEqual(961, timer.next_opening())
         self.assertFalse(timer.window_open())
+
+
+class ArvadosTimestamp(unittest.TestCase):
+    def test_arvados_timestamp(self):
+        self.assertEqual(1527710178, cnode.arvados_timestamp('2018-05-30T19:56:18Z'))
+        self.assertEqual(1527710178.999371, cnode.arvados_timestamp('2018-05-30T19:56:18.999371Z'))