Skip to content

Fix multiple 'Deleted' strings from logs#1000

Merged
pragya811 merged 1 commit into
mainfrom
jenkins-fix1
Jun 9, 2026
Merged

Fix multiple 'Deleted' strings from logs#1000
pragya811 merged 1 commit into
mainfrom
jenkins-fix1

Conversation

@pragya811

@pragya811 pragya811 commented Jun 9, 2026

Copy link
Copy Markdown
Member

Type of change

Note: Fill x in []

  • bug
  • enhancement
  • documentation
  • dependencies

Issue

In the unused_nat_gateway.py policy, when a NAT Gateway was successfully deleted, the code was setting unit_price="Deleted" (a string) instead of keeping it as a numeric value.

The _get_es_schema method then tries to calculate TotalYearlySavings by calling __current_savings_year(unit_price), which does:

total_days * 24 * unit_price

When unit_price is the string "Deleted", Python's string multiplication creates:

24 * "Deleted" = "Deleted" repeated 24 times

Then total_days * (that result) = "Deleted" repeated ~4,000+ times (24 hours × ~175 days remaining in year)

For security reasons, all pull requests need to be approved first before running any automated CI

Assisted-by: Cursor

@coderabbitai

coderabbitai Bot commented Jun 9, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Enterprise

Run ID: 284cd56a-3509-4581-a164-17f2b12d71a8

📥 Commits

Reviewing files that changed from the base of the PR and between ea49ded and fdcb956.

📒 Files selected for processing (1)
  • cloud_governance/policy/aws/cleanup/unused_nat_gateway.py

📝 Walkthrough

Summary by CodeRabbit

  • Bug Fixes
    • Enhanced tracking and documentation of unused NAT gateway cleanup operations. Cleanup results now correctly display "Deleted" status when operations complete successfully. Improved data structure implementation for cleanup record documentation, providing more explicit tracking of resource states and pricing information during removal operations.

Walkthrough

The pull request refactors a single method call in NAT gateway cleanup to restructure Elasticsearch schema argument passing. The _get_es_schema(...) invocation now uses explicit keyword-style assignment for resource_state and conditionally maps cleanup_result to "Deleted".

Changes

NAT Gateway Cleanup Schema Argument Update

Layer / File(s) Summary
Elasticsearch schema argument restructuring
cloud_governance/policy/aws/cleanup/unused_nat_gateway.py
The _get_es_schema(...) call in run_policy_operations() is refactored to pass resource_state and cleanup_result using keyword-style assignment, with cleanup_result conditionally mapped to "Deleted" when truthy.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main bug fix: preventing multiple 'Deleted' strings from appearing in logs by correcting unit_price handling.
Description check ✅ Passed The description clearly explains the bug (unit_price set to string 'Deleted' instead of numeric value) and the consequence (string multiplication creating thousands of repeated 'Deleted' entries in logs).
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

Comment @coderabbitai help to get the list of available commands and usage tips.

@pragya811 pragya811 self-assigned this Jun 9, 2026
@pragya811 pragya811 added the bug Something isn't working label Jun 9, 2026
@pragya811 pragya811 requested a review from ebattat June 9, 2026 10:50

@ebattat ebattat left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

/approve

@pragya811 pragya811 merged commit 3c47c99 into main Jun 9, 2026
19 checks passed
@github-project-automation github-project-automation Bot moved this from In progress to Done in Cloud-Governance project Jun 9, 2026
@pragya811 pragya811 deleted the jenkins-fix1 branch June 9, 2026 14:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

Development

Successfully merging this pull request may close these issues.

2 participants