Skip to content
This repository has been archived by the owner on May 21, 2024. It is now read-only.

Implement Abort() API call #1122

Merged
merged 8 commits into from
Mar 22, 2019
Merged

Implement Abort() API call #1122

merged 8 commits into from
Mar 22, 2019

Conversation

eu-siemann
Copy link
Contributor

The main idea of this PR is to provide an ability to abort ongoing downloads and reset the queue to an empty state. It also removes Shutdown() call, which was bringing an Aktualizr object to an unusable state and fixes the issue with a possible race condition between Pause()/Resume() calls.
The PR still lacks tests for the Abort() functionality and more proper handling of an abort event in fetcher and uptane client.
At least it doesn't seem to break existing functionality and I feel that it's already getting quite big,
so it would be great if you could have a look at it next week.

@codecov-io
Copy link

codecov-io commented Mar 1, 2019

Codecov Report

Merging #1122 into master will decrease coverage by 0.06%.
The diff coverage is 92.25%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1122      +/-   ##
==========================================
- Coverage   77.82%   77.75%   -0.07%     
==========================================
  Files         167      169       +2     
  Lines       10001    10004       +3     
==========================================
- Hits         7783     7779       -4     
- Misses       2218     2225       +7
Impacted Files Coverage Δ
src/libaktualizr/primary/aktualizr.h 100% <ø> (ø) ⬆️
src/libaktualizr/package_manager/ostreemanager.h 100% <ø> (ø) ⬆️
src/libaktualizr/primary/sotauptaneclient.h 100% <ø> (ø) ⬆️
src/libaktualizr/http/httpclient.h 100% <ø> (ø) ⬆️
src/hmi_stub/main.cc 0% <0%> (ø) ⬆️
src/libaktualizr/utilities/apiqueue.h 100% <100%> (ø)
src/libaktualizr/http/httpinterface.h 100% <100%> (ø) ⬆️
src/libaktualizr/uptane/fetcher.h 77.77% <100%> (-6.23%) ⬇️
src/libaktualizr/http/httpclient.cc 91.92% <100%> (+0.2%) ⬆️
src/sota_tools/request_pool.cc 91.48% <100%> (+0.09%) ⬆️
... and 10 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f6202e4...61d2f9b. Read the comment docs.

Copy link
Collaborator

@pattivacek pattivacek left a comment

Choose a reason for hiding this comment

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

I got interrupted, will continue reviewing tomorrow.

tests/sota_tools/treehub_server.py Outdated Show resolved Hide resolved
tests/sota_tools/repo/refs/heads/master Outdated Show resolved Hide resolved
Copy link
Collaborator

@pattivacek pattivacek left a comment

Choose a reason for hiding this comment

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

Did a more thorough review today. Mostly looks fine. So the point of the token is to have one object to represent the API state, right? For some reason it took me a minute to make sense out of that, but it seems fine to me now. I still haven't played around with this, but the easiest way to do that is with hmi_stub, which is lacking the Abort function. Once that is there, I'd like to try it out and make sure it behaves as expected.

src/libaktualizr/utilities/apiqueue.cc Show resolved Hide resolved
src/libaktualizr/primary/aktualizr.h Show resolved Hide resolved
* but the Aktualizr will remain in the paused state. To continue execution
* at some later point one needs to call Resume().
*/
void Abort();
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is it worth mentioning that the only command that can be interrupted while in progress is downloading?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not so sure if it's worth mentioning here. It's unlikely, but what if we decide to abort e.g. CheckForUpdates at some later point?

Copy link
Collaborator

Choose a reason for hiding this comment

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

It's not strictly necessary, but when I read "Requests the currently running command to abort", that leads me to assume that all commands can be aborted while in progress, and that isn't true. If it later becomes true, or even if just one more command is abortable, we can change the doc here again to reflect that as necessary.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agreed, sounds confusing. I'll rephrase it.

src/hmi_stub/main.cc Outdated Show resolved Hide resolved
@eu-siemann
Copy link
Contributor Author

Thanks for the review, @patrickvacek! I'll fix the mentioned issues soon.
The idea of the token is to make pause/cancellation more generic, so we can reuse it in other tasks if we want to, and, more important, to control the execution flow from one place, so we avoid race conditions.

@pattivacek
Copy link
Collaborator

The idea of the token is to make pause/cancellation more generic, so we can reuse it in other tasks if we want to, and, more important, to control the execution flow from one place, so we avoid race conditions.

Great, that was my understanding. That is perfect. The abstraction was confusing to me at first, but it is obviously superior to me now that I understand it better.

@eu-siemann eu-siemann force-pushed the feat/abort branch 4 times, most recently from 23a7b00 to a0be831 Compare March 20, 2019 15:25
doanac pushed a commit to doanac/aktualizr that referenced this pull request Mar 20, 2019
Squashed based on commit: 9076faf

advancedtelematic#1122

Signed-off-by: Eugene Smirnov <evgenii.smirnov@here.com>
@eu-siemann eu-siemann force-pushed the feat/abort branch 6 times, most recently from 9715ed2 to 402be5d Compare March 21, 2019 16:47
Copy link
Contributor

@lbonn lbonn left a comment

Choose a reason for hiding this comment

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

Cool!

Copy link
Collaborator

@pattivacek pattivacek left a comment

Choose a reason for hiding this comment

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

Lot of awesome work here!

self.send_response_only(200)
else:
self.send_response_only(404)
self.end_headers()
Copy link
Collaborator

Choose a reason for hiding this comment

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

do_HEAD looks to be duplicated.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oops, thanks!

tests/sota_tools/test-garage-deploy-dry-run Show resolved Hide resolved
try:
httpd.serve_forever()
except KeyboardInterrupt as k:
with ExitStack() as stack:
Copy link
Collaborator

Choose a reason for hiding this comment

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

What benefit does the ExitStack and sig_handler provide? Just curious, not doubting. :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sys.exit(0) in signal handler will raise a SystemExit exception, which will unwind the ExitStack cleaning up the tmp directory

Signed-off-by: Eugene Smirnov <evgenii.smirnov@here.com>
Eugene Smirnov added 2 commits March 22, 2019 13:52
Signed-off-by: Eugene Smirnov <evgenii.smirnov@here.com>
Signed-off-by: Eugene Smirnov <evgenii.smirnov@here.com>
Eugene Smirnov added 5 commits March 22, 2019 13:55
Signed-off-by: Eugene Smirnov <evgenii.smirnov@here.com>
Signed-off-by: Eugene Smirnov <evgenii.smirnov@here.com>
Signed-off-by: Eugene Smirnov <evgenii.smirnov@here.com>
Signed-off-by: Eugene Smirnov <evgenii.smirnov@here.com>
Signed-off-by: Eugene Smirnov <evgenii.smirnov@here.com>
@eu-siemann eu-siemann merged commit 6254e96 into master Mar 22, 2019
@eu-siemann eu-siemann deleted the feat/abort branch March 26, 2019 10:50
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.

4 participants