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

Fixes #36665 - Remove katello-agent API endpoints and rabl nodes #10690

Merged

Conversation

jeremylenz
Copy link
Member

What are the changes introduced in this pull request?

Remove Katello API endpoints that use katello-agent:

  • /hosts/:host_id/errata/apply
  • /hosts/:host_id/packages/install
  • /hosts/:host_id/packages/upgrade
  • /hosts/:host_id/packages/upgrade_all
  • /hosts/:host_id/packages/remove
  • /hosts/bulk/install_content
  • /hosts/bulk/update_content
  • /hosts/bulk/remove_content

Also remove katello-agent from api/ping.

Considerations taken when implementing this change?

This will break all related Hammer commands, so we should probably wait and merge the hammer-cli-katello PR at the same time as this one

What are the testing steps for this pull request?

Try existing hammer commands and confirm they're broken, I guess

@theforeman-bot
Copy link

Issues: #36665

@host.content_facet.expects(:cves_changed?).returns(false)
::Katello::Resources::Candlepin::Consumer.expects(:destroy)
::Katello::EventQueue.expects(:push_event).never
::Katello::RegistrationManager.unregister_host(@host, :unregistering => true)
end

def test_unregister_host_with_katello_agent
Copy link
Member

@jturel jturel Aug 9, 2023

Choose a reason for hiding this comment

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

I was admiring your work when it occurred to me that there's always a small chance that after all this cleanup is done, there may be "delete host agent queue" events in the db which will break the event queue when they get processed because their handler class will be removed. You'll need an upgrade rake task to delete those from the events table. Obviously, on the PR when you remove that stuff

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, I was just thinking about delete_host_agent_queue and how to handle that.. 😢

Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need that? Isn't the queue emptied when upgrading any way?

Copy link
Member

Choose a reason for hiding this comment

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

The queue isn't explicitly emptied on upgrade and there could be events on it especially for this specific case because it's scheduled to run ten minutes in the future. Any hosts unregistered ~10 minutes before shutdown will put the events on queue and if Katello is upgraded with that event removed it'll raise an error around an unsupported event. There could also be events stuck on the queue due to this bug: #10692

Looking at the code:

def self.event_class(event_type)
fail _("Invalid event_type %s") % event_type if @event_types[event_type].nil?
@event_types[event_type].constantize

An error gets raised if an unsupported event is found on queue which is what will happen when the event's class is removed from the app. However, that error may be rescued, logged, and the event removed:

begin
::User.as_anonymous_admin do
event_instance = ::Katello::EventQueue.create_instance(event)
event_instance.run
end
rescue => e
@failed_count += 1
@logger.error("event_queue_error: type=#{event.event_type}, object_id=#{event.object_id}")
@logger.error(e.message)
@logger.error(e.backtrace.join("\n"))

Definitely test that to make sure it doesn't break the queue though.

Copy link
Member Author

Choose a reason for hiding this comment

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

So, do you think I should add to the rescue here instead of the upgrade rake task?

Either way, can this be addressed in a followup issue?

Copy link
Member

@jturel jturel Aug 15, 2023

Choose a reason for hiding this comment

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

I think the rescue & ensure that are there will handle the situation already - but that needs a confirmation - definitely outside of the scope here!

@jeremylenz jeremylenz force-pushed the 36665-katello-agent-remove-api branch 2 times, most recently from a656b3e to 6eb2a30 Compare August 11, 2023 20:35
@jeremylenz
Copy link
Member Author

@parthaa Updated route overrides 👍

Copy link
Member

@jturel jturel left a comment

Choose a reason for hiding this comment

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

LGTM ;)

@jeremylenz jeremylenz force-pushed the 36665-katello-agent-remove-api branch 2 times, most recently from e748a28 to e9a2f16 Compare August 21, 2023 17:59
@jeremylenz
Copy link
Member Author

Waiting until theforeman/forklift#1695 is merged.

@jeremylenz jeremylenz force-pushed the 36665-katello-agent-remove-api branch from e9a2f16 to 8ba3396 Compare August 21, 2023 21:33
@jeremylenz jeremylenz force-pushed the 36665-katello-agent-remove-api branch from 8ba3396 to 9aba33a Compare August 28, 2023 13:55
@jeremylenz
Copy link
Member Author

[test katello]

@jeremylenz jeremylenz merged commit bb738c6 into Katello:master Aug 29, 2023
4 of 5 checks passed
chris1984 pushed a commit that referenced this pull request Sep 6, 2023
chris1984 pushed a commit that referenced this pull request Sep 6, 2023
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