-
Notifications
You must be signed in to change notification settings - Fork 11.8k
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
Cloudwatch: Fix Unexpected error #74420
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sarahzinger
commented
Sep 5, 2023
sarahzinger
commented
Sep 5, 2023
fridgepoet
reviewed
Sep 6, 2023
fridgepoet
reviewed
Sep 19, 2023
Just some thoughts and totally defer to your judgement: |
fridgepoet
reviewed
Sep 19, 2023
fridgepoet
reviewed
Sep 19, 2023
Co-authored-by: Shirley <4163034+fridgepoet@users.noreply.github.com>
fridgepoet
reviewed
Sep 20, 2023
fridgepoet
approved these changes
Sep 21, 2023
rwwiv
pushed a commit
that referenced
this pull request
Oct 2, 2023
Fix unexpected error when creating a new cloudwatch datasource. Involves a fair amount of refactoring, so if this causes unexpected issues related to region fetching we can turn this off with the cloudwatchNewRegionsHandler feature toggle, although we do not predict it will so we are enabling it to default to true and hope to remove it shortly.
This was referenced Oct 16, 2023
3 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
add to changelog
area/backend
area/frontend
datasource/CloudWatch
no-backport
Skip backport of PR
type/docs
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.
What is this feature?
Fixes issue where an unparsed error is thrown in Cloudwatch when a datasource is created:
![Screenshot 2023-09-05 at 4 15 36 PM](https://private-user-images.githubusercontent.com/6620164/265815952-375c3f20-ea9f-4506-8ed7-97ba3f1ee8e5.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjIxODI2MjIsIm5iZiI6MTcyMjE4MjMyMiwicGF0aCI6Ii82NjIwMTY0LzI2NTgxNTk1Mi0zNzVjM2YyMC1lYTlmLTQ1MDYtOGVkNy05N2JhM2YxZWU4ZTUucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI0MDcyOCUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNDA3MjhUMTU1ODQyWiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9ZjE1ZTA1NzJmNGY0NTZhYjQyODgxN2RlMzZlNDYyZGU5MGQ0ZDI0NTkxNzQ1MWE3ZjBjZWQ3ZGNiMjkxNjY0YSZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QmYWN0b3JfaWQ9MCZrZXlfaWQ9MCZyZXBvX2lkPTAifQ.QwQjmrLD5CKBqk-VfL0Egnv0GAQkPJipEO5Q4NH6lho)
In order to address fixing this, I ended up refactoring the /regions endpoint to follow the same architecture we now have in most of cloudwatch resource routes. This helps to ensure we return a well formatted error response like so:
![Screenshot 2023-09-05 at 4 17 43 PM](https://private-user-images.githubusercontent.com/6620164/265816427-86f049f7-569b-4969-b03b-ebab587e21b6.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjIxODI2MjIsIm5iZiI6MTcyMjE4MjMyMiwicGF0aCI6Ii82NjIwMTY0LzI2NTgxNjQyNy04NmYwNDlmNy01NjliLTQ5NjktYjAzYi1lYmFiNTg3ZTIxYjYucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI0MDcyOCUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNDA3MjhUMTU1ODQyWiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9ZTNjOGM1M2MzNDU2ZTYzODVmZTAxNjI0MDcxYTNlZTZlMjE1M2VlYTAwMTYwMTUwNTgyMjI0YTQwMGM0YTllNCZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QmYWN0b3JfaWQ9MCZrZXlfaWQ9MCZyZXBvX2lkPTAifQ.yx9auzi7My7qalZGs7TYL7yr-H3rYvuWsz1c5VqdCKU)
rather than this string which our global error handling does not parse well:
![Screenshot 2023-09-05 at 4 18 01 PM](https://private-user-images.githubusercontent.com/6620164/265816554-2890f764-2b5c-499d-82d9-db3faf92468b.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjIxODI2MjIsIm5iZiI6MTcyMjE4MjMyMiwicGF0aCI6Ii82NjIwMTY0LzI2NTgxNjU1NC0yODkwZjc2NC0yYjVjLTQ5OWQtODJkOS1kYjNmYWY5MjQ2OGIucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI0MDcyOCUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNDA3MjhUMTU1ODQyWiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9ZmMyZjBhMzNhMDIzYTAwMWQzOWYzMjAxOGQ5Nzk3NDM2Y2ZlNzJjY2M1ZDVhNzIwOTcwMjVmNDQ5N2QwZmUyYSZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QmYWN0b3JfaWQ9MCZrZXlfaWQ9MCZyZXBvX2lkPTAifQ.Duets8hg5cwC4Goz8uZhF1RyqCFJbYyik9HFhEUKbb4)
Arguably there are a few reasons this error is happening, and many of them are worth tackling. Some of them I've covered in this pr and some of which I did not, figuring we could address it later:
For such a tiny bug, I ended up re-writing a lot of code, because it felt like a good opportunity to clean up some tech debt and get better familiar with our backend architecture. But it also made me a bit concerned that I might have unexpected changes here, so I went ahead and put the new stuff behind a feature flag. I feel reasonably confident with it so I was going to have it enabled by default, but if it seems to be causing issues we'll have a quick way to turn it off without reverting the commit.
An interesting note here is that I saw we have a
regionsCache
which I've removed. I realized while trying to add it back, that we're caching regions under a key ofProfile
which is often undefined, which seems wrong. I think it's not unreasonable for us to add in a cache and create a proper cache key (maybe out of a hash of the auth settings the way we do with settings?) but for now since it seems it was often unused, I've just removed it, but let me know if I'm missing anything!Which issue(s) does this PR fix?:
Fixes #73294
Please check that: