[ARVADOS] updated: 1.3.0-1024-g6ae78c122
Git user
git at public.curoverse.com
Thu Jun 6 20:04:09 UTC 2019
Summary of changes:
services/api/lib/config_loader.rb | 33 +++++++++++++++++++++++++++++----
1 file changed, 29 insertions(+), 4 deletions(-)
via 6ae78c12231f2487463722a193b43a716da8cec8 (commit)
via 24ce515666eb7b87694cd87f58b4291de080b7de (commit)
from 69b4828b22fbfdf26d1355e99bad5cd1858d64da (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 6ae78c12231f2487463722a193b43a716da8cec8
Author: Tom Clegg <tclegg at veritasgenetics.com>
Date: Thu Jun 6 16:03:10 2019 -0400
15000: Accept byte size suffixes (KB, KiB, ...) for numeric configs.
Arvados-DCO-1.1-Signed-off-by: Tom Clegg <tclegg at veritasgenetics.com>
diff --git a/services/api/lib/config_loader.rb b/services/api/lib/config_loader.rb
index 6aeb6fce2..522aa73b0 100644
--- a/services/api/lib/config_loader.rb
+++ b/services/api/lib/config_loader.rb
@@ -134,6 +134,31 @@ class ConfigLoader
cfg[k] = URI(cfg[k])
end
+ if cfgtype == Integer && cfg[k].is_a?(String)
+ v = cfg[k].sub(/B\s*$/, '')
+ if mt = /(-?\d*\.?\d+)\s*([KMGTPE]i?)$/.match(v)
+ if mt[1].index('.')
+ v = mt[1].to_f
+ else
+ v = mt[1].to_i
+ end
+ cfg[k] = v * {
+ 'K' => 1000,
+ 'Ki' => 1 << 10,
+ 'M' => 1000000,
+ 'Mi' => 1 << 20,
+ "G" => 1000000000,
+ "Gi" => 1 << 30,
+ "T" => 1000000000000,
+ "Ti" => 1 << 40,
+ "P" => 1000000000000000,
+ "Pi" => 1 << 50,
+ "E" => 1000000000000000000,
+ "Ei" => 1 << 60,
+ }[mt[2]]
+ end
+ end
+
if !cfg[k].is_a? cfgtype
raise "#{cfgkey} expected #{cfgtype} but was #{cfg[k].class}"
end
commit 24ce515666eb7b87694cd87f58b4291de080b7de
Author: Tom Clegg <tclegg at veritasgenetics.com>
Date: Thu Jun 6 16:02:35 2019 -0400
15000: Accept negative durations in config, fix crashing error log.
Arvados-DCO-1.1-Signed-off-by: Tom Clegg <tclegg at veritasgenetics.com>
diff --git a/services/api/lib/config_loader.rb b/services/api/lib/config_loader.rb
index 90b6d9ddc..6aeb6fce2 100644
--- a/services/api/lib/config_loader.rb
+++ b/services/api/lib/config_loader.rb
@@ -126,7 +126,7 @@ class ConfigLoader
if cfg[k].is_a? Integer
cfg[k] = cfg[k].seconds
elsif cfg[k].is_a? String
- cfg[k] = ConfigLoader.parse_duration cfg[k]
+ cfg[k] = ConfigLoader.parse_duration(cfg[k], cfgkey: cfgkey)
end
end
@@ -155,13 +155,13 @@ class ConfigLoader
end
end
- def self.parse_duration durstr
- duration_re = /(\d+(\.\d+)?)(s|m|h)/
+ def self.parse_duration durstr, cfgkey:
+ duration_re = /-?(\d+(\.\d+)?)(s|m|h)/
dursec = 0
while durstr != ""
mt = duration_re.match durstr
if !mt
- raise "#{cfgkey} not a valid duration: '#{cfg[k]}', accepted suffixes are s, m, h"
+ raise "#{cfgkey} not a valid duration: '#{durstr}', accepted suffixes are s, m, h"
end
multiplier = {s: 1, m: 60, h: 3600}
dursec += (Float(mt[1]) * multiplier[mt[3].to_sym])
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list