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:[CORE-2050][Azure-Collector-Issue]Adding "Unauthorized" errorcodes/messages to Datadog omission List #2263

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

AnandPaladin
Copy link
Contributor

@AnandPaladin AnandPaladin commented Jun 13, 2024

Description

This is related to https://paladincloud.atlassian.net/browse/CORE-2050 where vertex azure collector throwing datadog alerts due to "UnAuthorized" exception such as 401/403 error codes. These error codes should be excluded from datadog alerts because we are triggering notification for those alerts.

Problem

Some of the error codes are not in exclusion list.Detailed root causes are documented in this https://docs.google.com/spreadsheets/d/1dKZwK_bFE_4YRjyQX91vwYYdSxqSZEdVuyDeeZXxSb0/edit#gid=0
<style type="text/css"></style>

S.No Failed Collector Root cause File Omiited from Datadog Solution
1 RegisteredApplicationInventoryCollector 2024-06-12 23:42:38 [pool-3-thread-24] ERROR c.t.p.c.a.c.AzureCredentialManager - Error getting Grpah API token from Azure401---Unauthorized getGraphApiAuthToken() method in AzureCredentialManager.java Not ommited Need to add ommisionList at triggerNotificationPermissionDenied() at ErrorManageUtil.java
2 WebAppInventoryCollector com.microsoft.azure.management.appservice.DefaultErrorResponseException: Status code 403, { "error": { "code": "AuthorizationFailed", "message": "The client '94b60d78-9ae6-4cf8-9b1c-2d17a2b1bab6' with object id '94b60d78-9ae6-4cf8-9b1c-2d17a2b1bab6' does not have authorization to perform action 'Microsoft.Web/sites/config/list/action' over scope '/subscriptions/5cccdb97-2331-4736-8a35-cba63b5c9b54/resourceGroups/CorpIT.Dev.VioletAI.USE/providers/Microsoft.Web/sites/vi-dev-violetai-botapp/config/authsettings' or the scope is invalid. If access was recently granted, please refresh your credentials." }} WebAppInventoryCollector getAuthenticationConfig() method Omiited from Datadog  
3 VaultInventoryCollector 2024-06-12 23:43:16 [pool-13-thread-13] ERROR c.t.p.a.i.c.VaultInventoryCollector - Status code 403, { "error": { "code": "Forbidden", "message": "Caller is not authorized to perform action on resource.\r\nIf role assignments, deny assignments or role definitions were changed recently, please observe propagation time.\r\nCaller: appid=15779caf-a560-4578-8be8-c531e9f5449a;oid=94b60d78-9ae6-4cf8-9b1c-2d17a2b1bab6;iss=https://sts.windows.net/dd64b6ec-0a2a-4f60-8ca1-eeaab33884d7/\r\nAction: 'Microsoft.KeyVault/vaults/keys/read'\r\nResource: '/subscriptions/f889eecb-2eaa-4c83-b9bf-341c012ecc3a/resourcegroups/corpit-test-automation-use/providers/microsoft.keyvault/vaults/corpit-test-kv-us-domain'\r\nAssignment: (not found)\r\nDenyAssignmentId: null\r\nDecisionReason: null \r\nVault: CorpIT-Test-KV-US-domain;location=eastus\r\n", "innererror": { "code": "ForbiddenByRbac" } }} VaultInventoryCollector.java Not ommited Need to add ommisionList at triggerNotificationPermissionDenied() at ErrorManageUtil.java

Solution

Adding additional error codes (401/403) to omission list

Fixes # (issue if any)

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also
list any relevant details for your test configuration

  • Test A
  • Test B

Checklist:

  • My code follows the style guidelines of this project
  • My commit message/PR follows the contribution guidelines of this project
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

Other Information:

List any documentation updates that are needed for the Wiki

Summary by CodeRabbit

  • Bug Fixes
    • Improved error handling by adding additional strings to the exception lists, including "Unauthorized", "Forbidden", and "ForbiddenByRbac", to better manage permission-denied notifications.

Copy link
Contributor

coderabbitai bot commented Jun 13, 2024

Walkthrough

The modifications in ErrorManageUtil.java enrich the triggerNotificationPermissionDenied method by adding new exception strings ("Unauthorized", "Forbidden", and "ForbiddenByRbac") to the exceptionList. This enhancement helps in better error handling and notification when specific permission issues occur in the Azure inventory utility.

Changes

File Path Change Summary
...bile/pacbot/azure/inventory/util/ErrorManageUtil.java Updated triggerNotificationPermissionDenied() to include additional exceptions in the exceptionList and misconfiguredExceptionList lists.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant ErrorManageUtil

    Note over User,ErrorManageUtil: Permission Denied Scenario

    User ->> ErrorManageUtil: triggerNotificationPermissionDenied
    ErrorManageUtil ->> ErrorManageUtil: Check exceptions (Unauthorized, Forbidden, ForbiddenByRbac)
    ErrorManageUtil -->> User: Notify Permission Denied
Loading

Poem

🐇 In the realm of Azure's might,

New exceptions come to light.

Unauthorized, Forbidden's call,

ErrorManageUtil catches them all.

Permissions clear, the path defined,

In code's embrace, solutions find. 🚀


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@AnandPaladin AnandPaladin changed the title fix:[CORE-2050]Adding Unauthorised error codes to Data dog omission List fix:[CORE-2050][Azure-Collector-Issue]Adding Unauthorised error codes to Data dog omission List Jun 13, 2024
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 3ef999c and ab22378.

Files selected for processing (1)
  • jobs/azure-discovery/src/main/java/com/tmobile/pacbot/azure/inventory/util/ErrorManageUtil.java (1 hunks)
Additional comments not posted (1)
jobs/azure-discovery/src/main/java/com/tmobile/pacbot/azure/inventory/util/ErrorManageUtil.java (1)

136-136: Ensure the newly added exception strings align with the intended error handling logic.

Verification successful

The search results indicate multiple instances of the terms "Unauthorized", "Forbidden", and "ForbiddenByRbac" across different files. Specifically, in the ErrorManageUtil.java file, the addition of these exception strings appears consistent with the intended logic for error handling.

  • jobs/azure-discovery/src/main/java/com/tmobile/pacbot/azure/inventory/util/ErrorManageUtil.java: The new exception strings are added to the exceptionList.

Based on this, the newly added exception strings align with the intended error handling logic in the ErrorManageUtil.java file.

Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify the usage and impact of the newly added exception strings in the entire codebase.

# Test: Search for the usage of the newly added exception strings. Expect: Consistent usage and handling across the codebase.
rg --type java -e "Unauthorized" -e "Forbidden" -e "ForbiddenByRbac"

Length of output: 1832

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between ab22378 and e865635.

Files selected for processing (1)
  • jobs/azure-discovery/src/main/java/com/tmobile/pacbot/azure/inventory/util/ErrorManageUtil.java (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • jobs/azure-discovery/src/main/java/com/tmobile/pacbot/azure/inventory/util/ErrorManageUtil.java

Copy link

@AnandPaladin AnandPaladin changed the title fix:[CORE-2050][Azure-Collector-Issue]Adding Unauthorised error codes to Data dog omission List fix:[CORE-2050][Azure-Collector-Issue]Adding Unauthorised error codes to Datadog omission List Jun 13, 2024
@AnandPaladin AnandPaladin changed the title fix:[CORE-2050][Azure-Collector-Issue]Adding Unauthorised error codes to Datadog omission List fix:[CORE-2050][Azure-Collector-Issue]Adding "Unauthorized" errorcodes/messages to Datadog omission List Jun 13, 2024
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