Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mon 15671 instance nego 241109 #1875

Open
wants to merge 38 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 34 commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
c73c406
enh(log_v2): -fPIC is needed to use log_v2 on various libraries
bouda1 Nov 9, 2024
8741fdc
enh(common): hash directory, file content read, and others functions …
bouda1 Nov 9, 2024
736e619
enh(broker): annotations added to bulk_bind
bouda1 Nov 10, 2024
1cae3cb
cleanup(tests): various improvements on tests
bouda1 Nov 10, 2024
0de10fd
fix(tests): core trace logs enabled only when needed
bouda1 Nov 10, 2024
ed35706
enh(broker): write function rewritten to simplify the code
bouda1 Nov 10, 2024
bbb7c3a
cleanup(bbdo): introduction of a new common.proto file
bouda1 Nov 12, 2024
7ebdc6e
enh(broker): New GetPeer gRPC function
bouda1 Nov 12, 2024
33758f1
enh(tests): new tests on GetPeers function
bouda1 Nov 12, 2024
786ddc7
enh(engine): common.proto can be used with engine now and tests on st…
bouda1 Nov 12, 2024
f3df247
enh(broker/neb): cbmod arguments are parsed with boost::program_options
bouda1 Nov 12, 2024
f3969fd
enh(broker): broker knows it has a BROKER peer type
bouda1 Nov 13, 2024
c42cd74
fix(common/engine_conf): issue with err/error level in engine logger
bouda1 Nov 13, 2024
75635cb
enh(broker): new directories are managed now
bouda1 Nov 14, 2024
60f15de
enh(tests/broker): start-stop tests are improved to check some direct…
bouda1 Nov 14, 2024
6696e16
enh(tests): new test to check broker connections
bouda1 Nov 14, 2024
c4ddfb6
enh(broker): improved negotiation is almost done
bouda1 Nov 14, 2024
41f244d
cleanup(broker): unused files removed
bouda1 Nov 14, 2024
27da770
enh(broker): work on unified_sql completed for new negociation
bouda1 Nov 15, 2024
4c4b7af
enh(tests): new negociation tests
bouda1 Nov 15, 2024
732d6be
wip(bbdo): work on welcome message
bouda1 Nov 15, 2024
1530180
enh(tests): new tests and some of the start-stop moved to negociation
bouda1 Nov 15, 2024
fb5b541
fix(bbdo): welcome message contains poller name and broker name
bouda1 Nov 15, 2024
afd91bc
enh(tests): start-stop and negociation tests splitted
bouda1 Nov 15, 2024
e578ad3
wip(broker/applier/state): broker name and poller name must not be mixed
bouda1 Nov 15, 2024
3268958
fix(broker): we keep poller_name and broker_name. And tests updated
bouda1 Nov 15, 2024
f8a820f
fix(tests): regressions due to changes in the code
bouda1 Nov 15, 2024
8606bf9
fix(tests): the get hosts services count did not wait for the good value
bouda1 Nov 16, 2024
ac861df
fix(tests)
bouda1 Nov 17, 2024
b5eb4ae
fix(broker/unified_sql): with mysql we had a wrong query executed.
bouda1 Nov 18, 2024
3768f8d
fix(broker/bbdo): the extended negociation must be done even on grpc …
bouda1 Nov 18, 2024
5f6292c
fix(tests): new tests on grpc stream and extended negociation
bouda1 Nov 18, 2024
16171c6
fix(ci): new engine conf set by default
bouda1 Nov 18, 2024
4ba6b5d
fix(tests/negociation): bbdo 3.1.0 enabled
bouda1 Nov 18, 2024
4841232
fix(broker/bbdo): potential exceptions replaced by error_codes
bouda1 Nov 22, 2024
62f3cd8
fix(broker & common): filesystem functions have a version with error_…
bouda1 Nov 22, 2024
cf7928c
fix(broker): always filepath with error_code
bouda1 Nov 22, 2024
d9028b6
fix(broker/unified_sql): bad condition fixed
bouda1 Nov 22, 2024
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
6 changes: 3 additions & 3 deletions .github/workflows/centreon-collect.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ on:
legacy_engine:
description: 'Compile Engine with legacy configuration library'
required: true
default: true
default: false
type: boolean
packages_in_artifact:
description: 'Save packages in artifacts'
Expand Down Expand Up @@ -147,7 +147,7 @@ jobs:
SCCACHE_REGION: "eu-west-1"
AWS_ACCESS_KEY_ID: ${{ secrets.COLLECT_S3_ACCESS_KEY }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.COLLECT_S3_SECRET_KEY }}
LEGACY_ENGINE: ${{ github.event.inputs.legacy_engine != 'false' && 'ON' || 'OFF' }}
LEGACY_ENGINE: ${{ github.event.inputs.legacy_engine != 'true' && 'OFF' || 'ON' }}

container:
image: ${{ vars.DOCKER_INTERNAL_REGISTRY_URL }}/centreon-collect-${{ matrix.distrib }}:${{ needs.get-environment.outputs.img_version }}
Expand Down Expand Up @@ -286,7 +286,7 @@ jobs:
release: ${{ needs.get-environment.outputs.release }}
commit_hash: ${{ github.sha }}
stability: ${{ needs.get-environment.outputs.stability }}
legacy_engine: ${{ github.event.inputs.legacy_engine != 'false' && 'ON' || 'OFF' }}
legacy_engine: ${{ github.event.inputs.legacy_engine != 'true' && 'OFF' || 'ON' }}
packages_in_artifact: ${{ github.event.inputs.packages_in_artifact == 'true' }}
image: ${{ matrix.image }}
distrib: ${{ matrix.distrib }}
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -147,3 +147,5 @@ tests/resources/*_pb2.py
tests/resources/*_pb2_grpc.py
tests/resources/grpc_stream.proto
tests/resources/opentelemetry

compile_commands.json
46 changes: 7 additions & 39 deletions bbdo/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

set(protobuf_files
header
common
rebuild_message
remove_graph_message
bbdo
Expand All @@ -43,45 +44,12 @@ foreach(name IN LISTS protobuf_files)
add_custom_target(
"target_${name}" DEPENDS "${CMAKE_SOURCE_DIR}/bbdo/${name}.pb.cc"
"${CMAKE_SOURCE_DIR}/bbdo/${name}.pb.h")
add_library("pb_${name}_lib" STATIC "${name}.pb.cc"
"${name}.pb.h")
add_dependencies("pb_${name}_lib" "target_${name}")
set_target_properties("pb_${name}_lib" PROPERTIES POSITION_INDEPENDENT_CODE ON)
endforeach()

add_library(pb_header_lib STATIC header.pb.cc header.pb.h)
add_dependencies(pb_header_lib target_header)
set_target_properties(pb_header_lib PROPERTIES POSITION_INDEPENDENT_CODE ON)

add_library(pb_neb_lib STATIC neb.pb.cc neb.pb.h)
add_dependencies(pb_neb_lib target_neb target_header)
set_target_properties(pb_neb_lib PROPERTIES POSITION_INDEPENDENT_CODE ON)

add_library(pb_storage_lib STATIC storage.pb.cc storage.pb.h)
add_dependencies(pb_storage_lib target_storage target_header)
set_target_properties(pb_storage_lib PROPERTIES POSITION_INDEPENDENT_CODE ON)

add_library(pb_bbdo_lib STATIC bbdo.pb.cc bbdo.pb.h)
add_dependencies(pb_bbdo_lib target_bbdo)
set_target_properties(pb_bbdo_lib PROPERTIES POSITION_INDEPENDENT_CODE ON)

add_library(pb_bam_lib STATIC bam.pb.cc bam.pb.h bam_state.pb.cc bam_state.pb.h)
add_dependencies(pb_bam_lib target_bam target_bam_state target_header)
set_target_properties(pb_bam_lib PROPERTIES POSITION_INDEPENDENT_CODE ON)

add_library(pb_extcmd_lib STATIC extcmd.pb.cc extcmd.pb.h)
add_dependencies(pb_extcmd_lib target_extcmd target_header)
set_target_properties(pb_extcmd_lib PROPERTIES POSITION_INDEPENDENT_CODE ON)

add_library(pb_rebuild_message_lib STATIC rebuild_message.pb.cc
rebuild_message.pb.h)
add_dependencies(pb_rebuild_message_lib target_rebuild_message target_header)
set_target_properties(pb_rebuild_message_lib
PROPERTIES POSITION_INDEPENDENT_CODE ON)

add_library(pb_remove_graph_message_lib STATIC remove_graph_message.pb.cc
remove_graph_message.pb.h)
add_dependencies(pb_remove_graph_message_lib target_remove_graph_message
target_header)
set_target_properties(pb_remove_graph_message_lib
PROPERTIES POSITION_INDEPENDENT_CODE ON)

set(otl_protobuf_files
opentelemetry/proto/collector/metrics/v1/metrics_service
opentelemetry/proto/metrics/v1/metrics
Expand All @@ -100,7 +68,7 @@ foreach(name IN LISTS otl_protobuf_files)
--proto_path=${CMAKE_SOURCE_DIR}/opentelemetry-proto ${proto_file}
VERBATIM)
endforeach()

add_library(pb_open_telemetry_lib STATIC
${CMAKE_SOURCE_DIR}/bbdo/opentelemetry/proto/collector/metrics/v1/metrics_service.pb.cc
${CMAKE_SOURCE_DIR}/bbdo/opentelemetry/proto/metrics/v1/metrics.pb.cc
Expand Down Expand Up @@ -184,4 +152,4 @@ add_library(
"bam/kpi_event.hh")
set_target_properties(bbdo_bam PROPERTIES POSITION_INDEPENDENT_CODE ON)
target_precompile_headers(bbdo_bam REUSE_FROM bbdo_bbdo)
add_dependencies(bbdo_bam table_max_size pb_bam_lib)
add_dependencies(bbdo_bam table_max_size pb_bam_lib pb_bam_state_lib)
56 changes: 38 additions & 18 deletions bbdo/bbdo.proto
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
/*
** Copyright 2022 Centreon
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
**
** http://www.apache.org/licenses/LICENSE-2.0
**
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
**
** For more information : [email protected]
*/

/**
* Copyright 2022-2024 Centreon
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* For more information : [email protected]
*/
syntax = "proto3";

import "common.proto";

package com.centreon.broker;

/* Ignore */
Expand All @@ -33,6 +34,12 @@ message Welcome {
string extensions = 2;
uint64 poller_id = 3;
string poller_name = 4;
/* Broker name is more relevant than poller name because for example on the
* central, rrd broker, central broker and engine share the same poller name
* that is 'Central'. */
string broker_name = 5;
com.centreon.common.PeerType peer_type = 6;
bool extended_negotiation = 7;
}

/* io::bbdo, bbdo::de_pb_ack, 50 */
Expand All @@ -44,3 +51,16 @@ message Ack {
message Stop {
uint64 poller_id = 1;
}

/* io::bbdo, bbdo::de_pb_engine_configuration, 52 */
message EngineConfiguration {
uint64 poller_id = 1; // Poller ID of the sender (Engine or Broker)
string poller_name = 2; // Poller name of the sender
string broker_name = 3; // Broker name of the sender
com.centreon.common.PeerType peer_type =
4; // Peer type of the sender (Engine or Broker)
string engine_config_version =
5; // Engine uses this to send the conf version
bool need_update =
6; // Broker uses this to tell Engine if an update is needed
}
1 change: 0 additions & 1 deletion bbdo/bbdo/ack.hh
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
#define CCB_BBDO_ACK_HH

#include "com/centreon/broker/bbdo/internal.hh"
#include "com/centreon/broker/io/data.hh"
#include "com/centreon/broker/io/events.hh"
#include "com/centreon/broker/mapping/entry.hh"

Expand Down
1 change: 0 additions & 1 deletion bbdo/bbdo/stop.hh
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
#define CCB_BBDO_STOP_HH

#include "com/centreon/broker/bbdo/internal.hh"
#include "com/centreon/broker/io/data.hh"
#include "com/centreon/broker/io/events.hh"
#include "com/centreon/broker/mapping/entry.hh"

Expand Down
1 change: 0 additions & 1 deletion bbdo/bbdo/version_response.hh
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@

#include "bbdo/bbdo/bbdo_version.hh"
#include "com/centreon/broker/bbdo/internal.hh"
#include "com/centreon/broker/io/data.hh"
#include "com/centreon/broker/io/events.hh"
#include "com/centreon/broker/mapping/entry.hh"

Expand Down
33 changes: 33 additions & 0 deletions bbdo/common.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/**
* Copyright 2024 Centreon
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* For more information : [email protected]
*/

syntax = "proto3";

package com.centreon.common;

/**
* @brief Type of the peer. Used in Welcome message, also in the Broker gRPC
* service.
*
*/
enum PeerType {
UNKNOWN = 0;
BROKER = 1;
ENGINE = 2;
MAP = 3;
}
3 changes: 2 additions & 1 deletion bbdo/events.hh
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ enum data_element {
de_remove_poller = 6,
de_welcome = 7,
de_pb_ack = 8,
de_pb_stop = 9
de_pb_stop = 9,
de_pb_engine_configuration = 10,
};
}
namespace neb {
Expand Down
3 changes: 2 additions & 1 deletion bbdo/neb.proto
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ message HostStatus {
* @brief Message sent in BBDO 3.0.0 to update a host status partially
* changed. For example, it is convenient for downtime changed.
*/
/* io::neb, neb::de_pb_adaptive_host_status, 55 */
/* io::neb, neb::de_pb_adaptive_host_status, 54 */
message AdaptiveHostStatus {
uint64 host_id = 1;
optional int32 scheduled_downtime_depth = 2;
Expand Down Expand Up @@ -649,6 +649,7 @@ message Instance {
int64 end_time = 7;
int64 start_time = 8;
string version = 9;
string engine_config_version = 10;
}

/* io::neb, neb::de_pb_responsive_instance, 19 */
Expand Down
7 changes: 5 additions & 2 deletions broker/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -104,26 +104,28 @@ add_custom_command(
COMMAND
${Protobuf_PROTOC_EXECUTABLE} ARGS
--plugin=protoc-gen-grpc=${GRPC_CPP_PLUGIN} --proto_path=${SRC_DIR}
--proto_path=${CMAKE_SOURCE_DIR}/bbdo
--proto_path=${CMAKE_SOURCE_DIR}/common/src --grpc_out="${SRC_DIR}"
${SRC_DIR}/broker.proto
DEPENDS ${SRC_DIR}/broker.proto
COMMENT "Generating interface files of the proto file (protobuf)"
OUTPUT ${SRC_DIR}/broker.pb.cc ${SRC_DIR}/broker.pb.h
COMMAND
${Protobuf_PROTOC_EXECUTABLE} ARGS --cpp_out="${SRC_DIR}"
--proto_path=${CMAKE_SOURCE_DIR}/bbdo
--proto_path=${SRC_DIR} --proto_path=${CMAKE_SOURCE_DIR}/common/src
${SRC_DIR}/broker.proto
WORKING_DIRECTORY ${CMAKE_BINARY_DIR})

add_custom_target("target_broker_message" DEPENDS "${SRC_DIR}/broker.pb.cc"
add_custom_target(target_broker_message DEPENDS "${SRC_DIR}/broker.pb.cc"
"${SRC_DIR}/broker.pb.h")

include_directories(${SRC_DIR} ${CMAKE_SOURCE_DIR}/common/src
${CMAKE_SOURCE_DIR}/common/inc ${CMAKE_SOURCE_DIR}/bbdo)

add_library(berpc STATIC ${SRC_DIR}/broker.grpc.pb.cc ${SRC_DIR}/broker.pb.cc
${SRC_DIR}/broker.grpc.pb.h ${SRC_DIR}/broker.pb.h)
target_link_libraries(berpc protobuf)
target_link_libraries(berpc protobuf pb_common_lib)
set_target_properties(berpc PROPERTIES COMPILE_FLAGS "-fPIC")

# Version.
Expand Down Expand Up @@ -453,6 +455,7 @@ target_link_libraries(
ctncrypto
dl
pb_bbdo_lib
pb_common_lib
pb_extcmd_lib
pb_open_telemetry_lib
pthread
Expand Down
2 changes: 1 addition & 1 deletion broker/bam/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ add_library(
"${INC_DIR}/service_book.hh"
"${INC_DIR}/service_listener.hh"
"${INC_DIR}/timeperiod_map.hh")
target_link_libraries("${BAM}" bbdo_storage bbdo_bam pb_bam_lib
target_link_libraries("${BAM}" bbdo_storage bbdo_bam pb_bam_lib pb_bam_state_lib
spdlog::spdlog)
target_precompile_headers(${BAM} PRIVATE precomp_inc/precomp.hpp)
set_target_properties("${BAM}" PROPERTIES PREFIX "")
Expand Down
2 changes: 1 addition & 1 deletion broker/bam/test/ba/kpi_ba.cc
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class KpiBA : public ::testing::Test {
void SetUp() override {
// Initialization.
_logger = log_v2::instance().get(log_v2::BAM);
config::applier::init(0, "test_broker", 0);
config::applier::init(com::centreon::common::BROKER, 0, "test_broker", 0);

_aply_state = std::make_unique<bam::configuration::applier::state>(_logger);
_state = std::make_unique<bam::configuration::state>(_logger);
Expand Down
3 changes: 1 addition & 2 deletions broker/bam/test/ba/kpi_service.cc
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@

using namespace com::centreon::broker;


class BamBA : public ::testing::Test {
protected:
std::unique_ptr<bam::configuration::applier::state> _aply_state;
Expand All @@ -49,7 +48,7 @@ class BamBA : public ::testing::Test {
void SetUp() override {
// Initialization.
_logger = log_v2::instance().get(log_v2::BAM);
config::applier::init(0, "test_broker", 0);
config::applier::init(com::centreon::common::BROKER, 0, "test_broker", 0);

_aply_state = std::make_unique<bam::configuration::applier::state>(_logger);
_state = std::make_unique<bam::configuration::state>(_logger);
Expand Down
2 changes: 1 addition & 1 deletion broker/bam/test/configuration/applier-boolexp.cc
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class ApplierBoolexp : public ::testing::Test {
public:
void SetUp() override {
// Initialization.
config::applier::init(0, "test_broker", 0);
config::applier::init(com::centreon::common::BROKER, 0, "test_broker", 0);
auto logger = log_v2::instance().get(log_v2::BAM);

_aply_state = std::make_unique<bam::configuration::applier::state>(logger);
Expand Down
3 changes: 1 addition & 2 deletions broker/bam/test/exp_builder/exp_builder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
using namespace com::centreon::broker;
using log_v2 = com::centreon::common::log_v2::log_v2;


class BamExpBuilder : public ::testing::Test {
protected:
std::unique_ptr<test_visitor> _visitor;
Expand All @@ -45,7 +44,7 @@ class BamExpBuilder : public ::testing::Test {
void SetUp() override {
_logger = log_v2::instance().get(log_v2::BAM);
try {
config::applier::init(0, "test_broker", 0);
config::applier::init(com::centreon::common::BROKER, 0, "test_broker", 0);
_logger->set_level(spdlog::level::debug);
_logger->flush_on(spdlog::level::debug);
} catch (std::exception const& e) {
Expand Down
4 changes: 3 additions & 1 deletion broker/bam/test/monitoring_stream.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ using namespace com::centreon::broker;
using namespace com::centreon::broker::bam;

class BamMonitoringStream : public testing::Test {
void SetUp() override { config::applier::init(0, "test_broker", 0); }
void SetUp() override {
config::applier::init(com::centreon::common::BROKER, 0, "test_broker", 0);
}
void TearDown() override { config::applier::deinit(); }
};

Expand Down
Loading
Loading