diff --git a/build/embed/fluent-bit.version b/build/embed/fluent-bit.version index fac7403ed..338ca8738 100644 --- a/build/embed/fluent-bit.version +++ b/build/embed/fluent-bit.version @@ -6,4 +6,6 @@ # OS, newrelic_plugin_version, fluent-bit linux,1.19.1 -windows,1.19.1,1.9.3 +windows,1.19.1,3.0.6 +#To be removed on removal of the ff fluent_bit_19 +windows-legacy,1.19.1,1.9.3 diff --git a/build/package/windows/newrelic-infra-386-installer/newrelic-infra/Product.wxs b/build/package/windows/newrelic-infra-386-installer/newrelic-infra/Product.wxs index b62487f1c..554c0b234 100644 --- a/build/package/windows/newrelic-infra-386-installer/newrelic-infra/Product.wxs +++ b/build/package/windows/newrelic-infra-386-installer/newrelic-infra/Product.wxs @@ -37,6 +37,7 @@ + @@ -44,6 +45,7 @@ + @@ -70,7 +72,8 @@ - + + @@ -99,6 +102,11 @@ + + + + + @@ -243,6 +251,7 @@ + @@ -267,6 +276,32 @@ + + + + + + + + + + + + + + + + + + diff --git a/build/package/windows/newrelic-infra-amd64-installer/newrelic-infra/Product.wxs b/build/package/windows/newrelic-infra-amd64-installer/newrelic-infra/Product.wxs index db34ff4c4..51e354be8 100644 --- a/build/package/windows/newrelic-infra-amd64-installer/newrelic-infra/Product.wxs +++ b/build/package/windows/newrelic-infra-amd64-installer/newrelic-infra/Product.wxs @@ -37,12 +37,14 @@ + + @@ -71,7 +73,8 @@ - + + @@ -99,6 +102,11 @@ + + + + + @@ -226,6 +234,7 @@ + @@ -250,6 +259,32 @@ + + + + + + + + + + + + + + + + + + diff --git a/build/windows/scripts/embed_ohis.ps1 b/build/windows/scripts/embed_ohis.ps1 index 5780b6f32..f67ab264f 100644 --- a/build/windows/scripts/embed_ohis.ps1 +++ b/build/windows/scripts/embed_ohis.ps1 @@ -73,17 +73,33 @@ Function EmbedPrometheus { Function EmbedFluentBit { Write-Output "--- Embedding fluent-bit" + # + # td-agent-bit (1.9) + $pluginLegacyVersion = GetFluentBitLegacyPluginVersion + $nrfbLegacyVersion = GetFluentBitLegacyVersion + + [string]$pluginLegacyUrl = "https://github.com/newrelic/newrelic-fluent-bit-output/releases/download/v$pluginLegacyVersion/out_newrelic-windows-$arch-$pluginLegacyVersion.dll" + DownloadFile -dest:"$downloadPath\logging\nrfb" -outFile:"out_newrelic.dll" -url:"$pluginLegacyUrl" + + [string]$nrfbUrl = "https://github.com/newrelic-experimental/fluent-bit-package/releases/download/$nrfbLegacyVersion/fb-windows-$arch.zip" + DownloadAndExtractZip -dest:"$downloadPath\logging\nrfb" -url:"$nrfbUrl" + # + + ## fluent-bit (3.x) $pluginVersion = GetFluentBitPluginVersion $nrfbVersion = GetFluentBitVersion [string]$pluginUrl = "https://github.com/newrelic/newrelic-fluent-bit-output/releases/download/v$pluginVersion/out_newrelic-windows-$arch-$pluginVersion.dll" - DownloadFile -dest:"$downloadPath\logging\nrfb" -outFile:"out_newrelic.dll" -url:"$pluginUrl" + DownloadFile -dest:"$downloadPath\logging\nrfb2" -outFile:"out_newrelic.dll" -url:"$pluginUrl" - [string]$nrfbUrl = "https://github.com/newrelic-experimental/fluent-bit-package/releases/download/$nrfbVersion/fb-windows-$arch.zip" - DownloadAndExtractZip -dest:"$downloadPath\logging\nrfb" -url:"$nrfbUrl" + [string]$nrfbUrl = "https://logging-fb-windows-packages.s3.us-east-2.amazonaws.com/fb-windows-$nrfbVersion-$arch.zip" + DownloadAndExtractZip -dest:"$downloadPath\logging\nrfb2" -url:"$nrfbUrl" if (-Not $skipSigning) { + # SignExecutable -executable "$downloadPath\logging\nrfb\fluent-bit.exe" + # + SignExecutable -executable "$downloadPath\logging\nrfb2\fluent-bit.exe" } } diff --git a/build/windows/scripts/functions.ps1 b/build/windows/scripts/functions.ps1 index ca91a0eb4..617c54552 100644 --- a/build/windows/scripts/functions.ps1 +++ b/build/windows/scripts/functions.ps1 @@ -30,10 +30,33 @@ Function GetIntegrationVersion { return $version } +# +Function GetFluentBitLegacyPluginVersion { + $dir = "$scriptPath\..\..\embed" + + $pluginVersion = $(Get-Content "$dir/fluent-bit.version" | %{if($_ -match "^windows-legacy,") { $_.Split(',')[1]; }}) + if ([string]::IsNullOrWhitespace($pluginVersion)) { + throw "failed to read nr fluent-bit plugin version" + } + + return $pluginVersion +} + +Function GetFluentBitLegacyVersion { + $dir = "$scriptPath\..\..\embed" + $fbVersion = $(Get-Content "$dir/fluent-bit.version" | %{if($_ -match "^windows-legacy,") { $_.Split(',')[2]; }}) + if ([string]::IsNullOrWhitespace($fbVersion)) { + throw "failed to read nr fluent-bit 1.x version" + } + + return $fbVersion +} +# + Function GetFluentBitPluginVersion { $dir = "$scriptPath\..\..\embed" - $pluginVersion = $(Get-Content "$dir/fluent-bit.version" | %{if($_ -match "^windows") { $_.Split(',')[1]; }}) + $pluginVersion = $(Get-Content "$dir/fluent-bit.version" | %{if($_ -match "^windows,") { $_.Split(',')[1]; }}) if ([string]::IsNullOrWhitespace($pluginVersion)) { throw "failed to read nr fluent-bit plugin version" } @@ -42,9 +65,9 @@ Function GetFluentBitPluginVersion { } Function GetFluentBitVersion { $dir = "$scriptPath\..\..\embed" - $fbVersion = $(Get-Content "$dir/fluent-bit.version" | %{if($_ -match "^windows") { $_.Split(',')[2]; }}) + $fbVersion = $(Get-Content "$dir/fluent-bit.version" | %{if($_ -match "^windows,") { $_.Split(',')[2]; }}) if ([string]::IsNullOrWhitespace($fbVersion)) { - throw "failed to read nr fluent-bit version" + throw "failed to read nr fluent-bit 3.x version" } return $fbVersion diff --git a/cmd/newrelic-infra/newrelic-infra.go b/cmd/newrelic-infra/newrelic-infra.go index b8d7a59fb..ec47366ed 100644 --- a/cmd/newrelic-infra/newrelic-infra.go +++ b/cmd/newrelic-infra/newrelic-infra.go @@ -455,6 +455,7 @@ func initializeAgentAndRun(c *config.Config, logFwCfg config.LogForward) error { os.Exit(1) } + fbVerbose := c.Log.Level == config.LogLevelTrace && c.Log.HasIncludeFilter(config.TracesFieldName, config.SupervisorTrace) confTempFolder := filepath.Join(c.AgentTempDir, v4.FbConfTempFolderNameDefault) fbIntCfg := v4.NewFBSupervisorConfig( ffManager, @@ -464,7 +465,7 @@ func initializeAgentAndRun(c *config.Config, logFwCfg config.LogForward) error { c.FluentBitExePath, c.FluentBitNRLibPath, c.FluentBitParsersPath, - logFwCfg.FluentBitVerbose, + fbVerbose, confTempFolder, ) diff --git a/internal/agent/cmdchannel/fflag/ffhandler.go b/internal/agent/cmdchannel/fflag/ffhandler.go index 038a51d80..0e37a85a8 100644 --- a/internal/agent/cmdchannel/fflag/ffhandler.go +++ b/internal/agent/cmdchannel/fflag/ffhandler.go @@ -26,7 +26,7 @@ const ( FlagProtocolV4 = "protocol_v4_enabled" FlagFullProcess = "full_process_sampling" FlagDmRegisterDeprecated = "dm_register_deprecated" - FlagFluentBit19 = "fluent_bit_19" + FlagFluentBit19 = "fluent_bit_19_win" // Config CfgYmlRegisterEnabled = "register_enabled" CfgYmlParallelizeInventory = "inventory_queue_len" diff --git a/internal/agent/cmdchannel/fflag/ffhandler_test.go b/internal/agent/cmdchannel/fflag/ffhandler_test.go index c82cf1d64..af04aee9f 100644 --- a/internal/agent/cmdchannel/fflag/ffhandler_test.go +++ b/internal/agent/cmdchannel/fflag/ffhandler_test.go @@ -310,7 +310,7 @@ func TestSrv_InitialFetch_EnablesFb19(t *testing.T) { "name": "set_feature_flag", "arguments": { "category": "Infra_Agent", - "flag": "fluent_bit_19", + "flag": "fluent_bit_19_win", "enabled": true } } diff --git a/pkg/integrations/v4/supervisor_fb_conf_linux.go b/pkg/integrations/v4/supervisor_fb_conf_linux.go index c0c51b2c0..f76dd3f8a 100644 --- a/pkg/integrations/v4/supervisor_fb_conf_linux.go +++ b/pkg/integrations/v4/supervisor_fb_conf_linux.go @@ -19,17 +19,17 @@ const ( defaultFluentBitExecutable2 = "fluent-bit" ) -func (c *fBSupervisorConfig) defaultLoggingBinDir(ffExists bool, ffEnabled bool) string { - if (ffExists && ffEnabled) || onlyTdAgentInstalled() { +func (c *fBSupervisorConfig) defaultLoggingBinDir(_ bool, _ bool) string { + if onlyTdAgentInstalled() { return defaultLoggingBinDir1 } return defaultLoggingBinDir2 } -func (c *fBSupervisorConfig) defaultFluentBitExePath(ffExists bool, ffEnabled bool, loggingBinDir string) string { +func (c *fBSupervisorConfig) defaultFluentBitExePath(_ bool, _ bool, loggingBinDir string) string { defaultFluentBitExe := defaultFluentBitExecutable2 - if (ffExists && ffEnabled) || onlyTdAgentInstalled() { + if onlyTdAgentInstalled() { defaultFluentBitExe = defaultFluentBitExecutable1 } diff --git a/pkg/integrations/v4/supervisor_fb_conf_linux_test.go b/pkg/integrations/v4/supervisor_fb_conf_linux_test.go index f6755367e..29a62be00 100644 --- a/pkg/integrations/v4/supervisor_fb_conf_linux_test.go +++ b/pkg/integrations/v4/supervisor_fb_conf_linux_test.go @@ -40,7 +40,7 @@ func Test_defaultLoggingBinDir(t *testing.T) { name: "enabled ff", ffExists: true, ffEnabled: true, - expectedBinDir: "/opt/td-agent-bit/bin", + expectedBinDir: "/opt/fluent-bit/bin", }, } @@ -86,7 +86,7 @@ func Test_defaultFluentBitExePath(t *testing.T) { name: "enabled ff", ffExists: true, ffEnabled: true, - expectedExePath: "/opt/td-agent-bit/bin/td-agent-bit", + expectedExePath: "/opt/fluent-bit/bin/fluent-bit", }, } diff --git a/pkg/integrations/v4/supervisor_fb_conf_windows.go b/pkg/integrations/v4/supervisor_fb_conf_windows.go index 76b00fb61..08da816f1 100644 --- a/pkg/integrations/v4/supervisor_fb_conf_windows.go +++ b/pkg/integrations/v4/supervisor_fb_conf_windows.go @@ -8,7 +8,7 @@ import "path/filepath" const ( // defaults for td-agent-bit (<=1.9). - defaultLoggingBinDir1 = "logging" + defaultLoggingBinDir1 = "logging-legacy" // defaults for fluent-bit (>=2.0). defaultLoggingBinDir2 = "logging" // both versions have the same name. diff --git a/pkg/integrations/v4/supervisor_fb_conf_windows_test.go b/pkg/integrations/v4/supervisor_fb_conf_windows_test.go index f0bbe7e28..8f7460ee5 100644 --- a/pkg/integrations/v4/supervisor_fb_conf_windows_test.go +++ b/pkg/integrations/v4/supervisor_fb_conf_windows_test.go @@ -42,7 +42,7 @@ func Test_defaultLoggingBinDir(t *testing.T) { name: "enabled ff", ffExists: true, ffEnabled: true, - expectedLoggingBinDir: "C:\\some\\agent\\dir\\integrations_dir\\logging", + expectedLoggingBinDir: "C:\\some\\agent\\dir\\integrations_dir\\logging-legacy", }, } @@ -90,7 +90,7 @@ func Test_defaultFluentBitExePath(t *testing.T) { name: "enabled ff", ffExists: true, ffEnabled: true, - expectedExePath: "C:\\some\\agent\\dir\\integrations_dir\\logging\\fluent-bit.exe", + expectedExePath: "C:\\some\\agent\\dir\\integrations_dir\\logging-legacy\\fluent-bit.exe", }, } diff --git a/pkg/integrations/v4/supervisor_fb_test.go b/pkg/integrations/v4/supervisor_fb_test.go index 2cd117d6c..9d1e7b9c8 100644 --- a/pkg/integrations/v4/supervisor_fb_test.go +++ b/pkg/integrations/v4/supervisor_fb_test.go @@ -311,7 +311,7 @@ func TestNewSupervisorConfig(t *testing.T) { integrationsDir: "integrationsDir", ffEnabled: true, ffExists: true, - expectedPathLinux: filepath.Join("loggingBinDir", "td-agent-bit"), + expectedPathLinux: filepath.Join("loggingBinDir", "fluent-bit"), expectedPathWindows: filepath.Join("loggingBinDir", "fluent-bit.exe"), }, { @@ -327,8 +327,8 @@ func TestNewSupervisorConfig(t *testing.T) { ffExists: true, integrationsDir: "integrationsDir", agentDir: "some_agent_dir", - expectedPathLinux: filepath.Join("/opt/td-agent-bit/bin", "td-agent-bit"), - expectedPathWindows: filepath.Join("some_agent_dir", "integrationsDir", "logging", "fluent-bit.exe"), + expectedPathLinux: filepath.Join("/opt/fluent-bit/bin", "fluent-bit"), + expectedPathWindows: filepath.Join("some_agent_dir", "integrationsDir", "logging-legacy", "fluent-bit.exe"), }, } diff --git a/test/packaging/ansible/log-forwarder.yml b/test/packaging/ansible/log-forwarder.yml index b6ac84748..7469256e3 100644 --- a/test/packaging/ansible/log-forwarder.yml +++ b/test/packaging/ansible/log-forwarder.yml @@ -139,4 +139,55 @@ name: logging when: log_forwader_supported is defined + +- name: log-forwarder-windows + hosts: windows_amd64 + gather_facts: yes + + pre_tasks: + - name: Initial cleanup # Only required for shared infra. + include_role: + name: cleanup + + tasks: + - name: Log forwarder tests suite + vars: + env_vars: + + block: + + - name: Define variable with supported versions + set_fact: + log_forwader_supported: true + when: inventory_hostname is search("windows") + + - name: repo setup + include_role: + name: repo-setup + when: log_forwader_supported is defined + + - name: setup config + include_role: + name: setup-config + vars: + log_level: 'debug' + log_forward: 'true' + when: log_forwader_supported is defined + + - name: install agent + include_role: + name: agent-install + when: log_forwader_supported is defined + + # Not available for ARM yet + - name: Log forwarder + include_role: + name: logging + when: log_forwader_supported is defined + + always: + - name: Final cleanup # Only required for shared infra. + include_role: + name: cleanup + ... diff --git a/test/packaging/ansible/roles/assert-version/tasks/assert-version-Win32NT.yaml b/test/packaging/ansible/roles/assert-version/tasks/assert-version-Win32NT.yaml new file mode 100644 index 000000000..770affa4f --- /dev/null +++ b/test/packaging/ansible/roles/assert-version/tasks/assert-version-Win32NT.yaml @@ -0,0 +1,12 @@ +--- + +- name: Assert expected version + ansible.windows.win_command: '"C:\Program Files\New Relic\newrelic-infra\newrelic-infra.exe" "--version"' + register: check + +- name: Stdout from version grep + fail: + msg: "{{ check.stdout | regex_search('New Relic Infrastructure Agent version: ([^,]+)', '\\1') | first }} does not match {{ target_agent_version }}" + when: "{{ check.stdout | regex_search('New Relic Infrastructure Agent version: ([^,]+)', '\\1') | first != target_agent_version }}" + +... \ No newline at end of file diff --git a/test/packaging/ansible/roles/cleanup/tasks/files-Win32NT.yaml b/test/packaging/ansible/roles/cleanup/tasks/files-Win32NT.yaml new file mode 100644 index 000000000..435d1db79 --- /dev/null +++ b/test/packaging/ansible/roles/cleanup/tasks/files-Win32NT.yaml @@ -0,0 +1,10 @@ +--- + +- name: remove infra-agent files and directories + ansible.windows.win_file: + path: "{{ item }}" + state: absent + loop: + - 'C:\Program Files\New Relic\newrelic-infra' + +... diff --git a/test/packaging/ansible/roles/cleanup/tasks/package-Windows.yaml b/test/packaging/ansible/roles/cleanup/tasks/package-Windows.yaml new file mode 100644 index 000000000..8486482ec --- /dev/null +++ b/test/packaging/ansible/roles/cleanup/tasks/package-Windows.yaml @@ -0,0 +1,14 @@ +--- + +- name: Get infra agent productID + ansible.windows.win_powershell: + script: (Get-WmiObject win32_product | where{$_.name -eq "New Relic Infrastructure Agent"}).IdentifyingNumber + register: infra_agent_info + +- name: Uninstall infra agent + win_package: + product_id: "{{ infra_agent_info.output[0] }}" + state: absent + when: infra_agent_info.output[0] != None + +... diff --git a/test/packaging/ansible/roles/cleanup/tasks/service-Win32NT.yaml b/test/packaging/ansible/roles/cleanup/tasks/service-Win32NT.yaml new file mode 100644 index 000000000..3b576e250 --- /dev/null +++ b/test/packaging/ansible/roles/cleanup/tasks/service-Win32NT.yaml @@ -0,0 +1,10 @@ +--- + +- name: stop newrelic-infra service + win_service: + name: New Relic Infrastructure Agent + state: stopped + ignore_errors: true + failed_when: false + +... diff --git a/test/packaging/ansible/roles/package-uninstall/tasks/package-Windows.yaml b/test/packaging/ansible/roles/package-uninstall/tasks/package-Windows.yaml new file mode 100644 index 000000000..8486482ec --- /dev/null +++ b/test/packaging/ansible/roles/package-uninstall/tasks/package-Windows.yaml @@ -0,0 +1,14 @@ +--- + +- name: Get infra agent productID + ansible.windows.win_powershell: + script: (Get-WmiObject win32_product | where{$_.name -eq "New Relic Infrastructure Agent"}).IdentifyingNumber + register: infra_agent_info + +- name: Uninstall infra agent + win_package: + product_id: "{{ infra_agent_info.output[0] }}" + state: absent + when: infra_agent_info.output[0] != None + +...