Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,7 @@
"onCreateCommand": {
"update certificates & install dependencies": "sudo apt update && sudo apt install -y --no-install-recommends ca-certificates-java openjdk-17-jre-headless libacl1-dev tmux && sudo update-ca-certificates",
"bazel use system trust store": "echo 'startup --host_jvm_args=-Djavax.net.ssl.trustStore=/etc/ssl/certs/java/cacerts --host_jvm_args=-Djavax.net.ssl.trustStorePassword=changeit' | sudo tee --append /etc/bazel.bazelrc"
}
},

"runArgs": ["--network", "host"]
}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,6 @@ _build/
.clwb
.idea
external
compile_commands.json
.clangd
.cache
9 changes: 1 addition & 8 deletions BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ copyright_checker(
srcs = [
"examples",
"src",
"tests",
"//:BUILD",
"//:MODULE.bazel",
],
Expand Down Expand Up @@ -58,11 +59,3 @@ docs(
],
source_dir = "docs",
)

# Test suites
test_suite(
name = "unit_tests",
testonly = True,
tests = [
],
)
11 changes: 3 additions & 8 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ bazel_dep(name = "download_utils", version = "1.0.1")
# S-CORE process rules
bazel_dep(name = "score_bazel_platforms", version = "0.0.3")
bazel_dep(name = "score_docs_as_code", version = "2.2.0")
bazel_dep(name = "score_tooling", version = "1.0.4")
bazel_dep(name = "score_tooling", version = "1.0.5")
bazel_dep(name = "score_rust_policies", version = "0.0.3")
bazel_dep(name = "score_baselibs", version = "0.2.2")

