Fix sync cli for metric SLOs #431
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Fixes an issue where syncing metric-based SLOs would fail due to conflicting fields being sent to the Datadog API.
Problem
The Datadog SLO GET endpoint returns both sli_specification and query fields for metric SLOs. However, the CREATE and UPDATE endpoints only accept one of these fields—not both. When the sync CLI attempted to create or update a metric SLO, the API would reject the request because both fields were present.
Solution
Exclude
queryfrom both thediffand outgoing payloads to the API via theexcluded_attributesparam to avoid conflict errors.Changes
Aforementioned
excluded_attributesupdate.Consequences
Users will need the latest version of the datadog-sync-cli tool once the FF is enabled.
Conversely, if the FF is off and the tool is up to date with these changes, then the tool breaks because query will be excluded from payloads and it is a required field.
I tested this by using the datadog-sync-cli locally:
Adding query to excluded attrbitues and running against API w/ FF OFF
Running with FF on in the source org but not the destination org:
Running again with FF on, but with no change to underlying SLO
Running again with FF on, but with changes to underlying SLO sli_specification: