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

Completely remove the MiqVimBrokerWorker #19673

Merged
merged 6 commits into from
Jan 27, 2020

Conversation

agrare
Copy link
Member

@agrare agrare commented Dec 20, 2019

app/models/vm_scan.rb Outdated Show resolved Hide resolved
@jrafanie
Copy link
Member

jrafanie commented Jan 2, 2020

We probably should have a migration to remove any miq_worker rows for broker workers

@agrare agrare force-pushed the removal_of_miq_vim_broker_worker branch from 44d80ad to 070edd1 Compare January 3, 2020 14:55
@chessbyte
Copy link
Member

We probably should have a migration to remove any miq_worker rows for broker workers

@jrafanie won't the miq_worker rows be removed when the appliance gets restarted here?

@Fryguy
Copy link
Member

Fryguy commented Jan 3, 2020

We probably should have a migration to remove any miq_worker rows for broker workers

@jrafanie won't the miq_worker rows be removed when the appliance gets restarted here?

@chessbyte - The problem with the method you referenced is that it is still STI aware. That is, when the query sees an existing MiqVimBrokerWorker row, it will try to instantiate that class and blow up because it won't find the class anymore. This has bitten us before, unfortunately.

However, @jrafanie, I think @chessbyte has a point. If we make the method NOT STI aware, would that solve all of our future problems? Two ways I can think to do it...

select columns without type

MiqWorker.server_scope.select(:id, :pid, :status).each do |w|
  # w.class => MiqWorker
  ...
end

pluck columns

MiqWorker.server_scope.pluck(:id, :pid, :status).each do |w_id, w_pid, w_status|
  # however, you can't do w.is_alive?
end

Totally separate, we can probably make a generic without_sti scope, that is basically just

def self.without_sti
  select(column_names - ["type"])
end

I could see this being really useful in a lot of situations.

@agrare
Copy link
Member Author

agrare commented Jan 3, 2020

Okay put the schema PR in and kicked the cross-repo tests

@chessbyte
Copy link
Member

chessbyte commented Jan 3, 2020

We probably should have a migration to remove any miq_worker rows for broker workers

@jrafanie won't the miq_worker rows be removed when the appliance gets restarted here?

@chessbyte - The problem with the method you referenced is that it is still STI aware. That is, when the query sees an existing MiqVimBrokerWorker row, it will try to instantiate that class and blow up because it won't find the class anymore. This has bitten us before, unfortunately.

Thanks for the clarification.

However, @jrafanie, I think @chessbyte has a point. If we make the method NOT STI aware, would that solve all of our future problems? Two ways I can think to do it...

Agree that we do not need to instantiate a specific worker class just so we can kill the process and delete the row.

select columns without type

MiqWorker.server_scope.select(:id, :pid, :status).each do |w|
  # w.class => MiqWorker
  ...
end

pluck columns

MiqWorker.server_scope.pluck(:id, :pid, :status).each do |w_id, w_pid, w_status|
  # however, you can't do w.is_alive?
end

I prefer the select approach.

Totally separate, we can probably make a generic without_sti scope, that is basically just

def self.without_sti
  select(columns_names - ["type"])
end

I could see this being really useful in a lot of situations.

Totally agree that this would be useful in other scenarios. Where should this be defined?

@jrafanie
Copy link
Member

jrafanie commented Jan 6, 2020

We probably should have a migration to remove any miq_worker rows for broker workers

@jrafanie won't the miq_worker rows be removed when the appliance gets restarted here?

Looking at @Fryguy's cool ideas about avoiding the the STI problem with missing classes, I am also wondering if we need to be in the business of managing the server's worker processes. I think much of these process related checks were written before systemd and I don't know how likely there are to be runaway processes that don't exit or don't get killed by systemd. The processes can't be heartbeating as their server's drb port has changed once the server was restarted so I'm not sure what situation a worker could get in that would leave it running but not heartbeating and not exceeding memory... maybe a deadlock? Either way, I'm curious if we would have written this code in this way if we were to start from scratch with systemd.

@agrare agrare force-pushed the removal_of_miq_vim_broker_worker branch from 7ae2d8a to 2096f8d Compare January 6, 2020 21:08
@agrare agrare force-pushed the removal_of_miq_vim_broker_worker branch from 2096f8d to 70bb989 Compare January 7, 2020 01:38
@chessbyte
Copy link
Member

@chessbyte
Copy link
Member

@kbrock maybe you can take a look at implementing the without_sti method/scope discussed above.

@chessbyte
Copy link
Member

@agrare what is the status of this PR? hard to figure out what the dependencies and/or issues are before this can be merged

@agrare
Copy link
Member Author

agrare commented Jan 23, 2020

Yeah sorry @chessbyte I've been working on finishing up this issue #19543 then I'm going to get back to this. Mainly just need to get the cross-repo tests green in addition to some manual testing.

@agrare agrare force-pushed the removal_of_miq_vim_broker_worker branch 2 times, most recently from a850e1f to 395a1d4 Compare January 24, 2020 19:45
@agrare agrare force-pushed the removal_of_miq_vim_broker_worker branch from 395a1d4 to 36ec1d6 Compare January 24, 2020 19:58

# Check for a specific type (host/ems) if passed
# Default use_vim_broker is true for ems type
::Settings.coresident_miqproxy["use_vim_broker_#{type}"] == true
Copy link
Member

Choose a reason for hiding this comment

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

Can we drop this setting altogether? Do we need a data migration to drop it?

@agrare agrare force-pushed the removal_of_miq_vim_broker_worker branch from 36ec1d6 to 02a2f05 Compare January 24, 2020 20:49
@agrare agrare force-pushed the removal_of_miq_vim_broker_worker branch from 02a2f05 to 755d219 Compare January 24, 2020 21:11
@miq-bot
Copy link
Member

miq-bot commented Jan 24, 2020

Checked commits agrare/manageiq@201fc05~...755d219 with ruby 2.5.5, rubocop 0.69.0, haml-lint 0.20.0, and yamllint 1.10.0
15 files checked, 5 offenses detected

app/models/vm_or_template.rb

  • ❗ - Line 442, Col 5 - Style/SafeNavigation - Use safe navigation (&.) instead of checking if an object exists before calling the method.

spec/models/miq_action_spec.rb

@Fryguy Fryguy merged commit 18534ed into ManageIQ:master Jan 27, 2020
@Fryguy
Copy link
Member

Fryguy commented Jan 27, 2020

🎉 🎉 🎉 🎉 🌮 🎉

@agrare agrare deleted the removal_of_miq_vim_broker_worker branch January 27, 2020 15:28
@Fryguy Fryguy added this to the Sprint 129 Ending Feb 3, 2020 milestone Jan 27, 2020
@jrafanie
Copy link
Member

🔥 🗑 🚽
🔥 🗑 🚽
🔥 🗑 🚽
🔥 🗑 🚽
🔥 🗑 🚽
🔥 🗑 🚽
🔥 🗑 🚽
🔥 🗑 🚽
🔥 🗑 🚽
🔥 🗑 🚽
🔥 🗑 🚽
🔥 🗑 🚽
🔥 🗑 🚽

@chessbyte
Copy link
Member

Wow!!!!! This has been a long time coming!! Congratulations to all involved for making this happen!

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.

6 participants