-
Notifications
You must be signed in to change notification settings - Fork 60
Conversation
@@ -164,6 +175,12 @@ void SecondaryTcpServer::HandleOneConnection(int socket) { | |||
} else { | |||
LOG_DEBUG << "Not sending a response to message " << msg->present(); | |||
} | |||
|
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 don't think that there is much reason in calling stop
here as it's mainly intended for the server stooping from another thread. Perhaps just returning a bool/int from HandleOneConnection() and handling in the while loop would be slightly better (you could set keep_running_ = false; or just break
directly there).
Also, the name may_reboot
a bit confusing, it's rather want reboot
or require reboot
, just minor :)
Codecov Report
@@ Coverage Diff @@
## master #1578 +/- ##
==========================================
- Coverage 82.35% 82.32% -0.03%
==========================================
Files 189 189
Lines 11851 11872 +21
==========================================
+ Hits 9760 9774 +14
- Misses 2091 2098 +7
Continue to review full report at Codecov.
|
tcp_server.run(); | ||
|
||
if (tcp_server.exit_reason() == SecondaryTcpServer::ExitReason::kRebootNeeded) { | ||
secondary->completeInstall(); |
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.
How can we guarantee here that the TCP/IP stack has sent all data from its internal buffers before the reboot is called?
It looks like there is missing connection shutdown in HandleOneConnection() and connection socket closing in run().
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've added a RAII socket in run()
.
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.
Looks great! I think it's important to make sure that all data from TCP/IP internal buffers are sent through wire before reboot takes place. IMHO, Just shutdown and close a connection socket + wait a bit before reboot.
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.
Thankfully doesn't look quite as bad as we feared. How can we test this?
SecondaryTcpServer(Uptane::SecondaryInterface& secondary, const std::string& primary_ip, in_port_t primary_port, | ||
in_port_t port = 0); | ||
enum class ExitReason { | ||
kNA, |
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.
"NA" for "not applicable"? Minor, but maybe worth spelling out.
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've also renamed Other to Unknown, more consistent with other enums we have.
ac4f0c1
to
3fda90b
Compare
There should be something to do with ipsecondary_test.py. |
|
||
if (need_reboot && reboot_after_install_) { | ||
exit_reason_ = ExitReason::kRebootNeeded; | ||
return false; |
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.
As an option exit_reason_
can be returned from HandleOneConnection to run() and run() in turn can return the exit status to a caller/client so no class member is required to store an exit reason and no additional call for a client to get this exit reason. But it' really minor and not important just an alternative.
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.
LGTM, I just think that it would be great to add some test(s) for this functionality.
It's only used for tests, the equivalent case can be handled in the main one. Signed-off-by: Laurent Bonnans <laurent.bonnans@here.com>
Signed-off-by: Laurent Bonnans <laurent.bonnans@here.com>
It was not explicitely closed! Signed-off-by: Laurent Bonnans <laurent.bonnans@here.com>
"ON" is not the only way to get a true value from CMake Signed-off-by: Laurent Bonnans <laurent.bonnans@here.com>
3fda90b
to
515d858
Compare
Now comes with a test. |
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.
LGTM.
@with_sysroot() | ||
@with_secondary(start=False, output_logs=False, force_reboot=True) | ||
@with_aktualizr(start=False, run_mode='once', output_logs=True) | ||
def test_secondary_ostree_reboot(uptane_repo, secondary, aktualizr, treehub, sysroot, director, **kwargs): |
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.
Do we have a negative test for this? (Same goes for the Primary, actually.) Less important, but just curious.
with aktualizr: | ||
aktualizr.wait_for_completion() | ||
|
||
if not director.get_install_result(): |
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 think it makes sense to add checking if what is currently installed on Secondary is what we expect
something like this `if target_rev != aktualizr.get_current_image_info(secondary.id):
Signed-off-by: Laurent Bonnans <laurent.bonnans@here.com>
Signed-off-by: Laurent Bonnans <laurent.bonnans@here.com>
515d858
to
9689bbb
Compare
add_test(NAME test_ip_secondary | ||
COMMAND ${PROJECT_SOURCE_DIR}/tests/ipsecondary_test.py | ||
--build-dir ${PROJECT_BINARY_DIR} --src-dir ${PROJECT_SOURCE_DIR} --ostree ${BUILD_OSTREE}) | ||
--build-dir ${PROJECT_BINARY_DIR} --src-dir ${PROJECT_SOURCE_DIR} ${TEST_IPSEC_ARGS}) |
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.
What ${TEST_IPSEC_ARGS}
is for?
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.
It's here to set or not set --ostree
as an argument to the script, as using ${BUILD_OSTREE}
in the python script would force us to reimplement CMake boolean logic:
True if the constant is 1, ON, YES, TRUE, Y, or a non-zero number. False if the constant is 0, OFF, NO, FALSE, N, IGNORE, NOTFOUND, the empty string, or ends in the suffix -NOTFOUND. Named boolean constants are case-insensitive. If the argument is not one of these specific constants, it is treated as a variable or string and the following signature is used.
https://cmake.org/cmake/help/latest/command/if.html#command:if
I had the problem that the tests would not run because I configured my build directory with -DBUILD_OSTREE=on
instead of -DBUILD_OSTREE=ON
.
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.
OK, I got it.
Tested manually on qemu.