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

feature: Cost Insights: better error handling for team doesnt have cost insights related annotation #325

Open
Chris-Lee-Ca opened this issue Jan 27, 2025 · 4 comments
Labels
enhancement New feature or request

Comments

@Chris-Lee-Ca
Copy link

🔖 Feature description

Currently, the error handling strategy for entities missing Cost Insights-related annotations (aws.amazon.com/cost-insights-cost-categories or aws.amazon.com/cost-insights-tags) only displays a generic internal server error (500) without providing any meaningful context. It would be beneficial to display a clear hint suggesting the need to add the required tagging, rather than just showing the error. This enhancement would improve usability and make troubleshooting easier.

Additionally, Our company has some generic group entities assigned to users purely for RBAC (Role-Based Access Control) management purposes. These entities do not represent actual teams in the AWS environment, so they are not expected to include any Cost Insights-related annotations in their catalog-info.yaml files. Currently, if these groups being the first result returned by the getUserGroups method, the Overview page redirects users to an internal error page. This behavior provides no option to switch to a different team from the UI. The only way to "escape" from the error would be manually update the team name in the URL. This is unintuitive for users.

🎤 Context

For the first problem, displaying an instruction similar to what TechDocs does:
Image
For the second problem, we could filter out groups that lack the appropriate annotations. Another possible solution would be to make the CostExplorerClient class public, allowing developers to manually override the logic in some of its methods.

✌️ Possible Implementation

One possible implementation for the second problem is:

async getUserGroups(userId: string): Promise<Group[]> {
   return (
     await this.catalogApi.getEntities({
       filter: {
         kind: 'Group',
         ['relations.hasMember']: [`user:default/${userId}`],
       },
     })
   ).items
     .filter(e =>
       [COST_INSIGHTS_AWS_COST_CATEGORY_ANNOTATION, COST_INSIGHTS_AWS_TAGS_ANNOTATION].some(
         key => e.metadata.annotations?.[key] !== undefined
       )
     )
     .map(e => {
       return {
         id: `group:${e.metadata.name}`,
         name: e.metadata.name,
       };
     });
 }
@Chris-Lee-Ca Chris-Lee-Ca added the enhancement New feature or request label Jan 27, 2025
@niallthomson
Copy link
Contributor

Hi @Chris-Lee-Ca

The first issue I believe is related to how upstream cost insights is built.

Your fix for the second issue seems reasonable but it will not help with the first issue correct?

@Chris-Lee-Ca
Copy link
Author

Hi @niallthomson At first, I didn’t take a closer look at how it could be implemented. After taking a deeper look, yes, it is an upstream problem. I will create an issue there.

As for my fix, no, it won’t help with the first issue.

@ZhouLihua
Copy link

Hi there, is there any configure that will not use annotation to check the cost. I only want to know the costs for a aws account. Not group by any annotation.

@niallthomson
Copy link
Contributor

Hi @ZhouLihua we need something to tell what cost to display. Do you currently import your AWS accounts in to the Backstage catalog?

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

No branches or pull requests

3 participants