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

Fix spurious diff with hidden_queries #222

Merged
merged 5 commits into from
May 3, 2024

Conversation

MisterSquishy
Copy link
Contributor

@MisterSquishy MisterSquishy commented May 3, 2024

Fixes a spurious diff issue, in which alerts with hidden_queries set will continuously try (and fail) to "update". This is caused by a failure to store the hidden_queries map in state, causing an unresolvable diff between the HCL and the state file.

I fixed this by stealing the hidden_queries setting code from lightstep_dashboard and calling it from lightstep_alert, and added a unit test to ensure the plan is clean for these types of alerts now

@MisterSquishy MisterSquishy requested a review from mattcarmody May 3, 2024 14:28
}
hq := make(map[string]interface{}, len(query.HiddenQueries))
for k, v := range query.HiddenQueries {
// Don't include the top-level query in the TF resource data
Copy link
Contributor Author

@MisterSquishy MisterSquishy May 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note that this leads to another unresolvable diff scenario, specifically when the user specifies a hidden_queries with the top-level query name included (because the HCL will keep trying to add it, and this code will keep omitting it). i am choosing not to fix this in the provider, because i dont know how i think the API should be updated to better handle this case -- in particular, we should omit the top-level query name from hidden_queries in the API, and use hidden for that purpose (as the contract has been defined here)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this approach

@MisterSquishy MisterSquishy requested a review from danhurwit May 3, 2024 16:40
}
hq := make(map[string]interface{}, len(query.HiddenQueries))
for k, v := range query.HiddenQueries {
// Don't include the top-level query in the TF resource data
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this approach

@MisterSquishy MisterSquishy merged commit 6c548e1 into main May 3, 2024
6 checks passed
@MisterSquishy MisterSquishy deleted the fix_spurious_lightstep_alert_diff branch May 3, 2024 19:44
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

Successfully merging this pull request may close these issues.

2 participants