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

Shield service call from cancellation on REST API connection loss #102657

Merged
merged 7 commits into from
Nov 2, 2023

Conversation

Shulyaka
Copy link
Contributor

@Shulyaka Shulyaka commented Oct 24, 2023

Breaking change

When calling a service from REST API, the service used to be cancelled on connection drop. If you relied on that behavior, you would need to revisit the logic. With this change, a connection drop will not cancel the service call. Additionally, if the service call takes more than 10 second to execute, the REST API will return and the service call will continue executing in the background. Although this behavior is documented, it was not the case for several past releases.

Proposed change

This PR restores the behavior in the REST API documentation: when a service call is executed via /api/services/<domain>/<service>, the call should return when the service has been executed or after 10 seconds, whichever comes first.
Also, this PR fixes the cancellation of the service call on disconnect.

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New integration (thank you!)
  • New feature (which adds functionality to an existing integration)
  • Deprecation (breaking change to happen in the future)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Additional information

Checklist

  • The code change is tested and works locally.
  • Local tests pass. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the development checklist
  • I have followed the perfect PR recommendations
  • The code has been formatted using Black (black --fast homeassistant tests)
  • Tests have been added to verify that the new code works.

If user exposed functionality or configuration variables are added/changed:

If the code communicates with devices, web services, or third-party tools:

  • The manifest file has all fields filled out correctly.
    Updated and included derived files by running: python3 -m script.hassfest.
  • New or updated dependencies have been added to requirements_all.txt.
    Updated by running python3 -m script.gen_requirements_all.
  • For the updated dependencies - a link to the changelog, or at minimum a diff between library versions is added to the PR description.
  • Untested files have been added to .coveragerc.

To help with the load of incoming pull requests:

@home-assistant
Copy link

Hey there @home-assistant/core, mind taking a look at this pull request as it has been labeled with an integration (api) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of api can trigger bot actions by commenting:

  • @home-assistant close Closes the pull request.
  • @home-assistant rename Awesome new title Renames the pull request.
  • @home-assistant reopen Reopen the pull request.
  • @home-assistant unassign api Removes the current integration label and assignees on the pull request, add the integration domain after the command.

@Shulyaka Shulyaka changed the title Shield service call from cancellation on connection loss Shield service call from cancellation on REST API connection loss Oct 24, 2023
@Shulyaka Shulyaka force-pushed the api_service_timeout branch from d77a1ef to edf425f Compare October 24, 2023 13:46
@frenck frenck added the smash Indicator this PR is close to finish for merging or closing label Oct 25, 2023
@Shulyaka Shulyaka requested a review from bdraco October 31, 2023 19:41
bdraco
bdraco previously requested changes Oct 31, 2023
Copy link
Member

@bdraco bdraco left a comment

Choose a reason for hiding this comment

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

please see #102657 (comment)

@home-assistant home-assistant bot marked this pull request as draft October 31, 2023 21:34
@home-assistant
Copy link

Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍

Learn more about our pull request process.

@Shulyaka Shulyaka requested a review from bdraco October 31, 2023 22:25
@bdraco bdraco removed the smash Indicator this PR is close to finish for merging or closing label Oct 31, 2023
@bdraco bdraco self-requested a review November 1, 2023 21:27
@Shulyaka Shulyaka marked this pull request as ready for review November 1, 2023 21:31
@Shulyaka
Copy link
Contributor Author

Shulyaka commented Nov 1, 2023

The breaking change label should probably be added manually to the PR

@bdraco bdraco added breaking-change ci-full-run Marks a PR to trigger a full CI run (instead of partial) labels Nov 1, 2023
@bdraco
Copy link
Member

bdraco commented Nov 1, 2023

close/reopen to restart ci

@bdraco bdraco closed this Nov 1, 2023
@bdraco bdraco reopened this Nov 1, 2023
@home-assistant home-assistant bot marked this pull request as draft November 2, 2023 10:46
@Shulyaka Shulyaka marked this pull request as ready for review November 2, 2023 11:16
Copy link
Member

@MartinHjelmare MartinHjelmare left a comment

Choose a reason for hiding this comment

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

Thanks!

@MartinHjelmare MartinHjelmare merged commit d18b2d8 into home-assistant:dev Nov 2, 2023
50 checks passed
@Shulyaka Shulyaka deleted the api_service_timeout branch November 2, 2023 12:41
@bdraco
Copy link
Member

bdraco commented Nov 2, 2023

Thanks @Shulyaka @MartinHjelmare

@Shulyaka
Copy link
Contributor Author

Shulyaka commented Nov 2, 2023

Thanks for the review!

@github-actions github-actions bot locked and limited conversation to collaborators Nov 3, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Automation is cancelled on API client disconnect
4 participants