EmAchieng / azure-networking-management

0 stars 0 forks source link

Resource Tracking Mechanism #10

Closed EmAchieng closed 1 day ago

EmAchieng commented 1 week ago

Description: The resources created in the try block are deleted in the finally block regardless of whether they were successfully created. This could lead to redundant or failed delete operations for resources that do not exist.

Possible Fix: Use a resource tracking mechanism (like the resources_created dictionary) to ensure that only resources that were successfully created are deleted. This will prevent unnecessary error messages during the cleanup process.

EmAchieng commented 1 day ago
  1. Conditional Deletion:

    • The cleanup process now checks the resources_created dictionary to verify whether a resource was successfully created before attempting deletion. This ensures that only existing resources are targeted for removal, preventing redundant error messages.
  2. Improved Reliability:

    • By leveraging the resources_created dictionary, the script enhances its reliability during the cleanup process. It avoids exceptions related to trying to delete resources that were never created, leading to a smoother execution flow.
  3. Cleaner Logs:

    • The adjustments have led to cleaner log outputs, free from clutter caused by failed deletion attempts. This makes it easier to track the actual state of resource management.