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

Fix workers not restarting when auth/endpoints are changed. #22269

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

agrare
Copy link
Member

@agrare agrare commented Dec 6, 2022

When changes are made to the endpoints or authentications workers which run with an open connection like event catchers and streaming refresh workers have to be restarted.

This was done via after_update_authentication called from update_authentication. The issue is that this method is no longer called when providers are updated via the API with DDF parameters.

We also have some before_save :stop_event_monitor_queue_on_change, :stop_refresh_worker_queue_on_change but these aren't invoked because auth/endpoint changes aren't part of the ext_management_system record.

Ref ManageIQ/manageiq-providers-openshift#235 (comment)

TODO

  • Specs for edit_with_params
  • Handle child managers' workers

Depends on:

Cross-Repo: ManageIQ/manageiq-cross_repo-tests#720

@agrare agrare force-pushed the endpoint_auth_changed_callbacks_edit_with_params branch from 1ee330a to 0733f89 Compare December 6, 2022 17:48
Comment on lines +178 to +180
endpoints_changed = false
authentications_changed = false
Copy link
Member Author

Choose a reason for hiding this comment

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

NOTE I'm not sure how necessary it is to differentiate between endpoints and authentications changing. Currently as far as I can tell we only use this information to restart workers and we need to do that when either endpoints or authentications change.

@agrare agrare force-pushed the endpoint_auth_changed_callbacks_edit_with_params branch from 0733f89 to eb74c6c Compare December 6, 2022 18:40
_log.info("EMS: [#{name}], Hostname or IP address has changed, stopping Event Monitor. It will be restarted by the WorkerMonitor.")
stop_event_monitor_queue
end
end

def stop_event_monitor_queue_on_credential_change
if event_monitor_class && !self.new_record? && self.credentials_changed?
Copy link
Member Author

Choose a reason for hiding this comment

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

NOTE credentials_changed? used an instance variable set early in #update_authentications but it seemed easier to just check default_authentication.changed?

I didn't want to rewrite the credentials_changed? method to use this in case something else depended on that exact behavior.

Also that method only checked auth_user_pwd which wouldn't work for k8s/gce/etc... which use an auth_key.

I would like to be able to specify e.g. authentication_for_events rather than default_authentication in case a provider doesn't use the default_auth for events.

Copy link
Member

Choose a reason for hiding this comment

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

Is that something you want to do as a followup or for this 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.

I should be able to get that working in this 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.

I've added authtype_for_event/refresh and endpoint_role_for_event/refresh so that the callbacks can check the changes for endpoints they care about

@agrare agrare changed the title [WIP] Fix workers not restarting when auth/endpoints are changed. Fix workers not restarting when auth/endpoints are changed. Dec 6, 2022
@agrare
Copy link
Member Author

agrare commented Dec 6, 2022

Example changing the credentials for an Openshift provider

INFO -- evm: MIQ(ManageIQ::Providers::Openshift::ContainerManager#stop_refresh_worker_queue_on_credential_change) EMS: [CRC], Credentials have changed, stopping Refresh Worker.  It will be restarted by the WorkerMonitor.
INFO -- evm: MIQ(MiqQueue.put) Message id: [7862], Zone: [default], Role: [], Server: [000be0ae-9877-4482-9226-a3b1a07bcd67], MiqTask id: [], Handler id: [], Ident: [miq_server], Target id: [], Instance id: [1], Task id: [], Command: [MiqServer.stop_worker], Timeout: [600], Priority: [100], State: [ready], Deliver On:        [], Data: [], Args: [10, nil]
INFO -- evm: MIQ(MiqQueue#deliver) Message id: [7862], Delivering...
INFO -- evm: MIQ(MiqServer::WorkerManagement::Process#stop_worker) Stopping Worker [ManageIQ::Providers::Openshift::ContainerManager::RefreshWorker] with ID: [10], PID: [107883], GUID: [d4068664-8dc3-4177-8d77-67c807b91ad4], status [started]...

@agrare
Copy link
Member Author

agrare commented Dec 6, 2022

miq-bot pushed a commit to ManageIQ/manageiq-cross_repo-tests that referenced this pull request Dec 6, 2022
@agrare agrare force-pushed the endpoint_auth_changed_callbacks_edit_with_params branch 3 times, most recently from 1ed4d61 to 0394dd3 Compare December 7, 2022 17:00
agrare added a commit to ManageIQ/manageiq-cross_repo-tests that referenced this pull request Dec 7, 2022
@Fryguy Fryguy self-assigned this Dec 7, 2022
@Fryguy
Copy link
Member

Fryguy commented Dec 7, 2022

Note that there's a WIP commit message in here, that should be cleaned up when this is ready.

@agrare agrare force-pushed the endpoint_auth_changed_callbacks_edit_with_params branch from 0394dd3 to 1215980 Compare December 9, 2022 15:18
@miq-bot
Copy link
Member

miq-bot commented Mar 13, 2023

This pull request has been automatically marked as stale because it has not been updated for at least 3 months.

If these changes are still valid, please remove the stale label, make any changes requested by reviewers (if any), and ensure that this issue is being looked at by the assigned/reviewer(s)

Thank you for all your contributions! More information about the ManageIQ triage process can be found in the triage process documentation.

@agrare agrare force-pushed the endpoint_auth_changed_callbacks_edit_with_params branch from b9d480e to 2ebfd61 Compare March 14, 2023 15:46
@kbrock kbrock removed the stale label Mar 15, 2023
@Fryguy
Copy link
Member

Fryguy commented Mar 20, 2023

@agrare Is this ready to go? Maybe a cross-repo test?

When changes are made to the endpoints or authentications workers which
run with an open connection like event catchers and streaming refresh
workers have to be restarted.

This was done via `after_update_authentication` called from
`update_authentication`.  The issue is that this method is no longer
called when providers are updated via the API with DDF parameters.
@agrare agrare force-pushed the endpoint_auth_changed_callbacks_edit_with_params branch from 2ebfd61 to 6f5a865 Compare June 19, 2023 13:50
@miq-bot
Copy link
Member

miq-bot commented Jun 19, 2023

Checked commits agrare/manageiq@2c4ff02~...6f5a865 with ruby 2.6.10, rubocop 1.28.2, haml-lint 0.35.0, and yamllint
4 files checked, 0 offenses detected
Everything looks fine. 🏆

@kbrock
Copy link
Member

kbrock commented Jun 20, 2023

ok, ManageIQ/manageiq-cross_repo-tests#720 is green.

Does this mean we are ready to go?

@miq-bot miq-bot added the stale label Sep 25, 2023
@miq-bot
Copy link
Member

miq-bot commented Sep 25, 2023

This pull request has been automatically marked as stale because it has not been updated for at least 3 months.

If these changes are still valid, please remove the stale label, make any changes requested by reviewers (if any), and ensure that this issue is being looked at by the assigned/reviewer(s)

Thank you for all your contributions! More information about the ManageIQ triage process can be found in the triage process documentation.

@agrare agrare removed the stale label Sep 25, 2023
@miq-bot miq-bot added the stale label Jan 1, 2024
@miq-bot
Copy link
Member

miq-bot commented Jan 1, 2024

This pull request has been automatically marked as stale because it has not been updated for at least 3 months.

If these changes are still valid, please remove the stale label, make any changes requested by reviewers (if any), and ensure that this issue is being looked at by the assigned/reviewer(s).

@miq-bot
Copy link
Member

miq-bot commented Mar 7, 2024

This pull request is not mergeable. Please rebase and repush.

@miq-bot
Copy link
Member

miq-bot commented Jun 10, 2024

This pull request has been automatically marked as stale because it has not been updated for at least 3 months.

If these changes are still valid, please remove the stale label, make any changes requested by reviewers (if any), and ensure that this issue is being looked at by the assigned/reviewer(s).

1 similar comment
@miq-bot
Copy link
Member

miq-bot commented Sep 16, 2024

This pull request has been automatically marked as stale because it has not been updated for at least 3 months.

If these changes are still valid, please remove the stale label, make any changes requested by reviewers (if any), and ensure that this issue is being looked at by the assigned/reviewer(s).

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