[ARVADOS] updated: 94d2af98f5882985e57d8dd1b17a2fd2e8cc8734

git at public.curoverse.com git at public.curoverse.com
Mon Mar 16 09:52:31 EDT 2015


Summary of changes:
 apps/workbench/Gemfile                             |  2 +-
 apps/workbench/Gemfile.lock                        |  4 +--
 .../app/assets/javascripts/application.js          |  3 +++
 .../app/assets/stylesheets/application.css.scss    | 10 ++++++++
 .../application/_show_autoselect_text.html.erb     |  4 +++
 .../collections/_show_source_summary.html.erb      |  4 +++
 apps/workbench/app/views/collections/show.html.erb | 23 +++++++++--------
 doc/_config.yml                                    |  6 +----
 doc/_includes/_navbar_top.liquid                   |  7 +++--
 doc/admin/index.html.md.liquid                     | 14 ----------
 doc/index.html.liquid                              |  3 ---
 .../cheat_sheet.html.textile.liquid                | 10 +++++---
 sdk/ruby/lib/arvados/keep.rb                       |  5 ++++
 sdk/ruby/test/test_keep_manifest.rb                | 13 ++++++++++
 .../api/app/controllers/application_controller.rb  |  5 ++--
 .../app/controllers/arvados/v1/jobs_controller.rb  |  9 ++++---
 .../app/controllers/arvados/v1/nodes_controller.rb |  2 +-
 .../controllers/arvados/v1/schema_controller.rb    |  2 +-
 services/api/app/middlewares/arvados_api_token.rb  |  7 +++--
 services/api/app/models/arvados_model.rb           |  6 +++--
 services/api/app/models/job.rb                     | 10 ++++----
 services/api/app/models/keep_disk.rb               |  2 +-
 services/api/app/models/log.rb                     |  4 +--
 services/api/app/models/node.rb                    | 10 +++++---
 .../api/config/initializers/db_current_time.rb     |  1 +
 services/api/lib/db_current_time.rb                |  7 +++++
 services/api/lib/simulate_job_log.rb               |  8 ++++--
 services/api/script/cancel_stale_jobs.rb           |  8 +++---
 services/api/script/crunch-dispatch.rb             | 30 ++++++++++++----------
 services/api/script/get_anonymous_user_token.rb    |  6 +++--
 services/api/test/unit/log_test.rb                 |  2 +-
 services/keepstore/keepstore.go                    | 16 +++++-------
 32 files changed, 143 insertions(+), 100 deletions(-)
 create mode 100644 apps/workbench/app/views/application/_show_autoselect_text.html.erb
 delete mode 100644 doc/admin/index.html.md.liquid
 rename doc/{admin => install}/cheat_sheet.html.textile.liquid (70%)
 create mode 100644 services/api/config/initializers/db_current_time.rb
 create mode 100644 services/api/lib/db_current_time.rb

       via  94d2af98f5882985e57d8dd1b17a2fd2e8cc8734 (commit)
       via  1e54d655b91afae99816f47ac3b9283ae12ba4c2 (commit)
       via  71c4fdc3352ad5ca34c2f260fe43fa1150868a04 (commit)
       via  2f27d8fa4c8f10989d1066df4df9c8995ee755f5 (commit)
       via  1bda9759f558316f01894634504a4346085be24d (commit)
       via  a7f932428b30582f54ea26084813eb7b3e8f3251 (commit)
       via  6e066d1a18a699e7abb20dda25670f814e1eb3b3 (commit)
       via  e893c4e1c4cb3b5f564517d281906f28e8799617 (commit)
       via  40d408b31405c780160490ddcc104be7d5a99368 (commit)
       via  a0f20c7a3e15b30efb1c48671a0fd4e1d87b21bc (commit)
       via  995af457bf39bfa82556a6f565efd30263a98415 (commit)
       via  bf213b6340f66bec945ceab8d2bab59f7ca17a6f (commit)
      from  40d04a669958fb777f4cf4a93ae7e21d101a438f (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 94d2af98f5882985e57d8dd1b17a2fd2e8cc8734
Author: Radhika Chippada <radhika at curoverse.com>
Date:   Mon Mar 16 09:51:54 2015 -0400

    5383: use db current time in place of Time.now

diff --git a/services/api/app/controllers/application_controller.rb b/services/api/app/controllers/application_controller.rb
index 69c03bd..638d236 100644
--- a/services/api/app/controllers/application_controller.rb
+++ b/services/api/app/controllers/application_controller.rb
@@ -21,6 +21,7 @@ class ApplicationController < ActionController::Base
   include ThemesForRails::ActionController
   include LoadParam
   include RecordFilters
+  include DbCurrentTime
 
   respond_to :json
   protect_from_forgery
@@ -176,7 +177,7 @@ class ApplicationController < ActionController::Base
       err = {}
     end
     err[:errors] ||= args
-    err[:error_token] = [Time.now.utc.to_i, "%08x" % rand(16 ** 8)].join("+")
+    err[:error_token] = [db_current_time.utc.to_i, "%08x" % rand(16 ** 8)].join("+")
     status = err.delete(:status) || 422
     logger.error "Error #{err[:error_token]}: #{status}"
     send_json err, status: status
@@ -527,7 +528,7 @@ class ApplicationController < ActionController::Base
           params[:_profile] &&
           Thread.current[:request_starttime]
         response[:_profile] = {
-          request_time: Time.now - Thread.current[:request_starttime]
+          request_time: db_current_time - Thread.current[:request_starttime]
         }
       end
     end
diff --git a/services/api/app/controllers/arvados/v1/jobs_controller.rb b/services/api/app/controllers/arvados/v1/jobs_controller.rb
index bd6cbd0..3a255ad 100644
--- a/services/api/app/controllers/arvados/v1/jobs_controller.rb
+++ b/services/api/app/controllers/arvados/v1/jobs_controller.rb
@@ -122,8 +122,9 @@ class Arvados::V1::JobsController < ApplicationController
       while not @job.started_at
         # send a summary (job queue + available nodes) to the client
         # every few seconds while waiting for the job to start
-        last_ack_at ||= Time.now - Q_UPDATE_INTERVAL - 1
-        if Time.now - last_ack_at >= Q_UPDATE_INTERVAL
+        current_time = db_current_time
+        last_ack_at ||= current_time - Q_UPDATE_INTERVAL - 1
+        if current_time - last_ack_at >= Q_UPDATE_INTERVAL
           nodes_in_state = {idle: 0, alloc: 0}
           ActiveRecord::Base.uncached do
             Node.where('hostname is not ?', nil).collect do |n|
@@ -139,13 +140,13 @@ class Arvados::V1::JobsController < ApplicationController
             break if j.uuid == @job.uuid
             n_queued_before_me += 1
           end
-          yield "#{Time.now}" \
+          yield "#{db_current_time}" \
             " job #{@job.uuid}" \
             " queue_position #{n_queued_before_me}" \
             " queue_size #{job_queue.size}" \
             " nodes_idle #{nodes_in_state[:idle]}" \
             " nodes_alloc #{nodes_in_state[:alloc]}\n"
-          last_ack_at = Time.now
+          last_ack_at = db_current_time
         end
         sleep 3
         ActiveRecord::Base.uncached do
diff --git a/services/api/app/controllers/arvados/v1/nodes_controller.rb b/services/api/app/controllers/arvados/v1/nodes_controller.rb
index 44197a0..fc3384b 100644
--- a/services/api/app/controllers/arvados/v1/nodes_controller.rb
+++ b/services/api/app/controllers/arvados/v1/nodes_controller.rb
@@ -41,7 +41,7 @@ class Arvados::V1::NodesController < ApplicationController
     if !current_user.andand.is_admin && current_user.andand.is_active
       # active non-admin users can list nodes that are (or were
       # recently) working
-      @objects = model_class.where('last_ping_at >= ?', Time.now - 1.hours)
+      @objects = model_class.where('last_ping_at >= ?', db_current_time - 1.hours)
     end
     super
     job_uuids = @objects.map { |n| n[:job_uuid] }.compact
diff --git a/services/api/app/controllers/arvados/v1/schema_controller.rb b/services/api/app/controllers/arvados/v1/schema_controller.rb
index 8dc90e1..5a84ef5 100644
--- a/services/api/app/controllers/arvados/v1/schema_controller.rb
+++ b/services/api/app/controllers/arvados/v1/schema_controller.rb
@@ -21,7 +21,7 @@ class Arvados::V1::SchemaController < ApplicationController
         version: "v1",
         revision: "20131114",
         source_version: (Rails.application.config.source_version ? Rails.application.config.source_version : "No version information available") + (Rails.application.config.local_modified ? Rails.application.config.local_modified.to_s : ''),
-        generatedAt: Time.now.iso8601,
+        generatedAt: db_current_time.iso8601,
         title: "Arvados API",
         description: "The API to interact with Arvados.",
         documentationLink: "http://doc.arvados.org/api/index.html",
diff --git a/services/api/app/middlewares/arvados_api_token.rb b/services/api/app/middlewares/arvados_api_token.rb
index 57d3ad0..2bee50c 100644
--- a/services/api/app/middlewares/arvados_api_token.rb
+++ b/services/api/app/middlewares/arvados_api_token.rb
@@ -2,7 +2,10 @@
 # this in the Rack stack instead of in ApplicationController because
 # websockets needs access to authentication but doesn't use any of the rails
 # active dispatch infrastructure.
+require 'db_current_time'
+
 class ArvadosApiToken
+  include DbCurrentTime
 
   # Create a new ArvadosApiToken handler
   # +app+  The next layer of the Rack stack.
@@ -24,7 +27,7 @@ class ArvadosApiToken
     params = request.params
     remote_ip = env["action_dispatch.remote_ip"]
 
-    Thread.current[:request_starttime] = Time.now
+    Thread.current[:request_starttime] = db_current_time
     user = nil
     api_client = nil
     api_client_auth = nil
@@ -51,7 +54,7 @@ class ArvadosApiToken
     Thread.current[:api_client] = api_client
     Thread.current[:user] = user
     if api_client_auth
-      api_client_auth.last_used_at = Time.now
+      api_client_auth.last_used_at = db_current_time
       api_client_auth.last_used_by_ip_address = remote_ip.to_s
       api_client_auth.save validate: false
     end
diff --git a/services/api/app/models/arvados_model.rb b/services/api/app/models/arvados_model.rb
index cf0aba9..1fe5808 100644
--- a/services/api/app/models/arvados_model.rb
+++ b/services/api/app/models/arvados_model.rb
@@ -4,6 +4,7 @@ class ArvadosModel < ActiveRecord::Base
   self.abstract_class = true
 
   include CurrentApiClient      # current_user, current_api_client, etc.
+  include DbCurrentTime
 
   attr_protected :created_at
   attr_protected :modified_by_user_uuid
@@ -358,9 +359,10 @@ class ArvadosModel < ActiveRecord::Base
   end
 
   def update_modified_by_fields
-    self.updated_at = Time.now
+    current_time = db_current_time
+    self.updated_at = current_time
     self.owner_uuid ||= current_default_owner if self.respond_to? :owner_uuid=
-    self.modified_at = Time.now
+    self.modified_at = current_time
     self.modified_by_user_uuid = current_user ? current_user.uuid : nil
     self.modified_by_client_uuid = current_api_client ? current_api_client.uuid : nil
     true
diff --git a/services/api/app/models/job.rb b/services/api/app/models/job.rb
index 934c7fa..01df069 100644
--- a/services/api/app/models/job.rb
+++ b/services/api/app/models/job.rb
@@ -63,7 +63,7 @@ class Job < ArvadosModel
            ]
 
   def assert_finished
-    update_attributes(finished_at: finished_at || Time.now,
+    update_attributes(finished_at: finished_at || db_current_time,
                       success: success.nil? ? false : success,
                       running: false)
   end
@@ -239,7 +239,7 @@ class Job < ArvadosModel
       # Ensure cancelled_at cannot be set to arbitrary non-now times,
       # or changed once it is set.
       if self.cancelled_at and not self.cancelled_at_was
-        self.cancelled_at = Time.now
+        self.cancelled_at = db_current_time
         self.cancelled_by_user_uuid = current_user.uuid
         self.cancelled_by_client_uuid = current_api_client.andand.uuid
         @need_crunch_dispatch_trigger = true
@@ -265,11 +265,11 @@ class Job < ArvadosModel
 
     case state
     when Running
-      self.started_at ||= Time.now
+      self.started_at ||= db_current_time
     when Failed, Complete
-      self.finished_at ||= Time.now
+      self.finished_at ||= db_current_time
     when Cancelled
-      self.cancelled_at ||= Time.now
+      self.cancelled_at ||= db_current_time
     end
 
     # TODO: Remove the following case block when old "success" and
diff --git a/services/api/app/models/keep_disk.rb b/services/api/app/models/keep_disk.rb
index da421eb..4623393 100644
--- a/services/api/app/models/keep_disk.rb
+++ b/services/api/app/models/keep_disk.rb
@@ -44,7 +44,7 @@ class KeepDisk < ArvadosModel
                               :last_read_at,
                               :last_write_at
                              ].collect(&:to_s).index k
-                           }.merge(last_ping_at: Time.now))
+                           }.merge(last_ping_at: db_current_time))
   end
 
   def service_host
diff --git a/services/api/app/models/log.rb b/services/api/app/models/log.rb
index 39f789e..b10a491 100644
--- a/services/api/app/models/log.rb
+++ b/services/api/app/models/log.rb
@@ -48,7 +48,7 @@ class Log < ArvadosModel
     when "update"
       self.event_at = thing.modified_at
     when "destroy"
-      self.event_at = Time.now
+      self.event_at = db_current_time
     end
     self
   end
@@ -66,7 +66,7 @@ class Log < ArvadosModel
   alias_method :permission_to_delete, :permission_to_update
 
   def set_default_event_at
-    self.event_at ||= Time.now
+    self.event_at ||= db_current_time
   end
 
   def log_start_state
diff --git a/services/api/app/models/node.rb b/services/api/app/models/node.rb
index c38f681..bf27f6f 100644
--- a/services/api/app/models/node.rb
+++ b/services/api/app/models/node.rb
@@ -61,12 +61,12 @@ class Node < ArvadosModel
 
   def status
     if !self.last_ping_at
-      if Time.now - self.created_at > 5.minutes
+      if db_current_time - self.created_at > 5.minutes
         'startup-fail'
       else
         'pending'
       end
-    elsif Time.now - self.last_ping_at > 1.hours
+    elsif db_current_time - self.last_ping_at > 1.hours
       'missing'
     else
       'running'
@@ -80,7 +80,9 @@ class Node < ArvadosModel
       logger.info "Ping: secret mismatch: received \"#{o[:ping_secret]}\" != \"#{self.info['ping_secret']}\""
       raise ArvadosModel::UnauthorizedError.new("Incorrect ping_secret")
     end
-    self.last_ping_at = Time.now
+
+    current_time = db_current_time
+    self.last_ping_at = current_time
 
     @bypass_arvados_authorization = true
 
@@ -88,7 +90,7 @@ class Node < ArvadosModel
     if self.ip_address.nil?
       logger.info "#{self.uuid} ip_address= #{o[:ip]}"
       self.ip_address = o[:ip]
-      self.first_ping_at = Time.now
+      self.first_ping_at = current_time
     end
 
     # Record instance ID if not already known
diff --git a/services/api/config/initializers/db_current_time.rb b/services/api/config/initializers/db_current_time.rb
new file mode 100644
index 0000000..1da7b86
--- /dev/null
+++ b/services/api/config/initializers/db_current_time.rb
@@ -0,0 +1 @@
+require 'db_current_time'
diff --git a/services/api/lib/db_current_time.rb b/services/api/lib/db_current_time.rb
new file mode 100644
index 0000000..ef68b0d
--- /dev/null
+++ b/services/api/lib/db_current_time.rb
@@ -0,0 +1,7 @@
+module DbCurrentTime
+  CURRENT_TIME_SQL = "SELECT CURRENT_TIMESTAMP"
+
+  def db_current_time
+    Time.parse(ActiveRecord::Base.connection.select_value(CURRENT_TIME_SQL)).to_time
+  end
+end
diff --git a/services/api/lib/simulate_job_log.rb b/services/api/lib/simulate_job_log.rb
index fc124c8..65ab021 100644
--- a/services/api/lib/simulate_job_log.rb
+++ b/services/api/lib/simulate_job_log.rb
@@ -1,11 +1,15 @@
+require 'db_current_time'
+
 module SimulateJobLog
