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

Commit

Permalink
Fix issue with never-ending install retries
Browse files Browse the repository at this point in the history
As backend sends empty director targets in some unexpected situations,
we've implemented a client-side mitigation in
02deeb5.

One unwanted side-effect is that after a failed installation, we'll keep
taking into account the targets containing the new version, hence
retrying installations in a loop until the backend asks to install
something new.

Second fix is to drop director targets after installation end, until
we've come to an agreement on a proper solution on both sides.

Signed-off-by: Laurent Bonnans <laurent.bonnans@here.com>
  • Loading branch information
lbonn committed Apr 24, 2019
1 parent a1d8f1b commit 6d6a98e
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/libaktualizr/primary/sotauptaneclient.cc
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ void SotaUptaneClient::finalizeAfterReboot() {

computeDeviceInstallationResult(nullptr, correlation_id);
putManifestSimple();
director_repo.dropLatest(*storage); // fix for OTA-2587, listen to backend again after end of install
} else {
// nothing found on primary
LOG_ERROR << "Expected reboot after update on primary but no update found";
Expand Down Expand Up @@ -828,6 +829,10 @@ result::Install SotaUptaneClient::uptaneInstall(const std::vector<Uptane::Target
computeDeviceInstallationResult(&result.dev_report, correlation_id);
sendEvent<event::AllInstallsComplete>(result);

if (result.dev_report.result_code != data::ResultCode::Numeric::kNeedCompletion) {
director_repo.dropLatest(*storage); // fix for OTA-2587, listen to backend again after end of install
}

return result;
}

Expand Down
5 changes: 5 additions & 0 deletions src/libaktualizr/uptane/directorrepository.cc
Original file line number Diff line number Diff line change
Expand Up @@ -150,4 +150,9 @@ bool DirectorRepository::updateMeta(INvStorage& storage, Fetcher& fetcher) {
return true;
}

void DirectorRepository::dropLatest(INvStorage& storage) {
storage.clearNonRootMeta(RepositoryType::Director());
latest_targets.clear();
}

} // namespace Uptane
1 change: 1 addition & 0 deletions src/libaktualizr/uptane/directorrepository.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class DirectorRepository : public RepositoryCommon {
// a non-empty list.
bool usePreviousTargets() const { return !targets.targets.empty() && latest_targets.targets.empty(); }
bool checkMetaOffline(INvStorage& storage);
void dropLatest(INvStorage& storage);

Exception getLastException() const { return last_exception; }
bool updateMeta(INvStorage& storage, Fetcher& fetcher);
Expand Down
6 changes: 6 additions & 0 deletions src/libaktualizr/uptane/tuf.h
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,12 @@ class Targets : public MetaWithKeys {
return version_ == rhs.version() && expiry_ == rhs.expiry() && targets == rhs.targets;
}
const std::string &correlation_id() const { return correlation_id_; }
void clear() {
targets.clear();
delegated_role_names_.clear();
paths_for_role_.clear();
terminating_role_.clear();
}

std::vector<Uptane::Target> targets;
std::vector<std::string> delegated_role_names_;
Expand Down

0 comments on commit 6d6a98e

Please sign in to comment.