kennel 1.64.0 → 1.66.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/kennel/api.rb +3 -3
- data/lib/kennel/github_reporter.rb +5 -5
- data/lib/kennel/models/dashboard.rb +0 -8
- data/lib/kennel/models/monitor.rb +3 -2
- data/lib/kennel/models/record.rb +4 -1
- data/lib/kennel/settings_as_methods.rb +1 -2
- data/lib/kennel/syncer.rb +3 -0
- data/lib/kennel/tasks.rb +2 -2
- data/lib/kennel/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 65bf9625be169156f491cb4e987dba3cd1ffa7c4ed4c9875e8a91c6e4ac87c7d
|
4
|
+
data.tar.gz: 3d95cd55b82d4b34c52239509ccd6c0ed57f0147d5494df60b3756df4ad07569
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0c6b78a86ddbf6f9c4d320545f779566270e5f878081c77a5de842e0f10a9821fdf415b6b959c1bef849f27e7fe47901cecac096f972284357b3e5ae49d36b30
|
7
|
+
data.tar.gz: c79b6fbf9adda3958c9d5626e8c7073bcfb0e8b4c3f2d2a29c6931a4d21f205fd4a8609be9236afda97cfe9c5fa0fe4c22b82acbbbf35cf69a3fa294ada59662
|
data/lib/kennel/api.rb
CHANGED
@@ -43,12 +43,12 @@ module Kennel
|
|
43
43
|
end
|
44
44
|
|
45
45
|
def delete(api_resource, id)
|
46
|
-
request :delete, "/api/v1/#{api_resource}/#{id}"
|
46
|
+
request :delete, "/api/v1/#{api_resource}/#{id}", ignore_404: true
|
47
47
|
end
|
48
48
|
|
49
49
|
private
|
50
50
|
|
51
|
-
def request(method, path, body: nil, params: {})
|
51
|
+
def request(method, path, body: nil, params: {}, ignore_404: false)
|
52
52
|
params = params.merge(application_key: @app_key, api_key: @api_key)
|
53
53
|
query = Faraday::FlatParamsEncoder.encode(params)
|
54
54
|
response = nil
|
@@ -66,7 +66,7 @@ module Kennel
|
|
66
66
|
Kennel.err.puts "Retrying on server error #{response.status} for #{path}"
|
67
67
|
end
|
68
68
|
|
69
|
-
|
69
|
+
if !response.success? && (response.status != 404 || !ignore_404)
|
70
70
|
message = +"Error #{response.status} during #{method.upcase} #{path}\n"
|
71
71
|
message << "request:\n#{JSON.pretty_generate(body)}\nresponse:\n" if body
|
72
72
|
message << response.body
|
@@ -7,13 +7,13 @@ module Kennel
|
|
7
7
|
class << self
|
8
8
|
def report(token, &block)
|
9
9
|
return yield unless token
|
10
|
-
new(token).report(&block)
|
10
|
+
new(token, Utils.capture_sh("git rev-parse HEAD").strip).report(&block)
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
14
|
-
def initialize(token)
|
14
|
+
def initialize(token, git_sha)
|
15
15
|
@token = token
|
16
|
-
@git_sha =
|
16
|
+
@git_sha = git_sha
|
17
17
|
origin = ENV["PROJECT_REPOSITORY"] || Utils.capture_sh("git remote -v").split("\n").first
|
18
18
|
@repo_part = origin[%r{github\.com[:/](.+?)(\.git|$)}, 1] || raise("no origin found")
|
19
19
|
end
|
@@ -27,8 +27,6 @@ module Kennel
|
|
27
27
|
comment "```\n#{output || "Error"}\n```"
|
28
28
|
end
|
29
29
|
|
30
|
-
private
|
31
|
-
|
32
30
|
# https://developer.github.com/v3/repos/comments/#create-a-commit-comment
|
33
31
|
def comment(body)
|
34
32
|
# truncate to maximum allowed comment size for github to avoid 422
|
@@ -39,6 +37,8 @@ module Kennel
|
|
39
37
|
post "commits/#{@git_sha}/comments", body: body
|
40
38
|
end
|
41
39
|
|
40
|
+
private
|
41
|
+
|
42
42
|
def post(path, data)
|
43
43
|
url = "https://api.github.com/repos/#{@repo_part}/#{path}"
|
44
44
|
response = Faraday.post(url, data.to_json, authorization: "token #{@token}")
|
@@ -34,14 +34,6 @@ module Kennel
|
|
34
34
|
super
|
35
35
|
|
36
36
|
widgets_pairs(expected, actual).each do |pair|
|
37
|
-
# datadog always adds 2 to slo widget height
|
38
|
-
# need to check fir layout since some monitors have height/width in their definition
|
39
|
-
pair[1].each do |widget|
|
40
|
-
if widget.dig(:definition, :type) == "slo" && widget.dig(:layout, :height)
|
41
|
-
widget[:layout][:height] -= 2
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
37
|
# conditional_formats ordering is randomly changed by datadog, compare a stable ordering
|
46
38
|
pair.each do |widgets|
|
47
39
|
widgets.each do |widget|
|
@@ -5,7 +5,8 @@ module Kennel
|
|
5
5
|
include OptionalValidations
|
6
6
|
|
7
7
|
RENOTIFY_INTERVALS = [0, 10, 20, 30, 40, 50, 60, 90, 120, 180, 240, 300, 360, 720, 1440].freeze # minutes
|
8
|
-
|
8
|
+
# 2d and 1w are valid timeframes for anomaly monitors
|
9
|
+
QUERY_INTERVALS = ["1m", "5m", "10m", "15m", "30m", "1h", "2h", "4h", "1d", "2d", "1w"].freeze
|
9
10
|
OPTIONAL_SERVICE_CHECK_THRESHOLDS = [:ok, :warning].freeze
|
10
11
|
READONLY_ATTRIBUTES = superclass::READONLY_ATTRIBUTES + [
|
11
12
|
:multi, :matching_downtimes, :overall_state_modified, :overall_state, :restricted_roles
|
@@ -132,7 +133,7 @@ module Kennel
|
|
132
133
|
|
133
134
|
case actual[:type]
|
134
135
|
when "event alert"
|
135
|
-
# setting
|
136
|
+
# setting nothing results in thresholds not getting returned from the api
|
136
137
|
options[:thresholds] ||= { critical: 0 }
|
137
138
|
|
138
139
|
when "service check"
|
data/lib/kennel/models/record.rb
CHANGED
@@ -42,7 +42,10 @@ module Kennel
|
|
42
42
|
|
43
43
|
self.class.send(:normalize, expected, actual)
|
44
44
|
|
45
|
-
|
45
|
+
# strict: ignore Integer vs Float
|
46
|
+
# similarity: show diff when not 100% similar
|
47
|
+
# use_lcs: saner output
|
48
|
+
Hashdiff.diff(actual, expected, use_lcs: false, strict: false, similarity: 1)
|
46
49
|
end
|
47
50
|
|
48
51
|
def tracking_id
|
@@ -25,8 +25,7 @@ module Kennel
|
|
25
25
|
names.each do |name|
|
26
26
|
next if method_defined?(name)
|
27
27
|
define_method name do
|
28
|
-
|
29
|
-
raise_with_location ArgumentError, message
|
28
|
+
raise_with_location ArgumentError, "'#{name}' on #{self.class} was not set or passed as option"
|
30
29
|
end
|
31
30
|
end
|
32
31
|
end
|
data/lib/kennel/syncer.rb
CHANGED
@@ -3,6 +3,7 @@ module Kennel
|
|
3
3
|
class Syncer
|
4
4
|
CACHE_FILE = "tmp/cache/details" # keep in sync with .travis.yml caching
|
5
5
|
TRACKING_FIELDS = [:message, :description].freeze
|
6
|
+
DELETE_ORDER = ["dashboard", "slo", "monitor"].freeze # dashboards references monitors + slos, slos reference monitors
|
6
7
|
|
7
8
|
def initialize(api, expected, project: nil)
|
8
9
|
@api = api
|
@@ -98,6 +99,8 @@ module Kennel
|
|
98
99
|
ensure_all_ids_found
|
99
100
|
@create = @expected.map { |e| [nil, e] }
|
100
101
|
end
|
102
|
+
|
103
|
+
@delete.sort_by! { |_, _, a| DELETE_ORDER.index a.fetch(:api_resource) }
|
101
104
|
end
|
102
105
|
|
103
106
|
# Make diff work even though we cannot mass-fetch definitions
|
data/lib/kennel/tasks.rb
CHANGED
@@ -111,9 +111,9 @@ namespace :kennel do
|
|
111
111
|
end
|
112
112
|
end
|
113
113
|
|
114
|
-
desc "Convert existing resources to copy-pastable definitions to import existing resources RESOURCE=
|
114
|
+
desc "Convert existing resources to copy-pastable definitions to import existing resources RESOURCE=[dashboard,monitor,slo] ID=1234"
|
115
115
|
task import: :environment do
|
116
|
-
resource = ENV["RESOURCE"] || Kennel::Tasks.abort("Call with RESOURCE=
|
116
|
+
resource = ENV["RESOURCE"] || Kennel::Tasks.abort("Call with RESOURCE=dashboard or monitor or slo")
|
117
117
|
id = ENV["ID"] || Kennel::Tasks.abort("Call with ID=1234")
|
118
118
|
id = Integer(id) if id =~ /^\d+$/ # dashboards can have alphanumeric ids
|
119
119
|
puts Kennel::Importer.new(Kennel.send(:api)).import(resource, id)
|
data/lib/kennel/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kennel
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.66.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Grosser
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-03-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 0
|
33
|
+
version: '1.0'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 0
|
40
|
+
version: '1.0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: net-http-persistent-retry
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|