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

Move the vmware-specific assign_ems_created_on method #655

Merged

Conversation

agrare
Copy link
Member

@agrare agrare commented Oct 20, 2020

The VmOrTemplate.assign_ems_created_on method is very VMware specific, it looks for VMware events then queries the historical event history to find created events.

Also using a graph-refresh dependent collection allows us to skip the step of "finding" vms which were created in this refresh by timestamp since we have access to the set of created_records directly.

ManageIQ/manageiq#19440

@agrare agrare requested a review from Fryguy as a code owner October 20, 2020 13:31
@agrare agrare force-pushed the move_vmware_specific_assign_ems_created_on branch from 8c51e40 to 570da3c Compare October 20, 2020 13:46
The VmOrTemplate.assign_ems_created_on method is very VMware specific,
it looks for VMware events then queries the historical event history to
find created events.
@miq-bot
Copy link
Member

miq-bot commented Oct 20, 2020

Checked commit agrare@b64a6a8 with ruby 2.6.3, rubocop 0.69.0, haml-lint 0.28.0, and yamllint
2 files checked, 2 offenses detected

app/models/manageiq/providers/vmware/infra_manager.rb

@chessbyte chessbyte self-assigned this Oct 20, 2020
@chessbyte chessbyte merged commit bced590 into ManageIQ:master Oct 20, 2020
@agrare agrare deleted the move_vmware_specific_assign_ems_created_on branch October 20, 2020 13:57
# Of the VMs without a VM create time, filter out the ones for which we
# already have a VM create event
vms_to_update = vms_to_update.reject do |v|
event = v.ems_events.find_by(:event_type => ["VmCreatedEvent", "VmDeployedEvent"])
Copy link
Member

Choose a reason for hiding this comment

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

Ugh this is a nasty N+1...I'll put in a follow up PR.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah this was a straight move, refactoring to follow

Copy link
Member Author

Choose a reason for hiding this comment

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

Also I should note that this is disabled in Settings by default which is why we probably never noticed when it was in core VmOrTemplate

Copy link
Member

Choose a reason for hiding this comment

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

Makes me wonder if we should just get rid of it.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, on vSphere 6.7 we can actually pull this from inventory directly (#645) so this won't be needed at all.

Copy link
Member Author

Choose a reason for hiding this comment

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

👍 I'm good with removing it then, you want to do that in #645 then?

Copy link
Member

@Fryguy Fryguy Oct 22, 2020

Choose a reason for hiding this comment

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

Would like @chessbyte 's input here as well.

@chessbyte tl;dr In the past vSphere didn't give us the created date, so we guessed based on the events (we'd find a VmCreatedEvent or VmDeployedEvent). However that guessing was behind an option that defaulted to false. Since in vSphere 6.7+ we get it for free from the refresh, I'm proposing dropping this "guessing" code altogether.

Copy link
Member

Choose a reason for hiding this comment

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

@Fryguy @agrare if this functionality is new to master, then I am ok with it being available on vSphere 6.7+. If we had this functionality for older vSphere versions, then we need to preserve it, probably by checking for vSphere version and then doing the optimal thing.

Copy link
Member

Choose a reason for hiding this comment

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

There is a check at the beginning on the method for whether ems_created_on is already set, so it will naturally skip vsphere 6.7+. I guess where I'm coming from is that if the setting is false by default, then there's likely nobody turning it on. So, the actual usage of this is probably nobody, hence my thought to drop it.

Copy link
Member

Choose a reason for hiding this comment

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

then, I agree to drop it. if a user complains, we can have a conversation at that time about what to do

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants