Skip to content

Commit

Permalink
MON-148688-telegraf-certificate-parameters-harmonization (#1716)
Browse files Browse the repository at this point in the history
REFS:MON-148688
  • Loading branch information
jean-christophe81 authored Sep 26, 2024
1 parent 6b1fcd0 commit 50bb836
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 29 deletions.
4 changes: 2 additions & 2 deletions engine/modules/opentelemetry/doc/opentelemetry.md
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,8 @@ An example of configuration:
"http_server" : {
"port": 1443,
"encryption": true,
"certificate_path": "server.crt",
"key_path": "server.key"
"public_cert": "server.crt",
"private_key": "server.key"
},
"engine_otel_endpoint": "172.17.0.1:4317",
"check_interval":60
Expand Down
Binary file modified engine/modules/opentelemetry/doc/otel_configuration.odg
Binary file not shown.
Binary file modified engine/modules/opentelemetry/doc/otel_configuration.pdf
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ class conf_server_config {
asio::ip::tcp::endpoint _listen_endpoint;
bool _crypted;
unsigned _second_keep_alive_interval;
std::string _certificate_path;
std::string _key_path;
std::string _public_cert;
std::string _private_key;
unsigned _check_interval;

public:
Expand All @@ -51,8 +51,8 @@ class conf_server_config {

unsigned get_check_interval() const { return _check_interval; }

const std::string& get_certificate_path() const { return _certificate_path; }
const std::string& get_key_path() const { return _key_path; }
const std::string& get_public_cert() const { return _public_cert; }
const std::string& get_private_key() const { return _private_key; }

bool operator==(const conf_server_config& right) const;
};
Expand Down
2 changes: 1 addition & 1 deletion engine/modules/opentelemetry/src/open_telemetry.cc
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ void open_telemetry::_create_telegraf_conf_server(
std::chrono::seconds(10), std::chrono::seconds(30),
std::chrono::seconds(300), 30, std::chrono::seconds(10), 0,
std::chrono::hours(1), 1, asio::ssl::context::tlsv12,
telegraf_conf->get_certificate_path(), telegraf_conf->get_key_path());
telegraf_conf->get_public_cert(), telegraf_conf->get_private_key());

if (telegraf_conf->is_crypted()) {
_telegraf_conf_server = http::server::load(
Expand Down
28 changes: 14 additions & 14 deletions engine/modules/opentelemetry/src/telegraf/conf_server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,12 @@ static constexpr std::string_view _config_schema(R"(
"minimum": 0,
"maximum": 3600
},
"certificate_path": {
"public_cert": {
"description": "path of the certificate file of the server",
"type": "string",
"minLength": 5
},
"key_path": {
"private_key": {
"description": "path of the key file",
"type": "string",
"minLength": 5
Expand Down Expand Up @@ -122,10 +122,10 @@ conf_server_config::conf_server_config(const rapidjson::Value& json_config_v,

_second_keep_alive_interval =
http_json_config.get_unsigned("keepalive_interval", 30);
_certificate_path = http_json_config.get_string("certificate_path", "");
_key_path = http_json_config.get_string("key_path", "");
_public_cert = http_json_config.get_string("public_cert", "");
_private_key = http_json_config.get_string("private_key", "");
if (_crypted) {
if (_certificate_path.empty()) {
if (_public_cert.empty()) {
SPDLOG_LOGGER_ERROR(config_logger,
"telegraf conf server encryption activated and no "
"certificate path "
Expand All @@ -135,7 +135,7 @@ conf_server_config::conf_server_config(const rapidjson::Value& json_config_v,
"path "
"provided");
}
if (_key_path.empty()) {
if (_private_key.empty()) {
SPDLOG_LOGGER_ERROR(config_logger,
"telegraf conf server encryption activated and no "
"certificate key path provided");
Expand All @@ -144,23 +144,23 @@ conf_server_config::conf_server_config(const rapidjson::Value& json_config_v,
"telegraf conf server encryption activated and no certificate key "
"path provided");
}
if (::access(_certificate_path.c_str(), R_OK)) {
if (::access(_public_cert.c_str(), R_OK)) {
SPDLOG_LOGGER_ERROR(
config_logger,
"telegraf conf server unable to read certificate file {}",
_certificate_path);
_public_cert);
throw exceptions::msg_fmt(
"telegraf conf server unable to read certificate file {}",
_certificate_path);
_public_cert);
}
if (::access(_key_path.c_str(), R_OK)) {
if (::access(_private_key.c_str(), R_OK)) {
SPDLOG_LOGGER_ERROR(
config_logger,
"telegraf conf server unable to read certificate key file {}",
_key_path);
_private_key);
throw exceptions::msg_fmt(
"telegraf conf server unable to read certificate key file {}",
_key_path);
_private_key);
}
}
} else {
Expand All @@ -175,8 +175,8 @@ bool conf_server_config::operator==(const conf_server_config& right) const {
return _listen_endpoint == right._listen_endpoint &&
_crypted == right._crypted &&
_second_keep_alive_interval == right._second_keep_alive_interval &&
_certificate_path == right._certificate_path &&
_key_path == right._key_path &&
_public_cert == right._public_cert &&
_private_key == right._private_key &&
_check_interval == right._check_interval;
}

Expand Down
2 changes: 1 addition & 1 deletion tests/broker-engine/opentelemetry.robot
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ BEOTEL_SERVE_TELEGRAF_CONFIGURATION_CRYPTED
Ctn Config Engine ${1} ${3} ${2}
Ctn Add Otl ServerModule
... 0
... {"otel_server":{"host": "0.0.0.0","port": 4317},"max_length_grpc_log":0, "telegraf_conf_server": {"http_server":{"port": 1443, "encryption": true, "certificate_path": "/tmp/otel/server.crt", "key_path": "/tmp/otel/server.key"}, "check_interval":60, "engine_otel_endpoint": "127.0.0.1:4317"}}
... {"otel_server":{"host": "0.0.0.0","port": 4317},"max_length_grpc_log":0, "telegraf_conf_server": {"http_server":{"port": 1443, "encryption": true, "public_cert": "/tmp/otel/server.crt", "private_key": "/tmp/otel/server.key"}, "check_interval":60, "engine_otel_endpoint": "127.0.0.1:4317"}}
Ctn Config Add Otl Connector
... 0
... OTEL connector
Expand Down
12 changes: 5 additions & 7 deletions tests/resources/resources.resource
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,9 @@ Ctn Clear Broker Logs

Ctn Start Broker
[Arguments] ${only_central}=False
Start Process /usr/sbin/cbd ${EtcRoot}/centreon-broker/central-broker.json alias=b1
Start Process /usr/sbin/cbd ${EtcRoot}/centreon-broker/central-broker.json alias=b1 stdout=${BROKER_LOG}/central-broker-master-stdout.log stderr=${BROKER_LOG}/central-broker-master-stderr.log
IF not ${only_central}
Start Process /usr/sbin/cbd ${EtcRoot}/centreon-broker/central-rrd.json alias=b2
Start Process /usr/sbin/cbd ${EtcRoot}/centreon-broker/central-rrd.json alias=b2 stdout=${BROKER_LOG}/central-rrd-stdout.log stderr=${BROKER_LOG}/central-rrd-stderr.log
END

Ctn Restart Broker
Expand Down Expand Up @@ -156,7 +156,7 @@ Ctn Start Engine
EXCEPT
Log can't remove ${lib}/rw/centengine.cmd don't worry
END
Start Process /usr/sbin/centengine ${conf} alias=${alias}
Start Process /usr/sbin/centengine ${conf} alias=${alias} stdout=${log}/centengine-stdout.log stderr=${log}/centengine-stderr.log
END

Ctn Start Engine With Extend Conf
Expand Down Expand Up @@ -285,10 +285,8 @@ Ctn Save Logs
Create Directory failed
${failDir} Catenate SEPARATOR= failed/ ${Test Name}
Create Directory ${failDir}
Copy Files ${centralLog} ${failDir}
Copy Files ${rrdLog} ${failDir}
Copy Files ${moduleLog0} ${failDir}
Copy Files ${engineLog0} ${failDir}
Copy Files ${BROKER_LOG}/* ${failDir}
Copy Files ${ENGINE_LOG}/config0/*.log ${failDir}
Copy Files ${ENGINE_LOG}/*.log ${failDir}
Copy Files ${EtcRoot}/centreon-engine/config0/*.cfg ${failDir}/etc/centreon-engine/config0
Copy Files ${EtcRoot}/centreon-engine/*.json ${failDir}/etc/centreon-engine
Expand Down

2 comments on commit 50bb836

@github-actions
Copy link

Choose a reason for hiding this comment

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

Robot Results

✅ Passed ❌ Failed ⏭️ Skipped Total Pass % ⏱️ Duration
4 1 0 5 80.00 2m51.895658999s

Failed Tests

Name Message ⏱️ Duration Suite
EBNSGU3_BBDO3 The servicegroup 1 still exists 92.379 s Servicegroups

@github-actions
Copy link

Choose a reason for hiding this comment

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

Robot Results

✅ Passed ❌ Failed ⏭️ Skipped Total Pass % ⏱️ Duration
4 1 0 5 80.00 1m55.349111s

Failed Tests

Name Message ⏱️ Duration Suite
EBNSGU3_BBDO2 We should get 9 relations between the servicegroup 1 and services. 40.634 s Servicegroups

Please sign in to comment.