Skip to content

Remove VMs and Hosts on HMC provider removal - #208

Open
Kummari-Yeshwanth wants to merge 1 commit into
ManageIQ:masterfrom
Kummari-Yeshwanth:purge_vms_branch
Open

Remove VMs and Hosts on HMC provider removal#208
Kummari-Yeshwanth wants to merge 1 commit into
ManageIQ:masterfrom
Kummari-Yeshwanth:purge_vms_branch

Conversation

@Kummari-Yeshwanth

@Kummari-Yeshwanth Kummari-Yeshwanth commented Jul 30, 2026

Copy link
Copy Markdown

Summary

Delete HMC inventory when a provider is removed instead of leaving the inventory in an archived state.

Changes

  • Added a provider setting to control inventory deletion on provider removal.
  • Added HMC-specific handling during provider removal.
  • Delete associated VMs and Hosts before the provider is destroyed.

@Kummari-Yeshwanth Kummari-Yeshwanth changed the title AAIOPS 399 Remove VMs and Hosts on HMC provider removal Jul 30, 2026
@Kummari-Yeshwanth
Kummari-Yeshwanth force-pushed the purge_vms_branch branch 2 times, most recently from 67656b0 to 2223a88 Compare July 30, 2026 15:06
@agrare

agrare commented Jul 30, 2026

Copy link
Copy Markdown
Member

This feels like something we could do in core (not necessarily exactly this way) if people don't want to keep this type of inventory around, @Fryguy ?

@Fryguy

Fryguy commented Jul 30, 2026

Copy link
Copy Markdown
Member

Agreed. An option when deleting a provider would be welcome across the board.

Note that even if the user decides to remove all of the inventory, I don't think this PR is the right way to do it. We've seen instances where deleting all of the VMS and hosts and everything can take a very long time because there's a lot of associated records. For example, if you had 10,000 VMS, this is deleting them one by one which can get very expensive.

I recall us putting the provider in maintenance mode first and then doing some other things. Maybe that's what orchestrate destroy does... I can't remember offhand.

@Fryguy

Fryguy commented Jul 30, 2026

Copy link
Copy Markdown
Member

Please also rebase this PR and don't use merge commits as described by the bot

@agrare

agrare commented Jul 30, 2026

Copy link
Copy Markdown
Member

I recall us putting the provider in maintenance mode first and then doing some other things. Maybe that's what orchestrate destroy does... I can't remember offhand.

Yes that is what orchestrate_destroy does.

ETA: Well technically orchestrate_destroy pauses the provider and waits for all workers to exit, the original intention wasn't to pre-destroy dependent associations that could take a long time but that's not a bad secondary benefit actually. Normally we've relied on purging to do this.

@miq-bot

miq-bot commented Jul 30, 2026

Copy link
Copy Markdown
Member

Checked commit Kummari-Yeshwanth@b3f905d with ruby 3.3.10, rubocop 1.86.0, haml-lint 0.73.0, and yamllint 1.37.1
1 file checked, 0 offenses detected
Everything looks fine. ⭐

@Fryguy

Fryguy commented Jul 30, 2026

Copy link
Copy Markdown
Member

Ok, right, so the way orchestrate_destroy is being used in this PR is not correct. Here it deletes all the vms and hosts then calls super, so if there are active ems workers running they would put the vms and hosts right back. Also, orchestrate_destroy does this all on the queue with a task_id, which this code bypasses.

I think the right way to do this is to override EMS#disconnect_inv (or implement this optional delete logic there for all providers), but I'm having trouble walking whether that would work or not.

@Fryguy Fryguy added the enhancement New feature or request label Aug 5, 2026
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

Successfully merging this pull request may close these issues.

4 participants