powervs: fix ports cleaning by cleaning them manually on delete#43
Conversation
Summary of ChangesHello @nikromen, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request resolves a critical issue in IBM Cloud PowerVS where network interfaces (ports) were not being automatically cleaned up after VM deletion, leading to the depletion of IP addresses within subnets. The changes introduce a dedicated utility for manual cleanup of orphaned interfaces and integrate proactive network interface deletion into the VM termination workflow, ensuring efficient resource management and preventing future IP pool exhaustion. Highlights
Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces a manual cleanup process for PowerVS network interfaces (ports) upon VM deletion, addressing an issue where they are not automatically removed by IBM Cloud. It adds a new utility script powervs-cleanup-ips to clean up orphaned IPs and modifies the VM deletion logic to remove associated network interfaces.
The changes to the VM deletion process appear correct. However, the new cleanup script contains a critical logic error that would cause it to delete network interfaces of active VMs instead of orphaned ones. There is also a minor issue with error logging in the same script. I've added comments with suggestions to fix these issues.
73dfedf to
e096a58
Compare
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces manual cleanup of network interfaces for PowerVS VMs upon deletion, addressing an issue where they were not being automatically removed. This is achieved by updating the delete_vm function and adding a new utility script, powervs-cleanup-ips, for broader cleanup. While the approach is sound, I've identified a potential race condition in the delete_vm function where network interfaces might be deleted before the VM deletion is complete, potentially leading to failures. My review includes a suggestion to add a waiting mechanism to ensure the VM is fully deleted before proceeding with interface cleanup, making the process more robust.
e096a58 to
18bba27
Compare
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces a crucial fix for cleaning up orphaned network ports in PowerVS, addressing potential resource leaks. This is achieved by adding logic to manually delete network interfaces after a VM is deleted, and also by providing a new standalone cleanup script. The changes include adding new client methods for the v1 API, a polling mechanism to wait for instance deletion, and the core cleanup logic. My review focuses on improving the robustness of the error handling in the new functionality to make it more resilient against various network-related failures.
a4b2d3a to
18bfb8f
Compare
| ) | ||
| try: | ||
| client.delete_network_interface(network_id, iface["id"]) | ||
| except HTTPError as e: |
There was a problem hiding this comment.
is there a re-try mechanism? if yes, just catch all exceptions?
There was a problem hiding this comment.
this is just a helper script to use this to delete all the dangling ports we had, so try is even not needed at all, removed
| return | ||
|
|
||
| logger.error("Failed to get instance %s: %s", instance_id, str(e)) | ||
| break |
There was a problem hiding this comment.
do you really want to break, or continue?
There was a problem hiding this comment.
on continue we may get stuck. 5xx errors are retried. Waiting for the VM to delete itself and then check and delete ports was gemini's idea, which makes sense... but in my experience with powervs this is not needed, so I'd rather break on error here (the API client in this tool I've written itself retries on error requests several times and after several retries it gives up, see powervs.client.PowerVSClient.request) and then we can proceed with the request of port deletion anyway. Whatever here goes wrong, we should still try to remove the dangling port (if there is any)
18bfb8f to
62a093e
Compare
62a093e to
d58af5f
Compare
ssia