+  include DbCurrentTime
+
   def replay(filename, multiplier = 1, simulated_job_uuid = nil)
     raise "Environment must be development or test" unless [ 'test', 'development' ].include? ENV['RAILS_ENV']
 
     multiplier = multiplier.to_f
     multiplier = 1.0 if multiplier <= 0
 
-    actual_start_time = Time.now
+    actual_start_time = db_current_time
     log_start_time = nil
 
     act_as_system_user do
@@ -29,7 +33,7 @@ module SimulateJobLog
         # determine when we want to simulate this log being created, based on the time multiplier
         log_start_time = cols[:timestamp] if log_start_time.nil?
         log_time = cols[:timestamp]
-        actual_elapsed_time = Time.now - actual_start_time
+        actual_elapsed_time = db_current_time - actual_start_time
         log_elapsed_time = log_time - log_start_time
         modified_elapsed_time = log_elapsed_time / multiplier
         pause_time = modified_elapsed_time - actual_elapsed_time
diff --git a/services/api/script/cancel_stale_jobs.rb b/services/api/script/cancel_stale_jobs.rb
index 4949ec0..e59e8d7 100755
--- a/services/api/script/cancel_stale_jobs.rb
+++ b/services/api/script/cancel_stale_jobs.rb
@@ -16,20 +16,22 @@ require File.dirname(__FILE__) + '/../config/environment'
 
 class CancelJobs
   include ApplicationHelper
+  include DbCurrentTime
 
   def cancel_stale_jobs
     act_as_system_user do
       Job.running.each do |jobrecord|
         f = Log.where("object_uuid=?", jobrecord.uuid).limit(1).order("created_at desc").first
         if f
-          age = (Time.now - f.created_at)
+          current_time = db_current_time
+          age = (current_time - f.created_at)
           if age > 300
             $stderr.puts "dispatch: failing orphan job #{jobrecord.uuid}, last log is #{age} seconds old"
             # job is marked running, but not known to crunch-dispatcher, and
             # hasn't produced any log entries for 5 minutes, so mark it as failed.
             jobrecord.running = false
-            jobrecord.cancelled_at ||= Time.now
-            jobrecord.finished_at ||= Time.now
+            jobrecord.cancelled_at ||= current_time
+            jobrecord.finished_at ||= current_time
             if jobrecord.success.nil?
               jobrecord.success = false
             end
diff --git a/services/api/script/crunch-dispatch.rb b/services/api/script/crunch-dispatch.rb
index ab4f70e..6faf931 100755
--- a/services/api/script/crunch-dispatch.rb
+++ b/services/api/script/crunch-dispatch.rb
@@ -52,6 +52,7 @@ end
 
 class Dispatcher
   include ApplicationHelper
+  include DbCurrentTime
 
   def initialize
     @crunch_job_bin = (ENV['CRUNCH_JOB_BIN'] || `which arv-crunch-job`.strip)
@@ -216,7 +217,7 @@ class Dispatcher
     nodelist = nodes_available_for_job_now(job)
     if nodelist.nil? and not did_recently(:wait_for_available_nodes, 3600)
       $stderr.puts "dispatch: waiting for nodes for #{job.uuid}"
-      @node_wait_deadline = Time.now + 5.minutes
+      @node_wait_deadline = db_current_time + 5.minutes
     end
     nodelist
   end
@@ -260,7 +261,7 @@ class Dispatcher
       # We already made a token for this job, but we need a new one
       # because modified_by_user_uuid has changed (the job will run
       # as a different user).
-      @authorizations[job.uuid].update_attributes expires_at: Time.now
+      @authorizations[job.uuid].update_attributes expires_at: db_current_time
       @authorizations[job.uuid] = nil
     end
     if not @authorizations[job.uuid]
@@ -356,7 +357,7 @@ class Dispatcher
       when :slurm_immediate
         nodelist = nodes_available_for_job(job)
         if nodelist.nil?
-          if Time.now < @node_wait_deadline
+          if db_current_time < @node_wait_deadline
             break
           else
             next
@@ -426,7 +427,7 @@ class Dispatcher
         bytes_logged: 0,
         events_logged: 0,
         log_throttle_is_open: true,
-        log_throttle_reset_time: Time.now + Rails.configuration.crunch_log_throttle_period,
+        log_throttle_reset_time: db_current_time + Rails.configuration.crunch_log_throttle_period,
         log_throttle_bytes_so_far: 0,
         log_throttle_lines_so_far: 0,
         log_throttle_bytes_skipped: 0,
@@ -450,18 +451,18 @@ class Dispatcher
       if (running_job[:bytes_logged] >
           Rails.configuration.crunch_limit_log_bytes_per_job)
         message = "Exceeded log limit #{Rails.configuration.crunch_limit_log_bytes_per_job} bytes (crunch_limit_log_bytes_per_job). Log will be truncated."
-        running_job[:log_throttle_reset_time] = Time.now + 100.years
+        running_job[:log_throttle_reset_time] = db_current_time + 100.years
         running_job[:log_throttle_is_open] = false
 
       elsif (running_job[:log_throttle_bytes_so_far] >
              Rails.configuration.crunch_log_throttle_bytes)
-        remaining_time = running_job[:log_throttle_reset_time] - Time.now
+        remaining_time = running_job[:log_throttle_reset_time] - db_current_time
         message = "Exceeded rate #{Rails.configuration.crunch_log_throttle_bytes} bytes per #{Rails.configuration.crunch_log_throttle_period} seconds (crunch_log_throttle_bytes). Logging will be silenced for the next #{remaining_time.round} seconds.\n"
         running_job[:log_throttle_is_open] = false
 
       elsif (running_job[:log_throttle_lines_so_far] >
              Rails.configuration.crunch_log_throttle_lines)
-        remaining_time = running_job[:log_throttle_reset_time] - Time.now
+        remaining_time = running_job[:log_throttle_reset_time] - db_current_time
         message = "Exceeded rate #{Rails.configuration.crunch_log_throttle_lines} lines per #{Rails.configuration.crunch_log_throttle_period} seconds (crunch_log_throttle_lines), logging will be silenced for the next #{remaining_time.round} seconds.\n"
         running_job[:log_throttle_is_open] = false
       end
@@ -486,7 +487,7 @@ class Dispatcher
     @running.each do |job_uuid, j|
       job = j[:job]
 
-      now = Time.now
+      now = db_current_time
       if now > j[:log_throttle_reset_time]
         # It has been more than throttle_period seconds since the last
         # checkpoint so reset the throttle
@@ -663,7 +664,7 @@ class Dispatcher
     # Invalidate the per-job auth token, unless the job is still queued and we
     # might want to try it again.
     if jobrecord.state != "Queued"
-      j_done[:job_auth].update_attributes expires_at: Time.now
+      j_done[:job_auth].update_attributes expires_at: db_current_time
     end
 
     @running.delete job_done.uuid
@@ -680,7 +681,7 @@ class Dispatcher
     end
 
     expire_tokens.each do |k, v|
-      v.update_attributes expires_at: Time.now
+      v.update_attributes expires_at: db_current_time
       @pipe_auth_tokens.delete k
     end
   end
@@ -721,8 +722,9 @@ class Dispatcher
   protected
 
   def did_recently(thing, min_interval)
-    if !@did_recently[thing] or @did_recently[thing] < Time.now - min_interval
-      @did_recently[thing] = Time.now
+    current_time = db_current_time
+    if !@did_recently[thing] or @did_recently[thing] < current_time - min_interval
+      @did_recently[thing] = current_time
       false
     else
       true
@@ -737,7 +739,7 @@ class Dispatcher
     # it has been at least crunch_log_seconds_between_events seconds since
     # the last flush.
     if running_job[:stderr_buf_to_flush].size > Rails.configuration.crunch_log_bytes_per_event or
-        (Time.now - running_job[:stderr_flushed_at]) >= Rails.configuration.crunch_log_seconds_between_events
+        (db_current_time - running_job[:stderr_flushed_at]) >= Rails.configuration.crunch_log_seconds_between_events
       begin
         log = Log.new(object_uuid: running_job[:job].uuid,
                       event_type: 'stderr',
@@ -750,7 +752,7 @@ class Dispatcher
         $stderr.puts exception.backtrace
       end
       running_job[:stderr_buf_to_flush] = ''
-      running_job[:stderr_flushed_at] = Time.now
+      running_job[:stderr_flushed_at] = db_current_time
     end
   end
 end
diff --git a/services/api/script/get_anonymous_user_token.rb b/services/api/script/get_anonymous_user_token.rb
index 6964af0..141f746 100755
--- a/services/api/script/get_anonymous_user_token.rb
+++ b/services/api/script/get_anonymous_user_token.rb
@@ -21,13 +21,15 @@ get_existing = opts[:get]
 require File.dirname(__FILE__) + '/../config/environment'
 
 include ApplicationHelper
+include DbCurrentTime
+
 act_as_system_user
 
 def create_api_client_auth
   api_client_auth = ApiClientAuthorization.
     new(user: anonymous_user,
         api_client_id: 0,
-        expires_at: Time.now + 100.years,
+        expires_at: db_current_time + 100.years,
         scopes: ['GET /'])
   api_client_auth.save!
   api_client_auth.reload
@@ -36,7 +38,7 @@ end
 if get_existing
   api_client_auth = ApiClientAuthorization.
     where('user_id=?', anonymous_user.id.to_i).
-    where('expires_at>?', Time.now).
+    where('expires_at>?', db_current_time).
     select { |auth| auth.scopes == ['GET /'] }.
     first
 end
diff --git a/services/api/test/unit/log_test.rb b/services/api/test/unit/log_test.rb
index d6b76fc..ec0dc60 100644
--- a/services/api/test/unit/log_test.rb
+++ b/services/api/test/unit/log_test.rb
@@ -43,7 +43,7 @@ class LogTest < ActiveSupport::TestCase
     assert_equal(event_type.to_s, log.event_type, "log event type mismatch")
     time_method, old_props_test, new_props_test = EVENT_TEST_METHODS[event_type]
     if time_method.nil? or (timestamp = thing.send(time_method)).nil?
-      assert(log.event_at >= @start_time, "log timestamp too old")
+      assert(log.event_at.utc.to_i >= @start_time.utc.to_i, "log timestamp too old")
     else
       assert_in_delta(timestamp, log.event_at, 1, "log timestamp mismatch")
     end

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list