kennel 1.108.0 → 1.110.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Readme.md +1 -0
- data/lib/kennel/models/base.rb +12 -5
- data/lib/kennel/models/monitor.rb +8 -0
- data/lib/kennel/syncer.rb +6 -5
- data/lib/kennel/version.rb +1 -1
- data/lib/kennel.rb +9 -7
- data/template/Readme.md +1 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 96f333547d6fe858544175909310a96c5b65507eb8d265285b4ee0b56550ac23
|
4
|
+
data.tar.gz: b4cb7c9a09c432a8faa5ba57746e4f14ee07730de89e3616c88a512db6ab1d5a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dee8590a0796078c82563b38fba653bbf3a3f6596ccc46206665810fe2c19a98de932a310ac4a524dc6ab63f041b5dffe61d0c19d15bd253d09f44a4b8d88e0f
|
7
|
+
data.tar.gz: ccc05391cf707a64ab70c2e8afe9ba26f9c6fab4632a5f9abdae567504930ec91583989f805ec9cd20d1242068097c258123277d85ea0d605c69c415cc4a67e3
|
data/Readme.md
CHANGED
@@ -248,6 +248,7 @@ so they can be created in a single update and can be re-created if any of them i
|
|
248
248
|
- rebase on updated `master` to not undo other changes
|
249
249
|
- figure out project name by converting the class name to snake-case
|
250
250
|
- run `PROJECT=foo bundle exec rake kennel:update_datadog` to test changes for a single project (monitors: remove mentions while debugging to avoid alert spam)
|
251
|
+
- use `PROJECT=foo,bar,...` for multiple projects
|
251
252
|
|
252
253
|
### Reuse
|
253
254
|
Add to `parts/<folder>`.
|
data/lib/kennel/models/base.rb
CHANGED
@@ -10,11 +10,7 @@ module Kennel
|
|
10
10
|
SETTING_OVERRIDABLE_METHODS = [:name, :kennel_id].freeze
|
11
11
|
|
12
12
|
def kennel_id
|
13
|
-
|
14
|
-
if name.start_with?("Kennel::") # core objects would always generate the same id
|
15
|
-
raise_with_location ArgumentError, "Set :kennel_id"
|
16
|
-
end
|
17
|
-
@kennel_id ||= Utils.snake_case name
|
13
|
+
@kennel_id ||= Utils.snake_case kennel_id_base
|
18
14
|
end
|
19
15
|
|
20
16
|
def name
|
@@ -24,6 +20,17 @@ module Kennel
|
|
24
20
|
def to_json # rubocop:disable Lint/ToJSON
|
25
21
|
raise NotImplementedError, "Use as_json"
|
26
22
|
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
# hook to allow overwriting id generation to remove custom module scopes
|
27
|
+
def kennel_id_base
|
28
|
+
name = self.class.name
|
29
|
+
if name.start_with?("Kennel::") # core objects would always generate the same id
|
30
|
+
raise_with_location ArgumentError, "Set :kennel_id"
|
31
|
+
end
|
32
|
+
name
|
33
|
+
end
|
27
34
|
end
|
28
35
|
end
|
29
36
|
end
|
@@ -111,6 +111,14 @@ module Kennel
|
|
111
111
|
# Datadog requires only either new_group_delay or new_host_delay, never both
|
112
112
|
options.delete(options[:new_group_delay] ? :new_host_delay : :new_group_delay)
|
113
113
|
|
114
|
+
# Add in statuses where we would re notify on. Possible values: alert, no data, warn
|
115
|
+
if options[:renotify_interval] != 0
|
116
|
+
statuses = ["alert"]
|
117
|
+
statuses << "no data" if options[:notify_no_data]
|
118
|
+
statuses << "warn" if options.dig(:thresholds, :warning)
|
119
|
+
options[:renotify_statuses] = statuses
|
120
|
+
end
|
121
|
+
|
114
122
|
validate_json(data) if validate
|
115
123
|
|
116
124
|
@as_json = data
|
data/lib/kennel/syncer.rb
CHANGED
@@ -4,9 +4,9 @@ module Kennel
|
|
4
4
|
DELETE_ORDER = ["dashboard", "slo", "monitor", "synthetics/tests"].freeze # dashboards references monitors + slos, slos reference monitors
|
5
5
|
LINE_UP = "\e[1A\033[K" # go up and clear
|
6
6
|
|
7
|
-
def initialize(api, expected,
|
7
|
+
def initialize(api, expected, project_filter: nil)
|
8
8
|
@api = api
|
9
|
-
@project_filter =
|
9
|
+
@project_filter = project_filter
|
10
10
|
@expected = expected
|
11
11
|
calculate_diff
|
12
12
|
validate_plan
|
@@ -252,7 +252,7 @@ module Kennel
|
|
252
252
|
end
|
253
253
|
|
254
254
|
# override resources that exist with their id
|
255
|
-
|
255
|
+
project_prefixes = @project_filter&.map { |p| "#{p}:" }
|
256
256
|
actual.each do |a|
|
257
257
|
# ignore when not managed by kennel
|
258
258
|
next unless tracking_id = a.fetch(:tracking_id)
|
@@ -262,7 +262,7 @@ module Kennel
|
|
262
262
|
api_resource = a.fetch(:klass).api_resource
|
263
263
|
next if
|
264
264
|
!@id_map.get(api_resource, tracking_id) &&
|
265
|
-
(!
|
265
|
+
(!project_prefixes || tracking_id.start_with?(*project_prefixes))
|
266
266
|
|
267
267
|
@id_map.set(api_resource, tracking_id, a.fetch(:id))
|
268
268
|
if a[:klass].api_resource == "synthetics/tests"
|
@@ -277,9 +277,10 @@ module Kennel
|
|
277
277
|
|
278
278
|
def filter_actual_by_project!(actual)
|
279
279
|
return unless @project_filter
|
280
|
+
project_prefixes = @project_filter&.map { |p| "#{p}:" }
|
280
281
|
actual.select! do |a|
|
281
282
|
tracking_id = a.fetch(:tracking_id)
|
282
|
-
!tracking_id || tracking_id.start_with?(
|
283
|
+
!tracking_id || tracking_id.start_with?(*project_prefixes)
|
283
284
|
end
|
284
285
|
end
|
285
286
|
end
|
data/lib/kennel/version.rb
CHANGED
data/lib/kennel.rb
CHANGED
@@ -63,7 +63,7 @@ module Kennel
|
|
63
63
|
|
64
64
|
def store(parts)
|
65
65
|
Progress.progress "Storing" do
|
66
|
-
old = Dir["generated
|
66
|
+
old = Dir["generated/{#{(project_filter || ["**"]).join(",")}}/*"]
|
67
67
|
used = []
|
68
68
|
|
69
69
|
Utils.parallel(parts, max: 2) do |part|
|
@@ -92,7 +92,7 @@ module Kennel
|
|
92
92
|
end
|
93
93
|
|
94
94
|
def syncer
|
95
|
-
@syncer ||= Syncer.new(api, generated,
|
95
|
+
@syncer ||= Syncer.new(api, generated, project_filter: project_filter)
|
96
96
|
end
|
97
97
|
|
98
98
|
def api
|
@@ -104,18 +104,20 @@ module Kennel
|
|
104
104
|
Progress.progress "Generating" do
|
105
105
|
load_all
|
106
106
|
known = []
|
107
|
+
filter = project_filter
|
108
|
+
|
107
109
|
parts = Models::Project.recursive_subclasses.flat_map do |project_class|
|
108
110
|
project = project_class.new
|
109
111
|
kennel_id = project.kennel_id
|
110
|
-
if
|
112
|
+
if filter
|
111
113
|
known << kennel_id
|
112
|
-
next []
|
114
|
+
next [] unless filter.include?(kennel_id)
|
113
115
|
end
|
114
116
|
project.validated_parts
|
115
117
|
end
|
116
118
|
|
117
|
-
if
|
118
|
-
raise "#{
|
119
|
+
if filter && parts.empty?
|
120
|
+
raise "#{filter.join(", ")} does not match any projects, try any of these:\n#{known.uniq.sort.join("\n")}"
|
119
121
|
end
|
120
122
|
|
121
123
|
parts.group_by(&:tracking_id).each do |tracking_id, same|
|
@@ -131,7 +133,7 @@ module Kennel
|
|
131
133
|
end
|
132
134
|
|
133
135
|
def project_filter
|
134
|
-
ENV["PROJECT"]
|
136
|
+
ENV["PROJECT"]&.split(",")
|
135
137
|
end
|
136
138
|
|
137
139
|
def load_all
|
data/template/Readme.md
CHANGED
@@ -230,6 +230,7 @@ so they can be created in a single update and can be re-created if any of them i
|
|
230
230
|
- rebase on updated `master` to not undo other changes
|
231
231
|
- figure out project name by converting the class name to snake-case
|
232
232
|
- run `PROJECT=foo bundle exec rake kennel:update_datadog` to test changes for a single project (monitors: remove mentions while debugging to avoid alert spam)
|
233
|
+
- use `PROJECT=foo,bar,...` for multiple projects
|
233
234
|
|
234
235
|
### Reuse
|
235
236
|
Add to `parts/<folder>`.
|
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.110.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: 2022-04-
|
11
|
+
date: 2022-04-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|