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

Deregister services from service registry on shutdown #5396

Merged
merged 14 commits into from
Dec 2, 2021

Conversation

khushboobhatia01
Copy link
Contributor

Few services like worker, workflow engine, scheduler and notifier perform a shutdown sequence before exiting the process. This PR will ensure that the services deregister themselves from service registry on shutdown and then continue with shutdown sequence.

(PR based on #5373 step 1)

@pull-request-size pull-request-size bot added the size/M PR that changes 30-99 lines. Good size to review. label Oct 19, 2021
@arm4b arm4b added this to the 3.7.0 milestone Oct 19, 2021
@arm4b arm4b requested review from Kami and m4dcoder October 19, 2021 14:40
Copy link
Contributor

@m4dcoder m4dcoder left a comment

Choose a reason for hiding this comment

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

@khushboobhatia01 Good start.

  1. Is it possible to write a unit test for deregister_service?
  2. How about other services (i.e. api, rulesengine, etc.)? Search service_registry=True to find them.

st2actions/st2actions/cmd/actionrunner.py Outdated Show resolved Hide resolved
@pull-request-size pull-request-size bot added size/L PR that changes 100-499 lines. Requires some effort to review. and removed size/M PR that changes 30-99 lines. Good size to review. labels Oct 28, 2021
@khushboobhatia01
Copy link
Contributor Author

@khushboobhatia01 Good start.

  1. Is it possible to write a unit test for deregister_service?
  2. How about other services (i.e. api, rulesengine, etc.)? Search service_registry=True to find them.

Addressed @m4dcoder

Copy link
Contributor

@m4dcoder m4dcoder left a comment

Choose a reason for hiding this comment

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

Minor concern on error handling during deregistration.

try:
service_setup.deregister_service(service)
except:
assert False, "service_setup.deregister_service raised exception"
Copy link
Contributor

Choose a reason for hiding this comment

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

@khushboobhatia01 What happens if this error is raised on shutdown? I think it is ok to make this silent if there is nothing to be deregister.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@m4dcoder We don't expect deregister() to raise an exception when service_registry is disabled or there's nothing to deregister. This test case would fail only when some unintended change is causing deregister to fail. All edge cases are handled in deregister(). Therefore it might be good to know if some new change is causing it to fail.

Copy link
Contributor

@m4dcoder m4dcoder left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks for your contribution and patience.

Copy link
Member

@arm4b arm4b left a comment

Choose a reason for hiding this comment

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

@khushboobhatia01 Could you please also add Changelog for this PR before we merge it?

@khushboobhatia01
Copy link
Contributor Author

@khushboobhatia01 Could you please also add Changelog for this PR before we merge it?

Done @armab. Thanks for reminding :)

@arm4b arm4b merged commit caacdfa into StackStorm:master Dec 2, 2021
@arm4b
Copy link
Member

arm4b commented Dec 2, 2021

Great stuff! Thanks @khushboobhatia01 for the work and @m4dcoder for review! 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement size/L PR that changes 100-499 lines. Requires some effort to review.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants