fix(windows): use %ProgramFiles% and %ProgramData% for default configuration variables#2203
Open
tsomerve wants to merge 1 commit intonewrelic:masterfrom
Open
fix(windows): use %ProgramFiles% and %ProgramData% for default configuration variables#2203tsomerve wants to merge 1 commit intonewrelic:masterfrom
tsomerve wants to merge 1 commit intonewrelic:masterfrom
Conversation
…lt paths Replace hardcoded C: drive references in Windows path initialization with the appropriate environment variables. Bug 1 (config_windows.go): defaultAgentDir was built from %SystemDrive% + "Program Files" instead of %ProgramFiles%, causing all derived paths (agent_dir, safe_bin_dir, config_dir, logging_home_dir, integration binary search paths) to resolve to C: when %ProgramFiles% is remapped to another drive. Bug 2 (initialize_windows.go): agentTemporaryFolder was hardcoded to C:\ProgramData\..., causing emptyTemporaryFolder() to never create the temp directory when %ProgramData% is on a non-C: drive, since the guard condition cfg.AgentTempDir == agentTemporaryFolder is always false. Affects zip installations on hosts where %ProgramFiles% or %ProgramData% are remapped to a non-system drive (e.g. FedRAMP-restricted environments). Secondary services (fluent-bit, nri-winservices) fail to start as a result.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fix Windows zip installation on hosts where
%ProgramFiles%or%ProgramData%areremapped to a non-system drive (e.g. E: on FedRAMP-restricted environments). Secondary
services — fluent-bit/logging and nri-winservices — fail to start because the agent
resolves their paths to C: instead of the actual installation drive.
Root cause
Two independent bugs share the same class of mistake: using a hardcoded drive letter
instead of the appropriate Windows environment variable.
Bug 1 —
pkg/config/config_windows.godefaultAgentDiris built by concatenating%SystemDrive%with the string"Program Files\New Relic\newrelic-infra". When%ProgramFiles%is remapped to E:but
%SystemDrive%is still C:, every path derived fromdefaultAgentDirresolves toC: — including the fluent-bit exe path,
safe_bin_dir, andconfig_dir.Bug 2 —
cmd/newrelic-infra/initialize/initialize_windows.goagentTemporaryFolderis hardcoded toC:\ProgramData\New Relic\newrelic-infra\tmp.emptyTemporaryFolder()only creates the temp directory whencfg.AgentTempDir == agentTemporaryFolder. When%ProgramData%is remapped to E:,cfg.AgentTempDirresolves toE:\ProgramData\...and the condition is always false —the temp directory is never created on first run, blocking fluent-bit config generation.
Files changed
pkg/config/config_windows.go%ProgramFiles%fordefaultAgentDir; remove unusedinstallationSubdirconstcmd/newrelic-infra/initialize/initialize_windows.goC:\ProgramDataconstant with%ProgramData%env var; addpath/filepathimportTesting
Reproduced on a Windows Server 2019 Azure VM with
%ProgramFiles%and%ProgramData%remapped to E: and the agent installed via zip. Confirmed:
C:\Program Files\...\logging\fluent-bit.exe(wrong drive)E:\Program Files\...\logging\fluent-bit.exe, progresses to full initializationStartup log showing the bug (
agent_diron C: despite agent installed on E:):Workaround for existing customers
Until this fix ships, customers can set all three in
newrelic-infra.yml(note:double-escaped backslashes are required in YAML double-quoted strings):
This does not work around Bug 2. The temp directory must also be pre-created manually: