From e1184e5bbe4f03d0667696610afd9ee5f0853171 Mon Sep 17 00:00:00 2001 From: Solomon Jacobs Date: Mon, 23 Oct 2023 13:07:51 +0200 Subject: [PATCH 1/6] Rewrite agent plugin in rust Also installs `walkdir`, for easy directory traversal. CMK-14887 --- v2/robotmk/Cargo.lock | 29 ++++++++++ v2/robotmk/Cargo.toml | 1 + v2/robotmk/src/bin/agent.rs | 107 ++++++++++++++++++++++++++++++++++++ 3 files changed, 137 insertions(+) create mode 100644 v2/robotmk/src/bin/agent.rs diff --git a/v2/robotmk/Cargo.lock b/v2/robotmk/Cargo.lock index c04fad91..8473d586 100644 --- a/v2/robotmk/Cargo.lock +++ b/v2/robotmk/Cargo.lock @@ -948,6 +948,7 @@ dependencies = [ "serde", "serde_json", "sysinfo", + "walkdir", ] [[package]] @@ -989,6 +990,15 @@ version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1ad4cc8da4ef723ed60bced201181d83791ad433213d8c24efffda1eec85d741" +[[package]] +name = "same-file" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" +dependencies = [ + "winapi-util", +] + [[package]] name = "scopeguard" version = "1.2.0" @@ -1134,6 +1144,16 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9d5b2c62b4012a3e1eca5a7e077d13b3bf498c4073e33ccd58626607748ceeca" +[[package]] +name = "walkdir" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d71d857dc86794ca4c280d616f7da00d2dbfd8cd788846559a6813e6aa4b54ee" +dependencies = [ + "same-file", + "winapi-util", +] + [[package]] name = "wasm-bindgen" version = "0.2.87" @@ -1226,6 +1246,15 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" +[[package]] +name = "winapi-util" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f29e6f9198ba0d26b4c9f07dbe6f9ed633e1f3d5b8b414090084349e46a52596" +dependencies = [ + "winapi", +] + [[package]] name = "winapi-x86_64-pc-windows-gnu" version = "0.4.0" diff --git a/v2/robotmk/Cargo.toml b/v2/robotmk/Cargo.toml index 596abce5..37f67042 100644 --- a/v2/robotmk/Cargo.toml +++ b/v2/robotmk/Cargo.toml @@ -21,3 +21,4 @@ log = "*" serde = { version = "1.0.188", features = ["derive"] } serde_json = "*" sysinfo = "*" +walkdir = "2.4.0" diff --git a/v2/robotmk/src/bin/agent.rs b/v2/robotmk/src/bin/agent.rs new file mode 100644 index 00000000..91f33f14 --- /dev/null +++ b/v2/robotmk/src/bin/agent.rs @@ -0,0 +1,107 @@ +use camino::Utf8PathBuf; +use clap::Parser; +use serde::{Deserialize, Serialize}; +use std::env::{var, VarError}; +use std::fs::read_to_string; +use std::path::Path; +use walkdir::{DirEntry, Error, WalkDir}; + +#[derive(Deserialize)] +pub struct Config { + pub results_directory: Utf8PathBuf, +} + +#[derive(Parser)] +#[command(about = "Robotmk agent plugin.")] +struct Args { + /// Configuration file path. + #[clap(name = "CONFIG_PATH")] + pub config_path: Option, +} + +#[derive(Serialize)] +pub struct ConfigError { + config_reading_error: String, +} + +#[derive(Serialize)] +pub struct ConfigFileContent { + config_file_content: String, +} + +fn determine_config_path(arg: Option) -> Result { + if let Some(p) = arg { + return Ok(p); + } + let config_dir = match var("MK_CONFDIR") { + Ok(path) => path, + Err(VarError::NotPresent) => "C:\\ProgramData\\checkmk\\agent\\config".to_string(), + Err(VarError::NotUnicode(_path)) => return Err("CONFIG_PATH is not utf-8.".into()), + }; + let mut config_dir = Utf8PathBuf::from(config_dir); + config_dir.push("robotmk.json"); + Ok(config_dir) +} + +fn report_config_error(message: String) { + let config_error = serde_json::to_string(&ConfigError { + config_reading_error: message, + }) + .unwrap(); + println!("{config_error}"); +} + +fn report_config_content(content: String) { + let config_content = serde_json::to_string(&ConfigFileContent { + config_file_content: content, + }) + .unwrap(); + println!("{config_content}"); +} + +fn print_or_ignore(entry: Result) { + if let Ok(dir) = entry { + if dir.file_type().is_file() { + if let Ok(raw) = read_to_string(dir.path()) { + println!("{raw}"); + } + } + } +} + +fn walk(results_directory: &Path) { + for entry in WalkDir::new(results_directory) + .sort_by_file_name() + .into_iter() + { + print_or_ignore(entry); + } +} + +fn main() { + let arguments = Args::parse(); + println!("<<>>"); + let config_path = match determine_config_path(arguments.config_path) { + Ok(p) => p, + Err(e) => { + report_config_error(e); + return; + } + }; + let raw = match read_to_string(config_path) { + Ok(raw) => raw, + Err(e) => { + report_config_error(e.to_string()); + return; + } + }; + report_config_content(raw.clone()); + let config: Config = match serde_json::from_str(&raw) { + Ok(config) => config, + Err(e) => { + report_config_error(e.to_string()); + return; + } + }; + walk(&config.results_directory.into_std_path_buf()); +} From c47be6216ac46cdb0cf110b9cd4798f058f6dd54 Mon Sep 17 00:00:00 2001 From: Solomon Jacobs Date: Mon, 23 Oct 2023 15:05:34 +0200 Subject: [PATCH 2/6] Add test for walk Also adds `tempfile` for easier testing. CMK-14887 --- v2/robotmk/Cargo.lock | 1 + v2/robotmk/Cargo.toml | 1 + v2/robotmk/src/bin/agent.rs | 44 ++++++++++++++++++++++++++++++++----- 3 files changed, 40 insertions(+), 6 deletions(-) diff --git a/v2/robotmk/Cargo.lock b/v2/robotmk/Cargo.lock index 8473d586..c8eace57 100644 --- a/v2/robotmk/Cargo.lock +++ b/v2/robotmk/Cargo.lock @@ -948,6 +948,7 @@ dependencies = [ "serde", "serde_json", "sysinfo", + "tempfile", "walkdir", ] diff --git a/v2/robotmk/Cargo.toml b/v2/robotmk/Cargo.toml index 37f67042..eb03e5dd 100644 --- a/v2/robotmk/Cargo.toml +++ b/v2/robotmk/Cargo.toml @@ -21,4 +21,5 @@ log = "*" serde = { version = "1.0.188", features = ["derive"] } serde_json = "*" sysinfo = "*" +tempfile = "3.8.0" walkdir = "2.4.0" diff --git a/v2/robotmk/src/bin/agent.rs b/v2/robotmk/src/bin/agent.rs index 91f33f14..be00648c 100644 --- a/v2/robotmk/src/bin/agent.rs +++ b/v2/robotmk/src/bin/agent.rs @@ -3,8 +3,9 @@ use clap::Parser; use serde::{Deserialize, Serialize}; use std::env::{var, VarError}; use std::fs::read_to_string; +use std::io; use std::path::Path; -use walkdir::{DirEntry, Error, WalkDir}; +use walkdir::{DirEntry, WalkDir}; #[derive(Deserialize)] pub struct Config { @@ -59,22 +60,22 @@ fn report_config_content(content: String) { println!("{config_content}"); } -fn print_or_ignore(entry: Result) { +fn print_or_ignore(entry: Result, stdout: &mut impl io::Write) { if let Ok(dir) = entry { if dir.file_type().is_file() { if let Ok(raw) = read_to_string(dir.path()) { - println!("{raw}"); + writeln!(stdout, "{raw}").unwrap(); } } } } -fn walk(results_directory: &Path) { +fn walk(results_directory: &Path, stdout: &mut impl io::Write) { for entry in WalkDir::new(results_directory) .sort_by_file_name() .into_iter() { - print_or_ignore(entry); + print_or_ignore(entry, stdout); } } @@ -103,5 +104,36 @@ fn main() { return; } }; - walk(&config.results_directory.into_std_path_buf()); + walk( + &config.results_directory.into_std_path_buf(), + &mut io::stdout(), + ); +} + +#[test] +fn test_walk() { + use std::fs::{create_dir_all, File}; + use std::io::Write; + use std::str::from_utf8_unchecked; + use tempfile::tempdir; + // Assemble + let path_content = [ + ("1", "Failure is not an Option, it's a Result."), + ("2", "In Rust, None is always an Option<_>."), + ("3/nested", "Rust is the best thing since &Bread[..]."), + ("4/more/nesting", "Yes, I stole these jokes from reddit."), + ]; + let expected: String = path_content.map(|(_, c)| format!("{c}\n")).concat(); + let results_directory = tempdir().unwrap(); + for (path, content) in path_content { + let file_path = results_directory.path().join(path); + create_dir_all(file_path.parent().unwrap()).unwrap(); + let mut file = File::create(file_path).unwrap(); + write!(file, "{}", content).unwrap(); + } + let mut stdout = Vec::new(); + //Act + walk(results_directory.path(), &mut stdout); + //Assert + assert_eq!(unsafe { from_utf8_unchecked(&stdout) }, expected); } From a2bb3e7a8cf49834bb91fd4bf4918ac32b559497 Mon Sep 17 00:00:00 2001 From: Solomon Jacobs Date: Tue, 24 Oct 2023 08:59:17 +0200 Subject: [PATCH 3/6] agent: small typing improvements and refactoring CMK-14887 Co-authored-by: Joerg Herbel --- v2/robotmk/src/bin/agent.rs | 39 ++++++++++++++++--------------------- 1 file changed, 17 insertions(+), 22 deletions(-) diff --git a/v2/robotmk/src/bin/agent.rs b/v2/robotmk/src/bin/agent.rs index be00648c..bb160307 100644 --- a/v2/robotmk/src/bin/agent.rs +++ b/v2/robotmk/src/bin/agent.rs @@ -31,24 +31,23 @@ pub struct ConfigFileContent { } fn determine_config_path(arg: Option) -> Result { - if let Some(p) = arg { - return Ok(p); - } - let config_dir = match var("MK_CONFDIR") { + Ok(arg.unwrap_or(config_path_from_env()?)) +} + +fn config_path_from_env() -> Result { + let config_path = match var("MK_CONFDIR") { Ok(path) => path, - Err(VarError::NotPresent) => "C:\\ProgramData\\checkmk\\agent\\config".to_string(), + Err(VarError::NotPresent) => "C:\\ProgramData\\checkmk\\agent\\config".into(), Err(VarError::NotUnicode(_path)) => return Err("CONFIG_PATH is not utf-8.".into()), }; - let mut config_dir = Utf8PathBuf::from(config_dir); - config_dir.push("robotmk.json"); - Ok(config_dir) + Ok(Utf8PathBuf::from(config_path).join("robotmk.json")) } fn report_config_error(message: String) { let config_error = serde_json::to_string(&ConfigError { config_reading_error: message, }) - .unwrap(); + .expect("Unexpected serialization error: ConfigError"); println!("{config_error}"); } @@ -56,24 +55,23 @@ fn report_config_content(content: String) { let config_content = serde_json::to_string(&ConfigFileContent { config_file_content: content, }) - .unwrap(); + .expect("Unexpected serialization error: ConfigFileContent"); println!("{config_content}"); } -fn print_or_ignore(entry: Result, stdout: &mut impl io::Write) { - if let Ok(dir) = entry { - if dir.file_type().is_file() { - if let Ok(raw) = read_to_string(dir.path()) { - writeln!(stdout, "{raw}").unwrap(); - } +fn print_or_ignore(dir: DirEntry, stdout: &mut impl io::Write) { + if dir.file_type().is_file() { + if let Ok(raw) = read_to_string(dir.path()) { + writeln!(stdout, "{raw}").unwrap(); } } } -fn walk(results_directory: &Path, stdout: &mut impl io::Write) { +fn walk(results_directory: &impl AsRef, stdout: &mut impl io::Write) { for entry in WalkDir::new(results_directory) .sort_by_file_name() .into_iter() + .filter_map(|entry| entry.ok()) { print_or_ignore(entry, stdout); } @@ -104,10 +102,7 @@ fn main() { return; } }; - walk( - &config.results_directory.into_std_path_buf(), - &mut io::stdout(), - ); + walk(&config.results_directory, &mut io::stdout()); } #[test] @@ -133,7 +128,7 @@ fn test_walk() { } let mut stdout = Vec::new(); //Act - walk(results_directory.path(), &mut stdout); + walk(&results_directory, &mut stdout); //Assert assert_eq!(unsafe { from_utf8_unchecked(&stdout) }, expected); } From ae811d289763c459a5db527bb2530115df8929bc Mon Sep 17 00:00:00 2001 From: Solomon Jacobs Date: Tue, 24 Oct 2023 09:24:39 +0200 Subject: [PATCH 4/6] agent: use rust binary instead of powershell CMK-14887 --- vagrant/f12.sh | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/vagrant/f12.sh b/vagrant/f12.sh index 0d4210b7..6edc3582 100755 --- a/vagrant/f12.sh +++ b/vagrant/f12.sh @@ -12,12 +12,10 @@ agentplugindir="$agentdir"/plugins agentconfigdir="$agentdir"/config agentbindir="$agentdir"/bin -# Sync robotmk.exe to vagrant machine +# Sync rust binaries to vagrant machine (scheduler and agent plugin) (cd "$rustdir"; cargo build --target=x86_64-pc-windows-gnu) sshpass -p "vagrant" scp -P 2222 "$rustdir"/target/x86_64-pc-windows-gnu/debug/robotmk.exe vagrant@127.0.0.1:"$agentbindir" +sshpass -p "vagrant" scp -P 2222 "$rustdir"/target/x86_64-pc-windows-gnu/debug/agent.exe vagrant@127.0.0.1:"$agentplugindir" -# Sync collector.ps1 to vagrant machine -sshpass -p "vagrant" scp -P 2222 "$topdir"/checkmk_extensions/agent/robotmk_collector.ps1 vagrant@127.0.0.1:"$agentplugindir" - -# Sync config for collector.ps1 to vagrant machine +# Sync config for agent plugin to vagrant machine sshpass -p "vagrant" scp -P 2222 "$topdir"/v2/data/retry_rcc/windows.json vagrant@127.0.0.1:"$agentconfigdir"/robotmk.json From 683019657cf7e49889f4ce34129fc11cb7b176f5 Mon Sep 17 00:00:00 2001 From: Solomon Jacobs Date: Tue, 24 Oct 2023 09:08:15 +0200 Subject: [PATCH 5/6] Remove powershell Previously, the agent plugin and part of the extension were written in powershell. Both have since be rewritten in Rust, making ci and the scripts themselve redundant. We have sofar "archived" most scripts. However, being able to easily look up these scripts offers little benefit. Having them in the git log should suffice. Thus, we delete them. We also remove the corresponding ci jobs. CMK-14887 --- .github/workflows/ci.yaml | 8 - PSScriptAnalyzerSettings.psd1 | 3 - .../agent/robotmk_collector.ps1 | 74 -------- checkmk_extensions/agent/scheduler_runner.ps1 | 171 ------------------ ci | 22 --- v2/data/retry_rcc/windows.ps1 | 1 - v2/data/retry_suite/windows.ps1 | 1 - 7 files changed, 280 deletions(-) delete mode 100644 PSScriptAnalyzerSettings.psd1 delete mode 100644 checkmk_extensions/agent/robotmk_collector.ps1 delete mode 100644 checkmk_extensions/agent/scheduler_runner.ps1 delete mode 100644 v2/data/retry_rcc/windows.ps1 delete mode 100644 v2/data/retry_suite/windows.ps1 diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 37d9cc1f..790827e9 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -15,8 +15,6 @@ jobs: step: cargo-clippy - name: Rust tests step: cargo-test - - name: Powershell static analysis - step: PSScriptAnalyzer-check-all steps: - name: Checkout repository @@ -52,12 +50,6 @@ jobs: with: components: rustfmt, clippy - - name: ${{ matrix.name }} - env: - STEP: ${{ matrix.step }} - run: .\ci.ps1 $env:STEP - shell: powershell - check_success: if: always() diff --git a/PSScriptAnalyzerSettings.psd1 b/PSScriptAnalyzerSettings.psd1 deleted file mode 100644 index 5d4cb24a..00000000 --- a/PSScriptAnalyzerSettings.psd1 +++ /dev/null @@ -1,3 +0,0 @@ -@{ - Severity=@('Error', 'Warning', 'Information') -} diff --git a/checkmk_extensions/agent/robotmk_collector.ps1 b/checkmk_extensions/agent/robotmk_collector.ps1 deleted file mode 100644 index 01f36f38..00000000 --- a/checkmk_extensions/agent/robotmk_collector.ps1 +++ /dev/null @@ -1,74 +0,0 @@ -Set-StrictMode -Version 3.0 -$ErrorActionPreference = "Stop" - -function Main { - $ConfigPath = DetermineConfigPath -CommandLineArgs $args - Write-Output "<<>>" - - try { - $configFileContent = Get-Content -Raw -Path $ConfigPath - } - catch { - Write-Output (SerializeConfigReadingError($Error[0])) - Throw $Error[0] - } - - # We don't know if the config is actually valid, which is why don't simply dump it as is but - # instead wrap it. - Write-Output (SerializeConfigFileContent($configFileContent)) - - $files = Get-ChildItem -File -Recurse (GetResultsDirectory($configFileContent)) - foreach ($file in $files) { - Write-Output (Get-Content -Raw -ErrorAction 'SilentlyContinue' $file.FullName) - } -} - - -function DetermineConfigPath { - [OutputType([string])] - Param ( - [parameter(Mandatory=$false, Position=0)] - [String[]]$CommandLineArgs - ) - - if ($CommandLineArgs -ne "" -and $CommandLineArgs.Count -gt 0) { - return $CommandLineArgs[0] - } - - $configDir = $env:MK_CONFDIR - if ($null -eq $configDir) { - $configDir = 'C:\ProgramData\checkmk\agent\config' - } - - return Join-Path $configDir 'robotmk.json' -} -function SerializeConfigReadingError { - [OutputType([string])] - Param ( - [parameter(Mandatory=$true, Position=0)] - [System.Management.Automation.ErrorRecord]$Err - ) - return ConvertTo-Json -Compress -InputObject @{ config_reading_error = Out-String -InputObject $Err; } -} - - -function SerializeConfigFileContent { - [OutputType([string])] - Param ( - [parameter(Mandatory=$true, Position=0)] - [string]$ConfigFileContent - ) - return ConvertTo-Json -Compress -InputObject @{ config_file_content = $configFileContent; } -} - -function GetResultsDirectory { - [OutputType([string])] - Param ( - [parameter(Mandatory=$true, Position=0)] - [string]$ConfigFileContent - ) - $configData = ConvertFrom-Json -InputObject $configFileContent - return $configData.results_directory -as [string] -} - -Main $args diff --git a/checkmk_extensions/agent/scheduler_runner.ps1 b/checkmk_extensions/agent/scheduler_runner.ps1 deleted file mode 100644 index f0088fbe..00000000 --- a/checkmk_extensions/agent/scheduler_runner.ps1 +++ /dev/null @@ -1,171 +0,0 @@ -Set-StrictMode -Version 3.0 -$ErrorActionPreference = "Stop" - -class RCCConfig { - [string]$BinaryPath - [string]$SchedulerRobotYamlPath - - RCCConfig([string]$BinaryPath, [string]$SchedulerRobotYamlPath) { - $this.BinaryPath = $BinaryPath - $this.SchedulerRobotYamlPath = $SchedulerRobotYamlPath - } - - static [RCCConfig] ParseRawConfig([object]$RawConfig) { - return [RCCConfig]::new( - $RawConfig.rcc_binary_path -as [string], - $RawConfig.scheduler_robot_yaml_path -as [string] - ) - } -} - -class Config { - [AllowNull()] [RCCConfig]$RCCConfig - [string]$ResultsDirectory - [string]$LogDirectory - - Config( - [string]$ResultsDirectory, - [string]$LogDirectory - ) { - $this.RCCConfig = $null - $this.ResultsDirectory = $ResultsDirectory - $this.LogDirectory = $LogDirectory - } - - Config( - [RCCConfig]$RCCConfig, - [string]$ResultsDirectory, - [string]$LogDirectory - ) { - $this.RCCConfig = $RCCConfig - $this.ResultsDirectory = $ResultsDirectory - $this.LogDirectory = $LogDirectory - } - - static [Config] ParseConfigFile([string]$Path) { - $configFileContent = Get-Content -Raw -Path $Path - $configData = ConvertFrom-Json -InputObject $configFileContent - - $resultsDir = $configData.results_directory -as [string] - $logDir = $configData.log_directory -as [string] - - if($configData.environment -eq "system_python") { - return [Config]::new( - $resultsDir, - $logDir - ) - } - return [Config]::new( - [RCCConfig]::ParseRawConfig($configData.environment), - $resultsDir, - $logDir - ) - } -} - -class CommandSpecification { - [string]$Executable - [string[]]$Arguments - - CommandSpecification([string]$Executable, [string[]]$Arguments) { - $this.Executable = $Executable - $this.Arguments = $Arguments - } -} - -function CreateSchedulerExecCommand { - [CmdletBinding()] - [OutputType([CommandSpecification])] - param ( - [Parameter(Mandatory=$true, Position=0)] - [string]$ConfigPath, - - [Parameter(Mandatory=$true, Position=1)] - [AllowNull()] - [RCCConfig]$RCCConfig - ) - $pythonSchedArgs = @("-m", "robotmk", $ConfigPath) - - if ($null -eq $RCCConfig) { - return [CommandSpecification]::new( - (Get-Command python).Source, - $pythonSchedArgs - ) - } - return [CommandSpecification]::new( - $RCCConfig.BinaryPath, - @( - "task", - "script", - "--controller", - "robotmk", - "--space", - "scheduler", - "--robot", - $RCCConfig.SchedulerRobotYamlPath, - "--", - "python" - ) + $pythonSchedArgs - ) -} - -function StartSchedulerRunner { - [CmdletBinding()] - param ( - [Parameter(Mandatory=$true)] - [string]$ConfigFilePath - ) - - $config = [Config]::ParseConfigFile($ConfigFilePath) - $commandSpec = CreateSchedulerExecCommand $ConfigFilePath $config.RCCConfig - - if (-not (Test-Path $config.LogDirectory)) { - New-Item -Path $config.LogDirectory -ItemType Directory - } - - $selfLogPath = Join-Path $config.LogDirectory "scheduler_runner.log" - $schedulerStdoutLogPath = Join-Path $config.LogDirectory "scheduler_stdout.log" - $schedulerStderrLogPath = Join-Path $config.LogDirectory "scheduler_stderr.log" - - while ($true) { - try { - Start-Process ` - -FilePath $commandSpec.Executable ` - -ArgumentList $commandSpec.Arguments ` - -Wait ` - -NoNewWindow ` - -RedirectStandardOutput $SchedulerStdoutLogPath ` - -RedirectStandardError $SchedulerStderrLogPath - } - catch { - # TODO: Handle errors - WriteLog -Message $_.Exception.Message -LogPath $selfLogPath - } - } -} - -function WriteLog { - [CmdletBinding()] - param ( - [Parameter(Mandatory=$true, Position=0)] - [string]$Message, - - [Parameter(Mandatory=$true, Position=1)] - [string]$LogPath - ) - - if (-not (Test-Path $LogPath)) { - $null = New-Item -Path $LogPath -ItemType File - } - - # Get the current timestamp - $TimeStamp = Get-Date -Format "yyyy-MM-dd HH:mm:ss" - - # Format the log entry - $LogEntry = "$TimeStamp - $Message" - - # Write the log entry to the log file - $LogEntry | Out-File -Append $LogPath -} - -StartSchedulerRunner $args[0] diff --git a/ci b/ci index d8d4f9a2..78348248 100755 --- a/ci +++ b/ci @@ -4,7 +4,6 @@ main() { topdir="$(git rev-parse --show-toplevel)" self="${topdir}/ci" cargo_toml_path="${topdir}/v2/robotmk/Cargo.toml" - checkmk_extensions_dir="${topdir}/checkmk_extensions" mode="${1}" shift @@ -21,25 +20,6 @@ main() { cargo test --manifest-path "${cargo_toml_path}" --all-targets ;; - 'PSScriptAnalyzer-check-all') - pwsh_output=$(pwsh -Command "Invoke-ScriptAnalyzer -Settings ${topdir}/PSScriptAnalyzerSettings.psd1 -Path ${checkmk_extensions_dir} -Recurse") - pwsh_exitcode="$?" - if [ "${pwsh_exitcode}" -eq 0 ]; then { - if [ -z "${pwsh_output}" ]; then { - echo "No static Powershell issues found" - return 0 - } else { - echo "${pwsh_output}" - return 1 - } - fi - } else { - echo "${pwsh_output}" - return "${pwsh_exitcode}" - } - fi - ;; - 'check-all') exit_code=0 for rust_step in fmt-check clippy test @@ -47,8 +27,6 @@ main() { "${self}" "cargo-${rust_step}" exit_code=$(( exit_code + $? )) done - "${self}" "PSScriptAnalyzer-check-all" - return "$(( exit_code + $? ))" ;; *) diff --git a/v2/data/retry_rcc/windows.ps1 b/v2/data/retry_rcc/windows.ps1 deleted file mode 100644 index cc2d0512..00000000 --- a/v2/data/retry_rcc/windows.ps1 +++ /dev/null @@ -1 +0,0 @@ -powershell C:\\robotmk\\checkmk_extensions\agent\scheduler_runner.ps1 "C:\\robotmk\\v2\\data\\retry_rcc\\windows.json" diff --git a/v2/data/retry_suite/windows.ps1 b/v2/data/retry_suite/windows.ps1 deleted file mode 100644 index 663d4074..00000000 --- a/v2/data/retry_suite/windows.ps1 +++ /dev/null @@ -1 +0,0 @@ -powershell C:\\robotmk\\checkmk_extensions\agent\scheduler_runner.ps1 "C:\\robotmk\\v2\\data\\retry_suite\\windows.json" From 890e8f3436a79b1bcae8079e6556bf04645851b3 Mon Sep 17 00:00:00 2001 From: Solomon Jacobs Date: Tue, 24 Oct 2023 09:58:22 +0200 Subject: [PATCH 6/6] Cleanup shell provisioning script We don't use nushell. And our project no longer is python based. --- vagrant/scripts/provision.ps1 | 3 --- 1 file changed, 3 deletions(-) diff --git a/vagrant/scripts/provision.ps1 b/vagrant/scripts/provision.ps1 index e02a6a54..dfb9444d 100644 --- a/vagrant/scripts/provision.ps1 +++ b/vagrant/scripts/provision.ps1 @@ -1,11 +1,8 @@ iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1')) choco install -y --force googlechrome choco install -y --force python -choco install -y --force nushell (new-object net.webclient).DownloadFile("https://nightly.link/elabit/robotmk/actions/artifacts/878920132.zip", "C:\Users\vagrant\Downloads\rcc.zip") Expand-Archive "C:\Users\vagrant\Downloads\rcc.zip" -Force -DestinationPath "C:\Users\vagrant\Downloads\" Copy-Item "C:\Users\vagrant\Downloads\windows64\rcc.exe" -Destination "C:\Users\vagrant\AppData\Local\Microsoft\WindowsApps\rcc.exe" rcc configure identity --do-not-track - -python -m pip install -e "C:\robotmk\"