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

Do not provision if primary times out while connecting to secon… #1491

Merged
merged 4 commits into from
Dec 16, 2019

Conversation

lbonn
Copy link
Contributor

@lbonn lbonn commented Dec 16, 2019

No description provided.

Move the flush report log to trace.

Signed-off-by: Laurent Bonnans <laurent.bonnans@here.com>
Signed-off-by: Laurent Bonnans <laurent.bonnans@here.com>
Signed-off-by: Laurent Bonnans <laurent.bonnans@here.com>
If a secondary connection times out before the device was provisioned,
exit early so that partially up devices are not provisioned in an
invalid state.

Already provisioned devices will still start even if some secondaries
are missing.

Signed-off-by: Laurent Bonnans <laurent.bonnans@here.com>
@lbonn
Copy link
Contributor Author

lbonn commented Dec 16, 2019

Unfortunately, an update of doxygen seems to have broken the docs generation. I'll merge anyway because this was already broken.

We'll have to fix that in another PR quite soon.

@lbonn lbonn changed the title Do not provision if primary times out while connecting to secondaries Do not provision if primary times out while connecting to secon… Dec 16, 2019
@lbonn lbonn merged commit dae4144 into master Dec 16, 2019
@lbonn lbonn deleted the feat/OTA-4114/no-sec-no-prov branch December 16, 2019 17:11
@@ -122,11 +122,14 @@ int main(int argc, char *argv[]) {
conn = aktualizr.SetSignalHandler(f_cb);

if (!config.uptane.secondary_config_file.empty()) {
if (boost::filesystem::exists(config.uptane.secondary_config_file)) {
try {
Copy link
Collaborator

Choose a reason for hiding this comment

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

This try/catch was not necessary as this code is already wrapped by the outter try/catch.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The exception is ignored if aktualizr.IsRegistered(), I think we cannot rely on the outer try/catch in this case.

Copy link
Collaborator

Choose a reason for hiding this comment

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

ok. I see, this is for the use case when Primary and Secondaries are trying to connect to each other after a device has been already provisioned, e.g. just a device and/or aktualizr reboot. I think, it might be not an optimal strategy to exit the connection procedure on a first failure if a device has been already registered, but, I suppose, it's not so important, adding secondaries dynamically is more important or not trying to connect to them on a startup at all if a device already registered.

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 think, it might be not an optimal strategy to exit the connection procedure on a first failure if a device has been already registered, but, I suppose, it's not so important, adding secondaries dynamically is more important or not trying to connect to them on a startup at all if a device already registered.

That's a good point indeed... But I remember I chose this simple solution at first because right now, we can't really do better than what the IP secondaries config parser gives us and it handles all IP secondaries at once.

LOG_WARNING << "The specified secondary config file does not exist: " << config.uptane.secondary_config_file
<< "\nProceed further without secondary(ies)";
} catch (const std::exception &e) {
LOG_ERROR << "Secondary initialization failed";
Copy link
Collaborator

Choose a reason for hiding this comment

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

I would add e.what() to the log message so we see more details of the secondary provisioning failure.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In the current version, e.what() is logged in initSecondaries() but I agree this is maybe not really clear.
initSecondaries() could also log these errors and return a boolean, to simplify the call site in main.cc.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I see, makes sense, it's up to you whether to terminate exceptions in initSecondaries and return boolean or rethrow them.

@@ -82,8 +81,10 @@ class SecondaryWaiter {
timer_.async_wait([&](const boost::system::error_code& error_code) {
if (!!error_code) {
LOG_ERROR << "Wait for secondaries has failed: " << error_code;
throw std::runtime_error("Error while waiting for secondary");
Copy link
Collaborator

Choose a reason for hiding this comment

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

As an alternative to these two 'throws' just one throw can be added at the end of createIPSecondaries().

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

3 participants