Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't resolve ID of not-yet-adopted item #267

Open
zdrve opened this issue Feb 22, 2023 · 1 comment
Open

Can't resolve ID of not-yet-adopted item #267

zdrve opened this issue Feb 22, 2023 · 1 comment

Comments

@zdrve
Copy link
Collaborator

zdrve commented Feb 22, 2023

Example:

  • we have an SLO, which exists in datadog, but not in kennel
  • we prepare a PR to import that SLO into kennel
  • rake kennel:update_datadog PROJECT=my_project works, but doesn't add the tracking_id

This is all fine so far. But now comes the problem:

  • on the same PR, we add a widget to some dashboard, with slo_id: "my_project:my_new_slo"
  • rake kennel:update_datadog PROJECT=my_project fails, saying it can't resolve my_project:my_new_slo.

Very hacky fix:

diff --git a/lib/kennel/syncer.rb b/lib/kennel/syncer.rb
index fec037e..82eb87c 100644
--- a/lib/kennel/syncer.rb
+++ b/lib/kennel/syncer.rb
@@ -105,7 +105,15 @@ module Kennel
           # Refuse to "adopt" existing items into kennel while running with a filter (i.e. on a branch).
           # Without this, we'd adopt an item, then the next CI run would delete it
           # (instead of "unadopting" it).
-          e.add_tracking_id unless filter.filtering? && a.fetch(:tracking_id).nil?
+          if filter.filtering? && a.fetch(:tracking_id).nil?
+            # Eww!
+            a[:tracking_id] = e.tracking_id
+            resolver.add_actual([a])
+            a[:tracking_id] = nil
+          else
+            e.add_tracking_id
+          end
+
           id = a.fetch(:id)
           diff = e.diff(a)
           a[:id] = id
@zdrve zdrve changed the title Can't resolve ID of not-yet-adopting item Can't resolve ID of not-yet-adopted item Feb 22, 2023
@grosser
Copy link
Owner

grosser commented Feb 23, 2023

yeah good solution for an ugly edge-case :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants