From 3f03126120455786944061cf7a15faaff5d549d9 Mon Sep 17 00:00:00 2001 From: Jean Christophe Roques Date: Wed, 6 Nov 2024 14:39:53 +0100 Subject: [PATCH 1/2] rename reverse_connection to reversed_grpc_streaming --- agent/src/config.cc | 6 +++--- agent/src/config_win.cc | 2 +- tests/resources/Agent.py | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/agent/src/config.cc b/agent/src/config.cc index d15de69aead..1616147a029 100644 --- a/agent/src/config.cc +++ b/agent/src/config.cc @@ -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+" }, @@ -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" }, @@ -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); } diff --git a/agent/src/config_win.cc b/agent/src/config_win.cc index 9fe35068904..a1315c3697d 100644 --- a/agent/src/config_win.cc +++ b/agent/src/config_win.cc @@ -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); } diff --git a/tests/resources/Agent.py b/tests/resources/Agent.py index 4497a4453f3..b5fac6b092a 100644 --- a/tests/resources/Agent.py +++ b/tests/resources/Agent.py @@ -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: From d8e87dc6392c3c097e464a5d1eef764cfd28e01f Mon Sep 17 00:00:00 2001 From: Jean Christophe Roques Date: Wed, 6 Nov 2024 14:41:18 +0100 Subject: [PATCH 2/2] upgrade vcpkg --- .github/scripts/windows-agent-compile.ps1 | 28 +++++++++++++------ common/process/CMakeLists.txt | 4 +++ .../com/centreon/common/process/process.hh | 2 +- common/process/src/process.cc | 10 +++---- 4 files changed, 29 insertions(+), 15 deletions(-) diff --git a/.github/scripts/windows-agent-compile.ps1 b/.github/scripts/windows-agent-compile.ps1 index 02af28abb7e..0b371e12917 100644 --- a/.github/scripts/windows-agent-compile.ps1 +++ b/.github/scripts/windows-agent-compile.ps1 @@ -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 @@ -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 @@ -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 @@ -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 diff --git a/common/process/CMakeLists.txt b/common/process/CMakeLists.txt index f79bbaaa657..22235468ac6 100644 --- a/common/process/CMakeLists.txt +++ b/common/process/CMakeLists.txt @@ -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) diff --git a/common/process/inc/com/centreon/common/process/process.hh b/common/process/inc/com/centreon/common/process/process.hh index 06a6799bd3b..9fc6862ecf6 100644 --- a/common/process/inc/com/centreon/common/process/process.hh +++ b/common/process/inc/com/centreon/common/process/process.hh @@ -48,7 +48,7 @@ class mutex {}; template <> class lock { public: - lock(mutex* dummy_mut) {} + lock(mutex* /* dummy_mut*/) {} }; } // namespace detail diff --git a/common/process/src/process.cc b/common/process/src/process.cc index 6036a0fca19..14f827d4310 100644 --- a/common/process/src/process.cc +++ b/common/process/src/process.cc @@ -113,7 +113,7 @@ struct boost_process { boost_process(asio::io_context& io_context, const std::string& exe_path, const std::vector& args, - bool no_stdin) + bool no_stdin [[maybe_unused]]) : stdout_pipe(io_context), stderr_pipe(io_context), stdin_pipe(io_context), @@ -277,9 +277,9 @@ void process::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 l(&me->_protect); if (caller != me->_proc) { return; @@ -438,4 +438,4 @@ template class process; template class process; -} // namespace com::centreon::common \ No newline at end of file +} // namespace com::centreon::common