-
Notifications
You must be signed in to change notification settings - Fork 44
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
Add option for detached HUP on start_os_update #378
base: master
Are you sure you want to change the base?
Conversation
This pull request sets up GitHub code scanning for this repository. Once the scans have completed and the checks have passed, the analysis results for this pull request branch will appear on this overview. Once you merge this pull request, the 'Security' tab will show more code scanning analysis results (for example, for the default branch). Depending on your configuration and choice of analysis tool, future pull requests will be annotated with code scanning analysis results. For more information about GitHub code scanning, check out the documentation. |
0b1c6ee
to
30af156
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First pass review. Have not tested operation yet.
00f8a99
to
0d3c654
Compare
@@ -1766,7 +1776,7 @@ def start_os_update(self, uuid_or_id: Union[str, int], target_os_version: str) - | |||
data = {"parameters": {"target_version": target_os_version}} | |||
|
|||
url_base = self.__config.get_all()["deviceUrlsBase"] | |||
action_api_version = self.__settings.get("device_actions_endpoint_version") | |||
action_api_version = "v2" if run_detached is True else self.__settings.get("device_actions_endpoint_version") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
action_api_version = "v2" if run_detached is True else self.__settings.get("device_actions_endpoint_version") | |
action_api_version = "v2" if run_detached else self.__settings.get("device_actions_endpoint_version") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
v2 is only for detached HUP at this point @otaviojacobi
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch on the "is True", @otaviojacobi . If the user happens to use runDetached="True", that still works with your change since the test now is for Truthiness. I'm a little surprised use of a string isn't type checked though since it's typed as Optional[bool]
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, the key thing here is to (similar to typescript) always think of the type system as best effort. There is only so much you can do on a dynamically typed languages (js/python) to avoid these mistakes. There is the argument of if someone does run_detatched="False"
it will still be truthy, however considering it defaults to False
I think someone messing with this parameter probably wants to run detatched
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can also always validate that it is either True
False
or None
and throw it otherwise so that we avoid all these sort of issues. I would defer if you want to go this route to you
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I actually like the strict checking best to remove the ambiguity.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense. Added below.
if not isinstance(run_detached, bool) and run_detached is not None:
raise ValueError(f"run_detached must be True, False, or None, got {type(run_detached)}: {run_detached}")
action_api_version = "v2" if run_detached is True else self.__settings.get("device_actions_endpoint_version")
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see why we need to allow the value to be None. We have a default value of False. How about:
if not isinstance(run_detached, bool):
raise ValueError(f"run_detached must be True or False, got {type(run_detached)}: {run_detached}")
action_api_version = "v2" if run_detached else self.__settings.get("device_actions_endpoint_version")
48c22db
to
c9e3d7d
Compare
Tested HUP against live device with and without Added a commit with some simple input tests on @jaomaloy if you can squash in my commit and fix the issue flagged by otaviojacoby, I'm happy to approve. Of course let me know if you have any concerns about the test I added. |
7db7935
to
b7df93c
Compare
This will call the v2 actions endpoint for resinhup which runs a detached version of HUP that increases HUP reliability on slow networks but will offer no status updates such as in_progress. Add tests for start_os_update as well. Change-type: minor
b7df93c
to
7ab93c0
Compare
This will call the v2 actions endpoint for resinhup which runs a detached version of HUP that increases HUP reliability on slow networks but will offer
no status updates such as in_progress.
Change-type: minor