Expand All @@ -41,16 +41,11 @@ bazel_dep(name = "score_toolchains_qnx", version = "0.0.6", dev_dependency = Tru
bazel_dep(name = "rust_qnx8_toolchain", version = "1.2.0", dev_dependency = True)
bazel_dep(name = "score_toolchains_rust", version = "0.1.1", dev_dependency = True)

bazel_dep(name = "googletest", version = "1.17.0.bcr.1")

# S-CORE crates
bazel_dep(name = "score_crates", version = "0.0.6")

# Overrides
git_override(
module_name = "score_tooling",
commit = "612d6f180a9bb6338de5f0e6667fcf83068d9c37", #until 1.0.5 is released
remote = "https://github.com/eclipse-score/tooling.git",
)

git_override(
module_name = "score_toolchains_rust",
commit = "bcf8e5364f72cf136ec81960350a82e2b5c45449",
Expand Down
4 changes: 4 additions & 0 deletions MODULE.bazel.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions examples/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,15 @@ rm -rf tmp
rm -rf config/tmp
mkdir config/tmp
python3 config/gen_health_monitor_process_cfg.py -c "$NUMBER_OF_CPP_PROCESSES_PER_PROCESS_GROUP" -r "$NUMBER_OF_RUST_PROCESSES_PER_PROCESS_GROUP" $PROCESS_GROUPS -o config/tmp/
../bazel-bin/external/flatbuffers+/flatc --binary -o config/tmp ../src/health_monitor_lib/config/hm_flatcfg.fbs config/tmp/health_monitor_process_cfg_*.json
../bazel-bin/external/flatbuffers+/flatc --binary -o config/tmp ../src/launch_manager_daemon/health_monitor_lib/config/hm_flatcfg.fbs config/tmp/health_monitor_process_cfg_*.json

python3 config/gen_health_monitor_cfg.py -c "$NUMBER_OF_CPP_PROCESSES_PER_PROCESS_GROUP" -r "$NUMBER_OF_RUST_PROCESSES_PER_PROCESS_GROUP" $PROCESS_GROUPS -o config/tmp/
../bazel-bin/external/flatbuffers+/flatc --binary -o config/tmp ../src/health_monitor_lib/config/hm_flatcfg.fbs config/tmp/hm_demo.json
../bazel-bin/external/flatbuffers+/flatc --binary -o config/tmp ../src/launch_manager_daemon/health_monitor_lib/config/hm_flatcfg.fbs config/tmp/hm_demo.json

python3 config/gen_launch_manager_cfg.py -c "$NUMBER_OF_CPP_PROCESSES_PER_PROCESS_GROUP" -r "$NUMBER_OF_RUST_PROCESSES_PER_PROCESS_GROUP" -n "$NUMBER_OF_NON_SUPERVISED_CPP_PROCESSES_PER_PROCESS_GROUP" $PROCESS_GROUPS -o config/tmp/
../bazel-bin/external/flatbuffers+/flatc --binary -o config/tmp ../src/launch_manager_daemon/config/lm_flatcfg.fbs config/tmp/lm_demo.json

../bazel-bin/external/flatbuffers+/flatc --binary -o config/tmp ../src/health_monitor_lib/config/hmcore_flatcfg.fbs config/hmcore.json
../bazel-bin/external/flatbuffers+/flatc --binary -o config/tmp ../src/launch_manager_daemon/health_monitor_lib/config/hmcore_flatcfg.fbs config/hmcore.json

mkdir -p tmp/launch_manager/etc
cp $LM_BINARY tmp/launch_manager/launch_manager
Expand Down
25 changes: 12 additions & 13 deletions examples/rust_supervised_app/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
/********************************************************************************
* Copyright (c) 2025 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
* information regarding copyright ownership.
*
* This program and the accompanying materials are made available under the
* terms of the Apache License Version 2.0 which is available at
* https://www.apache.org/licenses/LICENSE-2.0
*
* SPDX-License-Identifier: Apache-2.0
********************************************************************************/

// *******************************************************************************
// Copyright (c) 2026 Contributors to the Eclipse Foundation
//
// See the NOTICE file(s) distributed with this work for additional
// information regarding copyright ownership.
//
// This program and the accompanying materials are made available under the
// terms of the Apache License Version 2.0 which is available at
// <https://www.apache.org/licenses/LICENSE-2.0>
//
// SPDX-License-Identifier: Apache-2.0
// *******************************************************************************
use clap::Parser;
use libc::{c_long, nanosleep, time_t, timespec};
use signal_hook::flag;
Expand Down
6 changes: 3 additions & 3 deletions src/health_monitoring_lib/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// Copyright (c) 2025 Contributors to the Eclipse Foundation
// *******************************************************************************
// Copyright (c) 2026 Contributors to the Eclipse Foundation
//
// See the NOTICE file(s) distributed with this work for additional
// information regarding copyright ownership.
Expand All @@ -9,4 +9,4 @@
// <https://www.apache.org/licenses/LICENSE-2.0>
//
// SPDX-License-Identifier: Apache-2.0
//
// *******************************************************************************
33 changes: 33 additions & 0 deletions src/launch_manager_daemon/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,39 @@ cc_binary_with_common_opts(
}),
visibility = ["//visibility:public"],
deps = [
":config",
"//externals/ipc_dropin",
"//src/launch_manager_daemon/common",
"//src/launch_manager_daemon/common:control_client_channel",
"//src/launch_manager_daemon/common:identifier_hash",
"//src/launch_manager_daemon/common:lifecycle_error",
"//src/launch_manager_daemon/common:log",
"//src/launch_manager_daemon/health_monitor_lib:health_monitor",
"//src/launch_manager_daemon/process_state_client_lib:process_state_client",
"@flatbuffers",
"@score_baselibs//score/mw/log",
"@score_baselibs//score/result",
],
)

# FOR TESTING

cc_library(
name = "headers",
hdrs = glob(
[
"src/**/*.h",
"src/**/*.hpp",
],
allow_empty = True, # "src/**/*.h" is empty as of now
),
includes = [
"include",
"src",
],
visibility = ["//tests:__subpackages__"],
deps = [
# Must match launch_manager deps
":config",
"//externals/ipc_dropin",
"//src/launch_manager_daemon/common",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
/********************************************************************************
* Copyright (c) 2025 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
* information regarding copyright ownership.
*
* This program and the accompanying materials are made available under the
* terms of the Apache License Version 2.0 which is available at
* https://www.apache.org/licenses/LICENSE-2.0
*
* SPDX-License-Identifier: Apache-2.0
********************************************************************************/

// *******************************************************************************
// Copyright (c) 2026 Contributors to the Eclipse Foundation
//
// See the NOTICE file(s) distributed with this work for additional
// information regarding copyright ownership.
//
// This program and the accompanying materials are made available under the
// terms of the Apache License Version 2.0 which is available at
// <https://www.apache.org/licenses/LICENSE-2.0>
//
// SPDX-License-Identifier: Apache-2.0
// *******************************************************************************
use std::fmt;

#[derive(Debug, Clone)]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
/********************************************************************************
* Copyright (c) 2025 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
* information regarding copyright ownership.
*
* This program and the accompanying materials are made available under the
* terms of the Apache License Version 2.0 which is available at
* https://www.apache.org/licenses/LICENSE-2.0
*
* SPDX-License-Identifier: Apache-2.0
********************************************************************************/

// *******************************************************************************
// Copyright (c) 2026 Contributors to the Eclipse Foundation
//
// See the NOTICE file(s) distributed with this work for additional
// information regarding copyright ownership.
//
// This program and the accompanying materials are made available under the
// terms of the Apache License Version 2.0 which is available at
// <https://www.apache.org/licenses/LICENSE-2.0>
//
// SPDX-License-Identifier: Apache-2.0
// *******************************************************************************
pub mod errors;
pub mod monitor;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
/********************************************************************************
* Copyright (c) 2025 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
* information regarding copyright ownership.
*
* This program and the accompanying materials are made available under the
* terms of the Apache License Version 2.0 which is available at
* https://www.apache.org/licenses/LICENSE-2.0
*
* SPDX-License-Identifier: Apache-2.0
********************************************************************************/

// *******************************************************************************
// Copyright (c) 2026 Contributors to the Eclipse Foundation
//
// See the NOTICE file(s) distributed with this work for additional
// information regarding copyright ownership.
//
// This program and the accompanying materials are made available under the
// terms of the Apache License Version 2.0 which is available at
// <https://www.apache.org/licenses/LICENSE-2.0>
//
// SPDX-License-Identifier: Apache-2.0
// *******************************************************************************
use crate::errors;
use libc::{c_char, c_uint, c_void};
use std::ffi::CString;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ namespace lcm {
namespace saf {
namespace daemon {

HealthMonitorImpl::HealthMonitorImpl(std::shared_ptr<score::lcm::IRecoveryClient> recovery_client, std::unique_ptr<watchdog::IWatchdogIf> watchdog)
: m_recovery_client(recovery_client), m_watchdog(std::move(watchdog)), m_logger{score::lcm::saf::logging::PhmLogger::getLogger(score::lcm::saf::logging::PhmLogger::EContext::factory)} {}
HealthMonitorImpl::HealthMonitorImpl(std::shared_ptr<score::lcm::IRecoveryClient> recovery_client, std::unique_ptr<watchdog::IWatchdogIf> watchdog, std::unique_ptr<score::lcm::IProcessStateReceiver> process_state_receiver)
: m_recovery_client(recovery_client), m_watchdog(std::move(watchdog)), m_logger{score::lcm::saf::logging::PhmLogger::getLogger(score::lcm::saf::logging::PhmLogger::EContext::factory)}, m_process_state_receiver{std::move(process_state_receiver)} {}

EInitCode HealthMonitorImpl::init() noexcept {
score::lcm::saf::daemon::EInitCode initResult{score::lcm::saf::daemon::EInitCode::kGeneralError};
try {
m_osClock.startMeasurement();

m_daemon = std::make_unique<score::lcm::saf::daemon::PhmDaemon>(m_osClock, m_logger, std::move(m_watchdog));
m_daemon = std::make_unique<score::lcm::saf::daemon::PhmDaemon>(m_osClock, m_logger, std::move(m_watchdog), std::move(m_process_state_receiver));
initResult = m_daemon->init(m_recovery_client);

if (initResult == score::lcm::saf::daemon::EInitCode::kNoError) {
Expand Down Expand Up @@ -60,4 +60,4 @@ bool HealthMonitorImpl::run(std::atomic_bool& cancel_thread) noexcept {
} // namespace daemon
} // namespace saf
} // namespace lcm
} // namespace score
} // namespace score
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ namespace daemon {

class HealthMonitorImpl : public IHealthMonitor {
public:
HealthMonitorImpl(std::shared_ptr<score::lcm::IRecoveryClient> recovery_client, std::unique_ptr<watchdog::IWatchdogIf> watchdog);
HealthMonitorImpl(std::shared_ptr<score::lcm::IRecoveryClient> recovery_client, std::unique_ptr<watchdog::IWatchdogIf> watchdog, std::unique_ptr<score::lcm::IProcessStateReceiver> process_state_receiver);

EInitCode init() noexcept override;

Expand All @@ -45,11 +45,12 @@ class HealthMonitorImpl : public IHealthMonitor {
score::lcm::saf::logging::PhmLogger& m_logger;
std::unique_ptr<score::lcm::saf::daemon::PhmDaemon> m_daemon{nullptr};
score::lcm::saf::timers::OsClockInterface m_osClock{};
std::unique_ptr<score::lcm::IProcessStateReceiver> m_process_state_receiver;
};

} // namespace daemon
} // namespace saf
} // namespace lcm
} // namespace score

#endif
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ namespace daemon
/* RULECHECKER_comment(0, 4, check_incomplete_data_member_construction, "Default constructor is used for\
processStateReader.", true_no_defect) */
PhmDaemon::PhmDaemon(score::lcm::saf::timers::OsClockInterface& f_osClock, logging::PhmLogger& f_logger_r,
std::unique_ptr<watchdog::IWatchdogIf> f_watchdog) :
osClock{f_osClock}, cycleTimer{&osClock}, logger_r{f_logger_r}, swClusterHandlers{}, watchdog(std::move(f_watchdog))
std::unique_ptr<watchdog::IWatchdogIf> f_watchdog, std::unique_ptr<score::lcm::IProcessStateReceiver> f_process_state_receiver) :
osClock{f_osClock}, cycleTimer{&osClock}, logger_r{f_logger_r}, swClusterHandlers{}, watchdog(std::move(f_watchdog)), processStateReader{std::move(f_process_state_receiver)}
{
static_cast<void>(f_osClock);
}
Expand Down Expand Up @@ -84,40 +84,36 @@ void PhmDaemon::performCyclicTriggers(void)
bool PhmDaemon::construct(const factory::MachineConfigFactory::SupervisionBufferConfig& f_bufferConfig_r) noexcept(
false)
{
bool isSuccess{processStateReader.init()};
bool isSuccess{true};

if (isSuccess)
score::Result<std::vector<std::string>> listSwClustersPhm{{"MainCluster"}};
if (!listSwClustersPhm.has_value())
{

score::Result<std::vector<std::string>> listSwClustersPhm{{"MainCluster"}};
if (!listSwClustersPhm.has_value())
logger_r.LogError()
<< "Phm Daemon: retrieving the list of PHM software cluster configurations failed with error:"
<< listSwClustersPhm.error().Message();
isSuccess = false;
}
else
{
if (listSwClustersPhm.value().size() == 0U)
{
logger_r.LogError()
<< "Phm Daemon: retrieving the list of PHM software cluster configurations failed with error:"
<< listSwClustersPhm.error().Message();
isSuccess = false;
logger_r.LogWarn() << "Phm Daemon: is starting without any software cluster configurations!";
}
else
{
if (listSwClustersPhm.value().size() == 0U)
{
logger_r.LogWarn() << "Phm Daemon: is starting without any software cluster configurations!";
}

// Reserve the vector swClusterHandlers obtained from flatcfg before constructing the SwClusters
swClusterHandlers.reserve(listSwClustersPhm.value().size());
// Reserve the vector swClusterHandlers obtained from flatcfg before constructing the SwClusters
swClusterHandlers.reserve(listSwClustersPhm.value().size());

for (auto strSwClusterName : listSwClustersPhm.value())
for (auto strSwClusterName : listSwClustersPhm.value())
{
swClusterHandlers.emplace_back(strSwClusterName);
isSuccess =
swClusterHandlers.back().constructWorkers(recoveryClient, processStateReader, f_bufferConfig_r);
if (!isSuccess)
{
swClusterHandlers.emplace_back(strSwClusterName);
isSuccess =
swClusterHandlers.back().constructWorkers(recoveryClient, processStateReader, f_bufferConfig_r);
if (!isSuccess)
{
logger_r.LogError() << "Phm Daemon: failed to create worker objects for swclusterhandler:"
<< strSwClusterName;
break;
}
logger_r.LogError() << "Phm Daemon: failed to create worker objects for swclusterhandler:"
<< strSwClusterName;
break;
}
}
}
Expand Down
Loading
Loading