kennel 2.12.1 → 2.13.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 820cb0c4f746cbbafc79598199ba6c4e6d8d762e8505b432af9bf3c27de3ca74
4
- data.tar.gz: d1c54c6ecd55bfd00e432b9258dfb6c6f16fa15c9181f862adca7bd885a0c4c2
3
+ metadata.gz: 4ad7fc83d72816d45830ddf3c46d266d8a6baba0c163d16c85ae69dcdc5058bd
4
+ data.tar.gz: 2ab1212ba1a378cdfe758e0821251661a977adbea8f57f88156e38131d9fac81
5
5
  SHA512:
6
- metadata.gz: e001bd09798e846ddabdd5dae8b47aa9174cdd19be8f4af77b52d2eb877ed2cb6043a2022c229f23e0c232700104c930902ec89ecb2db416e77de2e29074ef0b
7
- data.tar.gz: bd930e26de4108718b8228056b726a5aeb41407ddef31175879b8126b250639e027b2d1e05cbabe47d5e94399aa8a8c609dddc3bb0163eeb920051d436186b1d
6
+ metadata.gz: bf31a0b076d4d961c04bfb670d5969d71419eeb97388bcdfcd9410192efad429cb2b2de04cd02ad1798534abe61f8c9f3c65689a7f34b27d2c6d8b7dee150bcd
7
+ data.tar.gz: cedb8aaa36eaaa1f67cc137419891048d56b1fb1b103a51e8743cf2eecdd10d10d8bdcf609435def8fad3b8d92e8cd3c53a03f7dacd4d6996796e9f79db73b15
data/lib/kennel/api.rb CHANGED
@@ -109,7 +109,9 @@ module Kennel
109
109
 
110
110
  def request(method, path, body: nil, params: {}, ignore_404: false)
111
111
  path = "#{path}?#{Faraday::FlatParamsEncoder.encode(params)}" if params.any?
112
- with_cache ENV["FORCE_GET_CACHE"] && method == :get, path do
112
+ cached = (ENV["FORCE_GET_CACHE"] && method == :get)
113
+
114
+ with_cache cached, path do
113
115
  response = nil
114
116
  tries = 2
115
117
 
@@ -128,7 +130,8 @@ module Kennel
128
130
  redo
129
131
  end
130
132
 
131
- break if i == tries - 1 || method != :get || response.status < 500
133
+ last_try = (i == tries - 1)
134
+ break if last_try || ![:get, :put].include?(method) || response.status < 500
132
135
  Kennel.err.puts "Retrying on server error #{response.status} for #{path}"
133
136
  end
134
137
 
@@ -33,6 +33,7 @@ module Kennel
33
33
  DEFAULT_ESCALATION_MESSAGE = ["", nil].freeze
34
34
  ALLOWED_PRIORITY_CLASSES = [NilClass, Integer].freeze
35
35
  SKIP_NOTIFY_NO_DATA_TYPES = ["event alert", "event-v2 alert", "log alert"].freeze
36
+ ON_MISSING_DATA_UNSUPPORTED_TYPES = ["composite", "datadog-usage alert"].freeze
36
37
  MINUTES_PER_UNIT = {
37
38
  "m" => 1,
38
39
  "h" => 60,
@@ -155,14 +156,19 @@ module Kennel
155
156
  action ||= "default" if type == "event-v2 alert"
156
157
 
157
158
  # TODO: mark setting action && !notify.nil? at all as invalid
158
- if action && timeframe
159
- invalid! :invalid_no_data_config, "set either no_data_timeframe or on_missing_data"
160
- end
161
- if type == "composite" && action
162
- invalid! :invalid_no_data_config, "cannot use on_missing_data with composite monitor"
163
- end
164
- if action == "resolve" && timeout_h.to_i != 0
165
- invalid! :invalid_no_data_config, "timeout_h cannot be set and non-zero when on_missing_data is `resolve`"
159
+ if action
160
+ if ON_MISSING_DATA_UNSUPPORTED_TYPES.include?(type)
161
+ invalid! :invalid_no_data_config, "cannot use on_missing_data with #{type} monitor"
162
+ end
163
+ if timeframe
164
+ invalid! :invalid_no_data_config, "set either no_data_timeframe or on_missing_data"
165
+ end
166
+ if action != "default" && type == "query alert" && query.to_s.include?("default_zero(") # is allowed for log alert for example
167
+ invalid! :invalid_no_data_config, "set on_missing_data to `default` when using default_zero"
168
+ end
169
+ if action == "resolve" && timeout_h.to_i != 0
170
+ invalid! :invalid_no_data_config, "timeout_h cannot be set and non-zero when on_missing_data is `resolve`"
171
+ end
166
172
  end
167
173
 
168
174
  # on_missing_data cannot be used with notify_no_data + no_data_timeframe
@@ -73,7 +73,7 @@ module Kennel
73
73
  end
74
74
 
75
75
  def self.parse_url(url)
76
- url[/[?&]slo_id=([a-z\d]{10,})/, 1] || url[/\/slo\/([a-z\d]{10,})\/edit(\?|$)/, 1]
76
+ url[/[?&]slo_id=([a-z\d]{10,})/, 1] || url[/\/slo\/([a-z\d]{10,})(:?\/edit)?(\?|$)/, 1]
77
77
  end
78
78
 
79
79
  def resolve_linked_tracking_ids!(id_map, **args)
@@ -18,7 +18,7 @@ module Kennel
18
18
  private
19
19
 
20
20
  def loaded_projects
21
- Models::Project.recursive_subclasses
21
+ Models::Project.recursive_subclasses.reject(&:abstract_class?)
22
22
  end
23
23
 
24
24
  # "require" requested .rb files under './projects',
@@ -9,8 +9,16 @@ module Kennel
9
9
  @subclasses ||= []
10
10
  end
11
11
 
12
+ def abstract_class?
13
+ !!@abstract_class
14
+ end
15
+
12
16
  private
13
17
 
18
+ def abstract_class!
19
+ @abstract_class = true # not inherited by children
20
+ end
21
+
14
22
  def inherited(child)
15
23
  super
16
24
  subclasses << child
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module Kennel
3
- VERSION = "2.12.1"
3
+ VERSION = "2.13.0"
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: 2.12.1
4
+ version: 2.13.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Grosser
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-01-12 00:00:00.000000000 Z
11
+ date: 2026-01-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: diff-lcs