-
Notifications
You must be signed in to change notification settings - Fork 60
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1267 +/- ##
==========================================
- Coverage 79.7% 79.57% -0.13%
==========================================
Files 173 173
Lines 10301 10320 +19
==========================================
+ Hits 8210 8212 +2
- Misses 2091 2108 +17
Continue to review full report at Codecov.
|
if (!url.empty()) { | ||
director_targets["targets"][target_name]["custom"]["uri"] = url; | ||
} else { | ||
director_targets["targets"][target_name]["custom"].removeMember("uri"); |
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.
Why a nested structure is required for the custom URI, not just a single attribute of target_name
, to paraphrase why ["custom"]["uri"] not just ["custom-uri"] or there is/are other attribute(s) of ["custom"] ?
Perhaps, just the whole "custom" can be removed ?
Oh, I see another attribute of custom
, it's "targetFormat", but still not clear why not remove the whole "custom" element.
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 is/are other attribute(s) of ["custom"] ?
Precisely. It's following the recommendation of Uptane to keep implementation-specific custom metadata in a custom
section.
@@ -37,11 +37,14 @@ void ImageRepo::addBinaryImage(const boost::filesystem::path &image_path, const | |||
target["hashes"]["sha256"] = boost::algorithm::to_lower_copy(boost::algorithm::hex(Crypto::sha256digest(image))); |
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 know that it's not related to this specific PR, but loading the whole file/image into memory doesn't look like optimal way to calculate file hash, unless aktualizr-repo is used just for testing purposes.
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.
Valid point. This is not what we do in libaktualizr itself, but aktualizr-repo is really just for testing, so it's not so critical.
for (auto it = targets.cbegin(); it != targets.cend(); ++it) { | ||
auto res = downloadImage(*it, token); | ||
for (const auto &it : targets) { | ||
auto res = downloadImage(it, token); |
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.
for some reason downloadImage() passes a target object by value, maybe it makes sense to pass it by reference ?
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.
This was changed because the targets inside the vectors are modified with setUri()
and we probably don't want to change it in the vector that lives in the caller.
That's a bit annoying though, I would maybe suggest passing by const reference and making a copy inside the function so that it's more explicit. (+ a comment about that)
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 would maybe suggest passing by const reference and making a copy inside the function so that it's more explicit. (+ a comment about that)
Agreed, done.
for (auto it = targets.cbegin(); it != targets.cend(); ++it) { | ||
auto res = downloadImage(*it, token); | ||
for (const auto &it : targets) { | ||
auto res = downloadImage(it, token); | ||
if (res.first) { | ||
downloaded_targets.push_back(res.second); | ||
} |
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.
Why do we need to continue downloading if a current target image download fails, don't we consider a singe multi-target update as an atomic operation ?
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.
Not necessarily. That logic is still being worked out as far as I understand. That should be up to the user to decide what to do. For now, we attempt to download everything regardless of failures.
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.
Maybe, makes sense to make it configurable.
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.
Agreed. That requires some integration with the backend, though, and we haven't sorted out the details yet.
@@ -582,10 +587,9 @@ void SotaUptaneClient::reportResume() { | |||
report_queue->enqueue(std_::make_unique<DeviceResumedReport>(correlation_id)); | |||
} | |||
|
|||
std::pair<bool, Uptane::Target> SotaUptaneClient::downloadImage(Uptane::Target target, | |||
std::pair<bool, Uptane::Target> SotaUptaneClient::downloadImage(const Uptane::Target &target, |
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.
Oh, you did it here :)
@@ -41,8 +41,7 @@ class SotaUptaneClient { | |||
|
|||
void initialize(); | |||
void addNewSecondary(const std::shared_ptr<Uptane::SecondaryInterface> &sec); | |||
result::Download downloadImages(const std::vector<Uptane::Target> &targets, | |||
const api::FlowControlToken *token = nullptr); | |||
result::Download downloadImages(std::vector<Uptane::Target> targets, const api::FlowControlToken *token = nullptr); |
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.
Why not by reference, is it because of the move semantics ?
const api::FlowControlToken *token) { | ||
// Uptane step 4 - download all the images and verify them against the metadata (for OSTree - pull without | ||
// deploying) | ||
std::lock_guard<std::mutex> guard(download_mutex); | ||
result::Download result; | ||
std::vector<Uptane::Target> downloaded_targets; | ||
for (auto it = targets.cbegin(); it != targets.cend(); ++it) { | ||
auto images_target = findTargetInDelegationTree(*it); | ||
for (auto &it : targets) { |
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.
When using this style of for
, it makes it clearer to rename the variable to something other than it
, as it's not an iterator anymore.
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 call. Done.
URLs are not matched. If the Director provides one, we use that. If not, but the Image repository does, use that. Otherwise, leave it empty and use the default. Signed-off-by: Patrick Vacek <patrickvacek@gmail.com>
Necessary for creating custom URLs. Signed-off-by: Patrick Vacek <patrickvacek@gmail.com>
Signed-off-by: Patrick Vacek <patrickvacek@gmail.com>
Signed-off-by: Patrick Vacek <patrickvacek@gmail.com>
8236d1b
to
7b0c026
Compare
The most interesting part is in sotauptaneclient.cc, where if the custom URL is not set in the Director target metadata, we check if it is set in the Images repo target metadata and use that if it is.
A lot of the changes relate to aktualizr-repo, where I added parameters to set the custom URL.