kennel 1.64.0 → 1.66.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
  SHA256:
3
- metadata.gz: 371bcfe0f309a53af116ec4b8073ef337c0addf6d949d392486cc7c4165902c5
4
- data.tar.gz: 77ddcf3210c004af815a96748c11bb25cbbd7ad2805c0c2dccef2d479f8480eb
3
+ metadata.gz: 65bf9625be169156f491cb4e987dba3cd1ffa7c4ed4c9875e8a91c6e4ac87c7d
4
+ data.tar.gz: 3d95cd55b82d4b34c52239509ccd6c0ed57f0147d5494df60b3756df4ad07569
5
5
  SHA512:
6
- metadata.gz: 2d38d04745a2ff9dd146d9d545131be7e1e94f33d6ce4f0ddc2ac80e3880e6546eb3094e767774fa5f85366c92ad56344ee3223a1c5dea3b363920ec2aa920dd
7
- data.tar.gz: 823303375a6d47ec86d0c88e58bffa3afbb6ccfc3380fb03d0d711b8a7f891be107d6d10e244deba69aa5731c1c803b9cef675bd7fca0896de6048bff73808c2
6
+ metadata.gz: 0c6b78a86ddbf6f9c4d320545f779566270e5f878081c77a5de842e0f10a9821fdf415b6b959c1bef849f27e7fe47901cecac096f972284357b3e5ae49d36b30
7
+ data.tar.gz: c79b6fbf9adda3958c9d5626e8c7073bcfb0e8b4c3f2d2a29c6931a4d21f205fd4a8609be9236afda97cfe9c5fa0fe4c22b82acbbbf35cf69a3fa294ada59662
@@ -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
- unless response.success?
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 = Utils.capture_sh("git rev-parse HEAD").strip
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
- QUERY_INTERVALS = ["1m", "5m", "10m", "15m", "30m", "1h", "2h", "4h", "1d"].freeze
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 0 results in thresholds not getting returned from the api
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"
@@ -42,7 +42,10 @@ module Kennel
42
42
 
43
43
  self.class.send(:normalize, expected, actual)
44
44
 
45
- HashDiff.diff(actual, expected, use_lcs: false)
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
- message = "Trying to call #{name} for #{self.class} but it was never set or passed as option"
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
@@ -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
@@ -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=dash ID=1234"
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=dash") # TODO: add others
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)
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module Kennel
3
- VERSION = "1.64.0"
3
+ VERSION = "1.66.3"
4
4
  end
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.64.0
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-02-19 00:00:00.000000000 Z
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.3.9
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.3.9
40
+ version: '1.0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: net-http-persistent-retry
43
43
  requirement: !ruby/object:Gem::Requirement