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

Adjust some log in aktualizr_secondary #1609

Merged
merged 2 commits into from
Mar 24, 2020

Conversation

xcheng-here
Copy link
Contributor

No description provided.

@xcheng-here xcheng-here force-pushed the fix/OTA-4389/aktualizr-secondary_logging branch from 9654cbe to f2e276f Compare March 20, 2020 11:03
@xcheng-here
Copy link
Contributor Author

I haven't modify below 3 lines log:
Could not find primary ecu serial, defaulting to empty serial: unknown error
Could not find hardware_id for serial : unknown error
No valid and pending Director targets to be applied

The reason is the first 2 lines are from libaktualizr, describing the status of database, so if we want it don't output for secondary, it means maybe we need to modify some interfaces of libaktualizr. I think maybe we don't want to modify so much to remove those 2 lines log.
The third one is from aktualizr_secondary, but the problem is similar as above, it's describing the status of database, I'm not sure whether we really want to add code to check if it's the first time launching.

@codecov-io
Copy link

codecov-io commented Mar 20, 2020

Codecov Report

Merging #1609 into master will decrease coverage by 0.06%.
The diff coverage is 87.5%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1609      +/-   ##
==========================================
- Coverage   82.54%   82.47%   -0.07%     
==========================================
  Files         189      189              
  Lines       11991    11996       +5     
==========================================
- Hits         9898     9894       -4     
- Misses       2093     2102       +9
Impacted Files Coverage Δ
src/aktualizr_secondary/aktualizr_secondary.cc 77.44% <100%> (+0.69%) ⬆️
src/aktualizr_secondary/secondary_tcp_server.cc 90% <85%> (+0.07%) ⬆️
src/libaktualizr/storage/sqlstorage_base.h 60% <0%> (-40%) ⬇️
src/libaktualizr/storage/sql_utils.h 85.89% <0%> (-1.29%) ⬇️
src/libaktualizr/crypto/crypto.cc 85.21% <0%> (-0.78%) ⬇️
src/libaktualizr/storage/sqlstorage_base.cc 75.83% <0%> (-0.68%) ⬇️
src/libaktualizr/storage/sqlstorage.cc 77.4% <0%> (-0.29%) ⬇️

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 fdafed8...f02c298. Read the comment docs.

Copy link
Collaborator

@pattivacek pattivacek left a comment

Choose a reason for hiding this comment

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

The reason is the first 2 lines are from libaktualizr, describing the status of database, so if we want it don't output for secondary, it means maybe we need to modify some interfaces of libaktualizr. I think maybe we don't want to modify so much to remove those 2 lines log.

Fair point, but actually the Primary has the same problem.

The third one is from aktualizr_secondary, but the problem is similar as above, it's describing the status of database, I'm not sure whether we really want to add code to check if it's the first time launching.

How hard is it to fix this (and the other two)? If it requires a bunch of work, it might not be worth it, but it seems like we ought to be able to do better here.

@@ -101,6 +101,7 @@ bool AktualizrSecondary::sendFirmware(const std::string& firmware) {
return false;
}

LOG_INFO << "Download successful.";
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you add the name of the target?

src/aktualizr_secondary/aktualizr_secondary.cc Outdated Show resolved Hide resolved
@xcheng-here xcheng-here force-pushed the fix/OTA-4389/aktualizr-secondary_logging branch from f2e276f to 6db9c20 Compare March 23, 2020 06:23
@xcheng-here
Copy link
Contributor Author

How hard is it to fix this (and the other two)? If it requires a bunch of work, it might not be worth it, but it seems like we ought to be able to do better here.

IMHO, it's doable but maybe not worthy because those log also indicating some invalid status for both of primary and secondary. If I don't want to put some ugly code into our source, I will need to change some interfaces and maybe add something into database.

Copy link
Collaborator

@pattivacek pattivacek left a comment

Choose a reason for hiding this comment

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

IMHO, it's doable but maybe not worthy because those log also indicating some invalid status for both of primary and secondary. If I don't want to put some ugly code into our source, I will need to change some interfaces and maybe add something into database.

Fair enough. I'll look into it some more and think about it, but it doesn't have to block the rest of this.

@@ -146,14 +146,15 @@ bool SecondaryTcpServer::HandleOneConnection(int socket) {
r->result = ok ? AKInstallationResult_success : AKInstallationResult_failure;
} break;
case AKIpUptaneMes_PR_sendFirmwareReq: {
LOG_DEBUG << "Received sendFirmwareReq from Primary.";
Copy link
Collaborator

Choose a reason for hiding this comment

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

Actually, this should probably be INFO level.

} break;
case AKIpUptaneMes_PR_installReq: {
LOG_DEBUG << "Received installReq from Primary.";
Copy link
Collaborator

Choose a reason for hiding this comment

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

This should also be INFO.

@pattivacek
Copy link
Collaborator

No valid and pending Director targets to be applied

@mike-sul Can you actually explain why this message is printed? I also note that after an update has been installed with aktualizr-secondary, I see "There is a valid and pending Director target to be applied" even after rebooting. I think there's a problem with how we are checking the Director metadata here. We are doing the right thing, but the logging is wrong. director_repo_.checkMetaOffline should only fail if there is no metadata, and then we have to do additional work to determine if there are pending Targets to apply.

@ghost
Copy link

ghost commented Mar 23, 2020

Can you actually explain why this message is printed?

To inform that there is no target (or target metadata) verification and installation of which is currently in progress.

director_repo_.checkMetaOffline should only fail if there is no metadata, and then we have to do additional work to determine if there are pending Targets to apply.

I agree with this statement and I think the code is inline with it. Just after initPendingTargetIfAny() the following is called if (hasPendingUpdate()) {.

@pattivacek
Copy link
Collaborator

Can you actually explain why this message is printed?

To inform that there is no target (or target metadata) verification and installation of which is currently in progress.

director_repo_.checkMetaOffline should only fail if there is no metadata, and then we have to do additional work to determine if there are pending Targets to apply.

I agree with this statement and I think the code is inline with it. Just after initPendingTargetIfAny() the following is called if (hasPendingUpdate()) {.

The code works correctly, but I think the logging is misleading. First, director_repo_.checkMetaOffline failing or succeeding does not tell us anything about whether there are updates to install or apply. It only tells us whether we have valid metadata in the database. Second, the message "There is a valid and pending Director target to be applied" appears every time the Secondary is started even after the target has been applied.

@ghost
Copy link

ghost commented Mar 23, 2020

Can you actually explain why this message is printed?

To inform that there is no target (or target metadata) verification and installation of which is currently in progress.

director_repo_.checkMetaOffline should only fail if there is no metadata, and then we have to do additional work to determine if there are pending Targets to apply.

I agree with this statement and I think the code is inline with it. Just after initPendingTargetIfAny() the following is called if (hasPendingUpdate()) {.

The code works correctly, but I think the logging is misleading. First, director_repo_.checkMetaOffline failing or succeeding does not tell us anything about whether there are updates to install or apply. It only tells us whether we have valid metadata in the database. Second, the message "There is a valid and pending Director target to be applied" appears every time the Secondary is started even after the target has been applied.

Oh, now I understand your point. Yes, the first log message is misleading for sure, it should be changed or removed at all.

The second one should be OK provided that the metadata are removed from DB just after successful installation, at least that was my plan. So, if the metadata are removed just after successful installation then this if (!director_repo_.checkMetaOffline(*storage_)) should be true and LOG_INFO << "There is a valid and pending Director target to be applied"; is never called.

@xcheng-here xcheng-here force-pushed the fix/OTA-4389/aktualizr-secondary_logging branch from 6db9c20 to 1faa65b Compare March 23, 2020 10:09
@pattivacek
Copy link
Collaborator

IMHO, it's doable but maybe not worthy because those log also indicating some invalid status for both of primary and secondary. If I don't want to put some ugly code into our source, I will need to change some interfaces and maybe add something into database.

Fair enough. I'll look into it some more and think about it, but it doesn't have to block the rest of this.

I've addressed these two issues in #1611.

@xcheng-here xcheng-here force-pushed the fix/OTA-4389/aktualizr-secondary_logging branch from d90d360 to f846587 Compare March 23, 2020 12:31
mike-sul
mike-sul previously approved these changes Mar 24, 2020
Co-Authored-By: Patrick Vacek <patrickvacek@gmail.com>
Signed-off-by: cheng.xiang <ext-cheng.xiang@here.com>
@pattivacek pattivacek force-pushed the fix/OTA-4389/aktualizr-secondary_logging branch from 2d87ab5 to 4e9a0f7 Compare March 24, 2020 08:17
Read and print Uptane metadata in the expected order. Be clear about
connection with the Primary. Don't print a message about a pending
target unless there really is one to apply.

Signed-off-by: Patrick Vacek <patrickvacek@gmail.com>
@pattivacek
Copy link
Collaborator

The second one should be OK provided that the metadata are removed from DB just after successful installation, at least that was my plan.

The metadata is not removed from the database, and it should not be. I've pushed another commit that address this issue as well as a few other minor things that were bugging me.

@mike-sul
Copy link
Collaborator

The metadata is not removed from the database, and it should not be

What for do we need to keep it in the DB after a target update has been installed and applied?

@mike-sul
Copy link
Collaborator

The metadata is not removed from the database, and it should not be

What for do we need to keep it in the DB after a target update has been installed and applied?

Got already answer to it :)

Copy link
Collaborator

@pattivacek pattivacek left a comment

Choose a reason for hiding this comment

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

LGTM but we should probably get an approval from someone that didn't write one of the commits.

@pattivacek pattivacek merged commit 4d9b41e into master Mar 24, 2020
@pattivacek pattivacek deleted the fix/OTA-4389/aktualizr-secondary_logging branch March 24, 2020 10:01
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

4 participants