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

ostree update on IP secondary (reworked) #1518

Merged
merged 11 commits into from
Jan 17, 2020
Merged
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@ Our versioning scheme is `YEAR.N` where `N` is incremented whenever a new releas

## [??? (unreleased)]

### Added

- Basic file update on IP Secondaries: [PR](https://github.com/advancedtelematic/aktualizr/pull/1518)
pattivacek marked this conversation as resolved.
Show resolved Hide resolved

### Fixed

- Fixed several issues with OSTree updates on IP Secondaries: [PR](https://github.com/advancedtelematic/aktualizr/pull/1518)

## [2019.11] - 2019-12-12

### Added
Expand Down
1 change: 1 addition & 0 deletions src/aktualizr_get/get.cc
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "get.h"
#include "crypto/keymanager.h"
#include "http/httpclient.h"
#include "storage/invstorage.h"

std::string aktualizrGet(Config &config, const std::string &url) {
auto storage = INvStorage::newStorage(config.storage);
Expand Down
12 changes: 6 additions & 6 deletions src/aktualizr_primary/secondary.cc
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,9 @@ class SecondaryWaiter {

LOG_INFO << "Accepted connection from a secondary: (" << sec_ip << ":" << sec_port << ")";
try {
auto sec_creation_res = Uptane::IpUptaneSecondary::create(sec_ip, sec_port, con_socket_.native_handle());
if (sec_creation_res.first) {
connected_secondaries_.push_back(sec_creation_res.second);
auto secondary = Uptane::IpUptaneSecondary::create(sec_ip, sec_port, con_socket_.native_handle());
if (secondary) {
connected_secondaries_.push_back(secondary);
}
} catch (const std::exception& exc) {
LOG_ERROR << "Failed to initialize a secondary: " << exc.what();
Expand Down Expand Up @@ -146,9 +146,9 @@ static Secondaries createIPSecondaries(const IPSecondariesConfig& config) {
SecondaryWaiter sec_waiter{config.secondaries_wait_port, config.secondaries_timeout_s, result};

for (auto& ip_sec_cfg : config.secondaries_cfg) {
auto sec_creation_res = Uptane::IpUptaneSecondary::connectAndCreate(ip_sec_cfg.ip, ip_sec_cfg.port);
if (sec_creation_res.first) {
result.push_back(sec_creation_res.second);
auto secondary = Uptane::IpUptaneSecondary::connectAndCreate(ip_sec_cfg.ip, ip_sec_cfg.port);
if (secondary) {
result.push_back(secondary);
} else {
sec_waiter.addSecondary(ip_sec_cfg.ip, ip_sec_cfg.port);
}
Expand Down
48 changes: 26 additions & 22 deletions src/aktualizr_secondary/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
set(AKTUALIZR_SECONDARY_SRC main.cc)

set(AKTUALIZR_SECONDARY_LIB_SRC
update_agent_file.cc
aktualizr_secondary.cc
aktualizr_secondary_factory.cc
aktualizr_secondary_config.cc
aktualizr_secondary_common.cc
aktualizr_secondary_metadata.cc
socket_server.cc
secondary_tcp_server.cc
)

# do not link tests with libaktualizr
Expand All @@ -26,7 +27,8 @@ add_library(aktualizr_secondary_lib SHARED
$<TARGET_OBJECTS:utilities>
$<TARGET_OBJECTS:storage>
$<TARGET_OBJECTS:logging>
$<TARGET_OBJECTS:uptane>)
$<TARGET_OBJECTS:uptane>
$<TARGET_OBJECTS:campaign>)
target_link_libraries(aktualizr_secondary_lib ${AKTUALIZR_EXTERNAL_LIBS})
target_include_directories(aktualizr_secondary_lib PUBLIC
$<TARGET_PROPERTY:asn1_lib,INCLUDE_DIRECTORIES>
Expand All @@ -46,12 +48,13 @@ install(TARGETS aktualizr-secondary
RUNTIME DESTINATION bin)

set(ALL_AKTUALIZR_SECONDARY_HEADERS
update_agent.h
update_agent_file.h
aktualizr_secondary.h
aktualizr_secondary_interface.h
aktualizr_secondary_factory.h
aktualizr_secondary_config.h
aktualizr_secondary_common.h
aktualizr_secondary_metadata.h
socket_server.h
secondary_tcp_server.h
)

include(AddAktualizrTest)
Expand All @@ -62,29 +65,30 @@ list(INSERT TEST_LIBS 0 aktualizr_secondary_lib)
add_aktualizr_test(NAME aktualizr_secondary_config
SOURCES aktualizr_secondary_config_test.cc PROJECT_WORKING_DIRECTORY LIBRARIES aktualizr_secondary_lib)

add_aktualizr_test(NAME aktualizr_secondary_update
SOURCES update_test.cc
ARGS ${PROJECT_BINARY_DIR}/ostree_repo
PROJECT_WORKING_DIRECTORY LIBRARIES aktualizr_secondary_lib)
add_aktualizr_test(NAME secondary_tcp_server
SOURCES secondary_tcp_server_test.cc PROJECT_WORKING_DIRECTORY)

if(BUILD_OSTREE)
add_aktualizr_test(NAME aktualizr_secondary_uptane_verification
SOURCES uptane_verification_test.cc
ARGS ${PROJECT_BINARY_DIR}/ostree_repo
LIBRARIES aktualizr_secondary_lib uptane_generator_lib $<TARGET_OBJECTS:campaign>
PROJECT_WORKING_DIRECTORY )
target_sources(aktualizr_secondary_lib PRIVATE update_agent_ostree.cc)
list(APPEND AKTUALIZR_SECONDARY_LIB_SRC update_agent_ostree.cc)
list(APPEND ALL_AKTUALIZR_SECONDARY_HEADERS update_agent_ostree.h)

set_target_properties(t_aktualizr_secondary_uptane_verification PROPERTIES LINK_FLAGS -Wl,--export-dynamic)
target_link_libraries(t_aktualizr_secondary_uptane_verification aktualizr_secondary_lib uptane_generator_lib)
add_aktualizr_test(NAME aktualizr_secondary_ostree
SOURCES aktualizr_secondary_ostree_test.cc
ARGS ${PROJECT_BINARY_DIR}/ostree_repo
LIBRARIES aktualizr_secondary_lib uptane_generator_lib
PROJECT_WORKING_DIRECTORY)

add_aktualizr_test(NAME aktualizr_secondary_uptane
SOURCES uptane_test.cc
LIBRARIES aktualizr_secondary_lib uptane_generator_lib virtual_secondary $<TARGET_OBJECTS:campaign> $<TARGET_OBJECTS:primary> $<TARGET_OBJECTS:http>
ARGS ${PROJECT_BINARY_DIR}/ostree_repo PROJECT_WORKING_DIRECTORY)
set_target_properties(t_aktualizr_secondary_ostree PROPERTIES LINK_FLAGS -Wl,--export-dynamic)
else(BUILD_OSTREE)
list(APPEND TEST_SOURCES uptane_verification_test.cc uptane_test.cc)
list(APPEND TEST_SOURCES aktualizr_secondary_ostree_test.cc update_agent_ostree.cc)
list(APPEND ALL_AKTUALIZR_SECONDARY_HEADERS update_agent_ostree.h)
endif(BUILD_OSTREE)

add_aktualizr_test(NAME aktualizr_secondary
SOURCES aktualizr_secondary_test.cc
LIBRARIES aktualizr_secondary_lib uptane_generator_lib)

# test running the executable with command line option --help
add_test(NAME aktualizr_secondary_cmdline--help COMMAND aktualizr-secondary --help)
# test running the executable with command line option --something
Expand Down
Loading