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

Report failed downloads in an installation report. #1301

Merged
merged 5 commits into from
Aug 21, 2019

Conversation

pattivacek
Copy link
Collaborator

@pattivacek pattivacek commented Aug 19, 2019

This should inform the Director that the update failed.

This appears to fix the bug, but it is not perfect:

  1. There is no test, because we don't have a way to fake a download failure. It's probably doable with libfiu and the fake package manager, though. This is now covered by tests.
  2. There is the same problem with empty targets metadata that occurs with installation failure. It could be has been handled the same way, although despite that I don't like the solution of dropping metadata.
  3. The installation report does not contain any information about how, why, or which download failed. That could be improved if anyone wants to see that.

We might want to consider merging testing and merging this as is anyway just to get the fix out the door, but further consideration is necessary to address the above issues.

@pattivacek pattivacek force-pushed the fix/OTA-3169/install-report-failed-download branch from 1d59acf to affb28f Compare August 19, 2019 09:55
@pattivacek
Copy link
Collaborator Author

I brought over f6a5bd5 from #1296 and did the same style of Targets metadata dropping to address issue # 2 despite that I really don't like that solution.

@lbonn
Copy link
Contributor

lbonn commented Aug 19, 2019

There is no test, because we don't have a way to fake a download failure. It's probably doable with libfiu and the fake package manager, though.

Don't we just need to fake some http error code with HttpFake or some or our python http scripts?

@codecov-io
Copy link

codecov-io commented Aug 19, 2019

Codecov Report

Merging #1301 into master will decrease coverage by 0.07%.
The diff coverage is 96.66%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1301      +/-   ##
==========================================
- Coverage   79.05%   78.97%   -0.08%     
==========================================
  Files         178      178              
  Lines       10475    10494      +19     
==========================================
+ Hits         8281     8288       +7     
- Misses       2194     2206      +12
Impacted Files Coverage Δ
src/libaktualizr/utilities/types.cc 68.75% <ø> (ø) ⬆️
src/libaktualizr/utilities/types.h 83.92% <ø> (ø) ⬆️
.../libaktualizr/package_manager/packagemanagerfake.h 100% <ø> (ø) ⬆️
src/libaktualizr/primary/sotauptaneclient.cc 91.59% <100%> (-0.53%) ⬇️
...libaktualizr/package_manager/packagemanagerfake.cc 91.22% <100%> (+1.43%) ⬆️
src/libaktualizr/utilities/fault_injection.h 94.87% <80%> (-2.19%) ⬇️
src/libaktualizr/storage/sqlstorage_base.h 60% <0%> (-40%) ⬇️
src/libaktualizr/storage/sqlstorage_base.cc 74.32% <0%> (-4.06%) ⬇️
src/libaktualizr-posix/ipuptanesecondary.cc 82.66% <0%> (-4%) ⬇️
src/libaktualizr/uptane/directorrepository.cc 95.71% <0%> (-1.43%) ⬇️
... and 5 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 7971998...636acdb. Read the comment docs.

@pattivacek
Copy link
Collaborator Author

Don't we just need to fake some http error code with HttpFake or some or our python http scripts?

Oooh, nice idea. I was already halfway through setting up libfiu. I'll take that under consideration as well.

@pattivacek
Copy link
Collaborator Author

Fixed with tests using libfiu after all. It wasn't hard and the additional power is nice to have.

@simao
Copy link

simao commented Aug 19, 2019

This should inform the Director that the update failed.

This appears to fix the bug, but it is not perfect:

1. ~There is no test, because we don't have a way to fake a download failure. It's probably doable with libfiu and the fake package manager, though.~ This is now covered by tests.

2. There is the same problem with empty targets metadata that occurs with installation failure. It ~could be~ has been handled the same way, ~although~ despite that I don't like the solution of dropping metadata.

3. The installation report does not contain any information about how, why, or which download failed. That could be improved if anyone wants to see that.

What do you mean here? director would need at least the correlation id to make this work..

We might want to consider merging testing and merging this as is anyway just to get the fix out the door, but further consideration is necessary to address the above issues.

@pattivacek
Copy link
Collaborator Author

What do you mean here? director would need at least the correlation id to make this work..

Correlation ID is included. I just mean the error code/message is fairly generic. I've tested manually and it works, but the UI says:

Result code DOWNLOAD_FAILED
Target download failed

This should inform the Director that the update failed.

Signed-off-by: Patrick Vacek <patrickvacek@gmail.com>
Otherwise this prevents being able to split updates into multiple
individual calls to the Install API call.

This still isn't my favorite fix for this problem, but in the short
term, it's an improvement.

Signed-off-by: Patrick Vacek <patrickvacek@gmail.com>
This is not an ideal solution! This makes it impossible to retry
downloading via the API without setting up another update in the
Director and rechecking for updates.

Signed-off-by: Patrick Vacek <patrickvacek@gmail.com>
Signed-off-by: Patrick Vacek <patrickvacek@gmail.com>
Signed-off-by: Patrick Vacek <patrickvacek@gmail.com>
@pattivacek pattivacek force-pushed the fix/OTA-3169/install-report-failed-download branch from adbc70f to 636acdb Compare August 20, 2019 12:50
Copy link

@Raigi Raigi left a comment

Choose a reason for hiding this comment

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

Tests:

  1. Device is not stuck after failed download - ok
  2. Device can install new updates after failed download - ok
  3. Creating devices and installing updates on them - ok

@pattivacek pattivacek merged commit 38325b9 into master Aug 21, 2019
@pattivacek pattivacek deleted the fix/OTA-3169/install-report-failed-download branch August 21, 2019 11:30
// Store installation report to inform Director of the download failure.
const std::string &correlation_id = director_repo.getCorrelationId();
data::InstallationResult device_installation_result =
data::InstallationResult(data::ResultCode::Numeric::kDownloadFailed, "Target download failed");
Copy link
Collaborator

Choose a reason for hiding this comment

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

As far as I understand the mechanism of cancelling/removing of the new targets at Director is a sending manifest to it with a negative installation result in case if all targets downloads fails ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

If I'm understanding you correctly, yes. If we send an installation report with a failure code, the Director will respond by identifying the installation as a failure, and subsequent Targets metadata will be empty (to indicate that the device should take no further action, i.e. not retry until explicitly told to do so). Let me know if that doesn't make sense or you have further questions.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants