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 152090 rename reverse connection to reversed grpc streaming #1843

Open
wants to merge 2 commits into
base: dev-24.04.x
Choose a base branch
from
Open
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
28 changes: 19 additions & 9 deletions .github/scripts/windows-agent-compile.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,14 @@ Write-Host $env:VCPKG_BINARY_SOURCES

$current_dir = $pwd.ToString()

#install recent version of 7zip needed by some packages
Write-Host "install 7zip"

#download 7zip
Invoke-WebRequest -Uri "https://www.7-zip.org/a/7z2408-x64.msi" -OutFile "7z2408-x64.msi"
#install 7zip
Start-Process 'msiexec.exe' -ArgumentList '/I "7z2408-x64.msi" /qn' -Wait

#get cache from s3
$files_to_hash = "vcpkg.json", "custom-triplets\x64-windows.cmake", "CMakeLists.txt", "CMakeListsWindows.txt"
$files_content = Get-Content -Path $files_to_hash -Raw
Expand All @@ -32,12 +40,13 @@ $writer = [System.IO.StreamWriter]::new($stringAsStream)
$writer.write($files_content -join " ")
$writer.Flush()
$stringAsStream.Position = 0
$vcpkg_release = "2024.10.21"
$vcpkg_hash = Get-FileHash -InputStream $stringAsStream -Algorithm SHA256 | Select-Object Hash
$file_name = "windows-agent-vcpkg-dependencies-cache-" + $vcpkg_hash.Hash
$file_name = "windows-agent-vcpkg-dependencies-cache-" + $vcpkg_hash.Hash + "-" + $vcpkg_release
$file_name_extension = "${file_name}.7z"

#try to get compiled dependenciesfrom s3
Write-Host "try to download compiled dependencies from s3"
Write-Host "try to download compiled dependencies from s3: $file_name_extension"
aws --quiet s3 cp s3://centreon-collect-robot-report/$file_name_extension $file_name_extension
if ( $? -ne $true ) {
#no => generate
Expand All @@ -46,7 +55,7 @@ if ( $? -ne $true ) {
Write-Host "#######################################################################################################################"

Write-Host "install vcpkg"
git clone --depth 1 -b 2024.07.12 https://github.com/microsoft/vcpkg.git
git clone --depth 1 -b $vcpkg_release https://github.com/microsoft/vcpkg.git
cd vcpkg
bootstrap-vcpkg.bat
cd $current_dir
Expand All @@ -57,18 +66,19 @@ if ( $? -ne $true ) {
Write-Host "compile vcpkg dependencies"
vcpkg install --vcpkg-root $env:VCPKG_ROOT --x-install-root build_windows\vcpkg_installed --x-manifest-root . --overlay-triplets custom-triplets --triplet x64-windows

Write-Host "Compress binary archive"
7z a $file_name_extension build_windows\vcpkg_installed
Write-Host "Upload binary archive"
aws s3 cp $file_name_extension s3://centreon-collect-robot-report/$file_name_extension
Write-Host "create CMake files"
if ( $? -eq $true ) {
Write-Host "Compress binary archive"
7z a $file_name_extension build_windows\vcpkg_installed
Write-Host "Upload binary archive"
aws s3 cp $file_name_extension s3://centreon-collect-robot-report/$file_name_extension
}
}
else {
7z x $file_name_extension
Write-Host "Create cmake files from binary-cache downloaded without use vcpkg"
}


Write-Host "create CMake files"

cmake -DCMAKE_BUILD_TYPE=Release -DWITH_TESTING=On -DWINDOWS=On -DBUILD_FROM_CACHE=On -S. -DVCPKG_CRT_LINKAGE=dynamic -DBUILD_SHARED_LIBS=OFF -Bbuild_windows

Expand Down
6 changes: 3 additions & 3 deletions agent/src/config.cc
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const std::string_view config::config_schema(R"(
"minLength": 5
},
"endpoint": {
"description": "Endpoint where agent has to connect to on the poller side or listening endpoint on the agent side in case of reverse_connection",
"description": "Endpoint where agent has to connect to on the poller side or listening endpoint on the agent side in case of reversed_grpc_streaming",
"type": "string",
"pattern": "[\\w\\.:]+:\\w+"
},
Expand All @@ -61,7 +61,7 @@ const std::string_view config::config_schema(R"(
"description": "Name of the SSL certification authority",
"type": "string"
},
"reverse_connection": {
"reversed_grpc_streaming": {
"description": "Set to true to make Engine connect to the agent. Requires the agent to be configured as a server. Default: false",
"type": "boolean"
},
Expand Down Expand Up @@ -144,5 +144,5 @@ config::config(const std::string& path) {
if (_host.empty()) {
_host = boost::asio::ip::host_name();
}
_reverse_connection = json_config.get_bool("reverse_connection", false);
_reverse_connection = json_config.get_bool("reversed_grpc_streaming", false);
}
2 changes: 1 addition & 1 deletion agent/src/config_win.cc
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ config::config(const std::string& registry_key) {
if (_host.empty()) {
_host = boost::asio::ip::host_name();
}
_reverse_connection = get_bool("reverse_connection");
_reverse_connection = get_bool("reversed_grpc_streaming");

RegCloseKey(h_key);
}
4 changes: 4 additions & 0 deletions common/process/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,8 @@ add_library(

target_precompile_headers(centreon_process REUSE_FROM centreon_common)

if(${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
target_link_libraries(centreon_process INTERFACE Boost::process)
endif()

set_property(TARGET centreon_process PROPERTY POSITION_INDEPENDENT_CODE ON)
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class mutex<false> {};
template <>
class lock<false> {
public:
lock(mutex<false>* dummy_mut) {}
lock(mutex<false>* /* dummy_mut*/) {}
};

} // namespace detail
Expand Down
10 changes: 5 additions & 5 deletions common/process/src/process.cc
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ struct boost_process {
boost_process(asio::io_context& io_context,
const std::string& exe_path,
const std::vector<std::string>& args,
bool no_stdin)
bool no_stdin [[maybe_unused]])
: stdout_pipe(io_context),
stderr_pipe(io_context),
stdin_pipe(io_context),
Expand Down Expand Up @@ -277,9 +277,9 @@ void process<use_mutex>::stdin_write_no_lock(
try {
_write_pending = true;
_proc->stdin_pipe.async_write_some(
asio::buffer(*data),
[me = shared_from_this(), caller = _proc, data](
const boost::system::error_code& err, size_t nb_written) {
asio::buffer(*data), [me = shared_from_this(), caller = _proc, data](
const boost::system::error_code& err,
size_t nb_written [[maybe_unused]]) {
detail::lock<use_mutex> l(&me->_protect);
if (caller != me->_proc) {
return;
Expand Down Expand Up @@ -438,4 +438,4 @@ template class process<true>;

template class process<false>;

} // namespace com::centreon::common
} // namespace com::centreon::common
2 changes: 1 addition & 1 deletion tests/resources/Agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def ctn_config_reverse_centreon_agent(key_path:str = None, cert_path:str = None,
makedirs(CONF_DIR, mode=0o777, exist_ok=True)
with open(f"{CONF_DIR}/centagent.json", "w") as ff:
ff.write(agent_config)
ff.write(",\n \"reverse_connection\":true")
ff.write(",\n \"reversed_grpc_streaming\":true")
if key_path is not None or cert_path is not None or ca_path is not None:
ff.write(",\n \"encryption\":true")
if key_path is not None:
Expand Down
Loading