Skip to content
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

Move CorrelationID up a level out of Target #108

Merged
merged 2 commits into from
May 18, 2024

Conversation

cajun-rat
Copy link
Collaborator

The Correlation ID logically belongs to a particular update that is assigned by the server, and not to a 'target', which is one of the things to be installed. Move the information about the current correlation id into the director, and explictly persist it in InvStorage.

Eventually I think we need to move torward a model where we have an explicit representation of an 'installation job'--including a correlation id--which persists over reboots. At the moment we infer this from the 'pending' flag for individual ECU installations.

@@ -1119,7 +1120,7 @@ void SQLStorage::saveInstalledVersion(const std::string& ecu_serial, const Uptan
auto statement = db.prepareStatement<std::string, int, int, int64_t>(
"UPDATE installed_versions SET correlation_id = ?, is_current = ?, is_pending = ?, was_installed = ? WHERE id "
"= ?;",
target.correlation_id(), static_cast<int>(update_mode == InstalledVersionUpdateMode::kCurrent),
correlation_id, static_cast<int>(update_mode == InstalledVersionUpdateMode::kCurrent),
Copy link
Collaborator

Choose a reason for hiding this comment

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

@detsch I think this change will break us, so we will need to adjust the fio's client (aktualizr-lite) to this change.

Copy link
Collaborator

@mike-sul mike-sul Apr 30, 2024

Choose a reason for hiding this comment

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

Also, it may lead to different correlation ID usage for the same target. For example, a client specifies corID-1 when storing a target as pending for the first time, and then the client, by mistake, may set corID-2 when updating the target status/mode to kCurrent.

Copy link
Collaborator

Choose a reason for hiding this comment

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

@cajun-rat Do we really need to set the correlation_id field if it's just an update of an existing record? I mean, do we need to update/change the correlation_id in this case at all, considering that only the is_* and was_* fields need to be updated?

cajun-rat added 2 commits May 9, 2024 18:54
The Correlation ID logically belongs to a particular update that
is assigned by the server, and not to a 'target', which is one of
the things to be installed. Move the information about the current
correlation id into the director, and explictly persist it in
InvStorage.

Eventually I think we need to move torward a model where we have
an explicit representation of an 'installation job'--including a
correlation id--which persists over reboots. At the moment we infer this
from the 'pending' flag for individual ECU installations.
This avoids a ", nullptr)" everywhere. See discussion in
uptane/aktualizr#108

This is implemented as a non-virtual member function on the base class, because
mixing default parameters and virtual calls is dangerous.
@cajun-rat cajun-rat requested a review from mike-sul May 14, 2024 17:03
@cajun-rat cajun-rat merged commit 3662ed0 into uptane:master May 18, 2024
5 checks passed
@cajun-rat
Copy link
Collaborator Author

Thank you @mike-sul !

@cajun-rat cajun-rat deleted the correlation-id branch May 18, 2024 11:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants