hotdog 0.18.2 → 0.18.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 41826771eee978718b934da22818cc2da5d0e3c6
4
- data.tar.gz: abc210a02a3a1b571ec5013bbb4b62791221cecd
3
+ metadata.gz: e1028a5f20aa3186fb10d14ea6442de32afd7f23
4
+ data.tar.gz: 5737e3411463b9be5d49646995b269d6f0c68d94
5
5
  SHA512:
6
- metadata.gz: a150d41cbbe3090ef6c8fc53fb03a183e9ddfdcf25ddc2056096adf3718b8830b8e4be3b25faeae658cdcfbd6d324f9b00c964c1ecf96d7dd02dfa19a734c9bf
7
- data.tar.gz: b555bb6321256c117b764c2f65bcbc635dce11f6510554484e1ad3316098bdaa0d3089a345b29d31989332956570e41ed8967bd416c437b5d51399233e78f44d
6
+ metadata.gz: a8ff94f92bfd4bfb3816a24715ece125ba0d61a162ae35e436ed9ad793e8bd52387daa45d2fed3dd7fd1dabd420c10f8671d841aafbbea279dc7ad7d9d3faf3f
7
+ data.tar.gz: e09c12120df40d689603e7b087e5c38686080347da012ae91d406eaf9b9be8d060101925794ebeaea04db65aaeef1dba279a0045a67cb5fb305b07fd226b1d98
@@ -219,6 +219,9 @@ module Hotdog
219
219
  persistent_db = SQLite3::Database.new(persistent)
220
220
  persistent_db.execute("SELECT hosts_tags.host_id FROM hosts_tags INNER JOIN hosts ON hosts_tags.host_id = hosts.id INNER JOIN tags ON hosts_tags.tag_id = tags.id LIMIT 1;")
221
221
  @db = persistent_db
222
+ rescue SQLite3::BusyException
223
+ sleep(rand) # FIXME: configurable retry interval
224
+ retry
222
225
  rescue SQLite3::SQLException
223
226
  if options[:offline]
224
227
  raise(RuntimeError.new("no database available on offline mode"))
@@ -391,7 +394,7 @@ module Hotdog
391
394
  end
392
395
 
393
396
  def with_retry(options={}, &block)
394
- (options[:retry] || 1).times do |i|
397
+ (options[:retry] || 3).times do |i|
395
398
  begin
396
399
  return yield
397
400
  rescue => error
@@ -31,11 +31,6 @@ module Hotdog
31
31
  arg
32
32
  end
33
33
  }
34
- scopes.each do |scope|
35
- with_retry(options) do
36
- schedule_downtime(scope, options)
37
- end
38
- end
39
34
  hosts = scopes.select { |scope| scope.start_with?("host:") }.map { |scope|
40
35
  scope.slice("host:".length, scope.length)
41
36
  }
@@ -51,6 +46,11 @@ module Hotdog
51
46
  end
52
47
  end
53
48
  end
49
+ scopes.each do |scope|
50
+ with_retry(options) do
51
+ schedule_downtime(scope, options)
52
+ end
53
+ end
54
54
  end
55
55
 
56
56
  private
@@ -27,16 +27,6 @@ module Hotdog
27
27
  hosts = args.map { |arg|
28
28
  arg.sub(/\Ahost:/, "")
29
29
  }
30
- hosts.each do |host|
31
- if options[:tags].empty?
32
- # nop
33
- else
34
- # add all as user tags
35
- with_retry(options) do
36
- add_tags(host, options[:tags], source=options[:tag_source])
37
- end
38
- end
39
- end
40
30
  if open_db
41
31
  with_retry do
42
32
  @db.transaction do
@@ -47,6 +37,16 @@ module Hotdog
47
37
  end
48
38
  end
49
39
  end
40
+ hosts.each do |host|
41
+ if options[:tags].empty?
42
+ # nop
43
+ else
44
+ # add all as user tags
45
+ with_retry(options) do
46
+ add_tags(host, options[:tags], source=options[:tag_source])
47
+ end
48
+ end
49
+ end
50
50
  end
51
51
 
52
52
  private
@@ -28,6 +28,21 @@ module Hotdog
28
28
  arg.sub(/\Ahost:/, "")
29
29
  }
30
30
 
31
+ if options[:tags].empty?
32
+ # refresh all persistent.db since there is no way to identify user tags
33
+ remove_db
34
+ else
35
+ if open_db
36
+ with_retry do
37
+ @db.transaction do
38
+ options[:tags].each do |tag|
39
+ disassociate_tag_hosts(@db, tag, hosts)
40
+ end
41
+ end
42
+ end
43
+ end
44
+ end
45
+
31
46
  hosts.each do |host|
32
47
  if options[:tags].empty?
33
48
  # delete all user tags
@@ -47,21 +62,6 @@ module Hotdog
47
62
  end
48
63
  end
49
64
  end
50
-
51
- if options[:tags].empty?
52
- # refresh all persistent.db since there is no way to identify user tags
53
- remove_db
54
- else
55
- if open_db
56
- with_retry do
57
- @db.transaction do
58
- options[:tags].each do |tag|
59
- disassociate_tag_hosts(@db, tag, hosts)
60
- end
61
- end
62
- end
63
- end
64
- end
65
65
  end
66
66
 
67
67
  private
@@ -37,6 +37,7 @@ module Hotdog
37
37
  cancel_downtime(downtime["id"], options)
38
38
  end
39
39
  end
40
+
40
41
  hosts = scopes.select { |scope| scope.start_with?("host:") }.map { |scope|
41
42
  scope.slice("host:".length, scope.length)
42
43
  }
@@ -1,3 +1,3 @@
1
1
  module Hotdog
2
- VERSION = "0.18.2"
2
+ VERSION = "0.18.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hotdog
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.18.2
4
+ version: 0.18.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yamashita Yuu