newrelic-logging: Add Comprehensive Global Value Inheritance and Fix Precedence Bugs#2023
Open
dpacheconr wants to merge 7 commits into
Open
Conversation
dea0fcb to
cfaf8da
Compare
…pport - Implemented proxy support with HTTP_PROXY/HTTPS_PROXY environment variables - Fixed cluster helper precedence (local > global instead of global > local) - Replaced custom labels helpers with common-library for global.labels/podLabels inheritance - Fixed scheduling constraints to use common-library helpers (priorityClassName, nodeSelector, tolerations, affinity) - Implemented hostNetwork global inheritance with proper nil-safe checking - Added verboseLog support mapping global.verboseLog to LOG_LEVEL=debug - Added proxy field to values.yaml with documentation - Created comprehensive test suite with 47 new tests covering all applicable global values - All 107 tests passing (61 existing + 47 new) Global values now supported: - proxy (HTTP_PROXY/HTTPS_PROXY for Fluent Bit) - priorityClassName, nodeSelector, tolerations, affinity (scheduling) - hostNetwork (with global/local precedence) - verboseLog (maps to LOG_LEVEL=debug) - labels, podLabels (via common-library) - cluster (fixed precedence) - All common-library values (images, security contexts, serviceAccount, dnsConfig, lowDataMode, nrStaging) Test Results: 107/107 passing (100% pass rate)
This commit fixes 2 critical bugs discovered during testing: **Critical Bug #1: DaemonSet Selector Label Mismatch** - **Issue**: DaemonSet selector used static labels (app, release) while pod template used common-library labels (app.kubernetes.io/name, app.kubernetes.io/instance) - **Impact**: Kubernetes rejects DaemonSet deployment with error: selector does not match template labels - **Root Cause**: When migrating pod labels to common-library helpers, DaemonSet selector wasn't updated - **Fix**: Updated both daemonset.yaml and daemonset-windows.yaml to use newrelic.common.labels.selectorLabels helper **Critical Bug #2: VerboseLog Boolean Evaluation** - **Issue**: Template compared boolean $verboseLog variable as string "true" instead of boolean - **Impact**: Setting global.verboseLog=true didn't set LOG_LEVEL=debug (silent configuration failure) - **Root Cause**: Common-library verboseLog helper returns boolean value, but template used string comparison - **Fix**: Changed condition from eq $verboseLog "true" to if $verboseLog in both Linux and Windows DaemonSets
…oseLog inheritance - Changed fluentBit.logLevel default from "info" to "" (empty) - This allows global.verboseLog=true to correctly set LOG_LEVEL=debug - Added clear precedence comments in values.yaml Root cause: values.yaml had logLevel: "info" as default, causing the template's if $logLevel condition to always be true, preventing global.verboseLog from being evaluated. Test Results: All 107 helm-unittest tests pass Template validation: - Default (no settings) → LOG_LEVEL="info" - global.verboseLog=true → LOG_LEVEL="debug" - Explicit fluentBit.logLevel → takes precedence
…ues test coverage - Fix customSecretName and customSecretLicenseKey helpers to use Local > Global > Default precedence - Add 16 new test cases for missing global values coverage - Add tests for images.registry, images.pullSecrets, serviceAccount.create, serviceAccount.annotations - Add tests for customSecretName, customSecretLicenseKey, dnsConfig - All 20 applicable global values now have explicit test coverage (100%) - Tests verify both inheritance (global applies when local empty) and precedence (local overrides global)
Define &base anchor on first test set block, apply <<: *base merge throughout so licenseKey is not repeated across all 58 test cases.
5d7db7c to
f47a930
Compare
Contributor
Author
|
Rebased onto master . Updated description. Also added YAML anchors (&base / <<: *base) across all 58 new tests to avoid repeating the base licenseKey setup. |
…pullPolicy support Consolidates changes from PR newrelic#2005 into this branch: - Add persistenceInitContainerImage helper: global.images.registry is prepended to busybox when set; chart-level repository takes precedence - Add imagePullPolicy helper: chart-specific > global.images.pullPolicy > IfNotPresent - Add persistenceInitContainerImagePullPolicy helper: same precedence for init container - Wire daemonset.yaml init container to use image/pullPolicy helpers - Wire main container imagePullPolicy to use imagePullPolicy helper - Add fluentBit.persistenceInitContainerImage values block (repo, tag, pullPolicy) - Add images_test.yaml: LICENSE_KEY secret, pullPolicy precedence, init container image/pullPolicy tests (180 lines, 11 new test cases) Note: global.images.pullSecrets is handled automatically by the common-library renderPullSecrets helper via context; no custom wiring needed. Closes newrelic#2005
…nce to local > global Pre-existing helpers had global checked before local, violating the local > global > default contract. Also adds tests verifying local values take precedence over global for all three helpers.
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.
Overview
This PR adds comprehensive test coverage validating global value inheritance for the newrelic-logging chart, implements 6 missing global values (proxy, priorityClassName, nodeSelector, tolerations, affinity, hostNetwork), and fixes 5 bugs discovered during testing. The chart uses common-library version 1.3.3 for most global value implementations. This work addresses critical gaps identified in the nri-bundle refactor project: proxy support for corporate environments, scheduling constraints, and verbose logging.
Changes
Fixed Pre-Existing Bugs
Bug #1: DaemonSet Selector Label Mismatch
app: newrelic-logging,release: {{.Release.Name}}) while pod template used common-library labels (app.kubernetes.io/name,app.kubernetes.io/instance)selector does not match template labelsdaemonset.yamlanddaemonset-windows.yamlto usenewrelic.common.labels.selectorLabelshelper for selector labelsBug #2: VerboseLog Boolean Evaluation
$verboseLogvariable as string (eq $verboseLog "true") instead of as boolean conditionglobal.verboseLog=truesilently failed—noLOG_LEVEL=debugenv var was setverboseLoghelper returns boolean value, but template used string comparisoneq $verboseLog "true"toif $verboseLogin both Linux and Windows DaemonSetsBugs #3–#5: Wrong Precedence in
licenseKey,nrStaging, andfargateHelpersglobal.*beforelocal.*, violating thelocal > global > defaultcontract_helpers.tplso local is evaluated first in all three helpersAdded Comprehensive Global Value Inheritance Tests
Created test cases in
tests/global-inheritance_test.yamlvalidating all 22 applicable global values. Tests use YAML anchors and aliases to reduce repetition while keeping each case explicit and readable:global.verboseLog: truetoLOG_LEVEL=debugenv varAll tests validate BOTH global inheritance and override precedence scenarios.
Implemented Missing Global Values
templates/daemonset.yaml & templates/daemonset-windows.yaml:
proxyenvironment variables (HTTP_PROXY/HTTPS_PROXY) with global/local precedence using nil-safe template logicpriorityClassNamewithnewrelic.common.priorityClassNamehelper (common-library 1.3.3+)nodeSelectorwithnewrelic.common.nodeSelectorhelper while preserving Windows OS labelstolerationswithnewrelic.common.tolerationshelperaffinitylogic withnewrelic.common.affinityhelper while preserving Fargate exclusionhostNetworkwith proper nil-safe global inheritance logic (avoids implicitfalsedefault)verboseLog→ LOG_LEVEL mapping (verboseLog=true sets LOG_LEVEL=debug, overrides local logLevel)newrelic.common.labelsfor resource labels andnewrelic.common.labels.podLabelsfor pod labelsnewrelic.common.labels.selectorLabelshelper (fixes selector mismatch)templates/_helpers.tpl:
newrelic-logging.licenseKeyhelper precedence: now implementslocal > global(wasglobal > local)newrelic-logging.clusterhelper precedence: now implementslocal > global(wasglobal > local)newrelic-logging.customSecretNamehelper precedence: now implementslocal > global(wasglobal > local)newrelic-logging.customSecretKeyhelper precedence: now implementslocal > global(wasglobal > local)newrelic.nrStaginghelper precedence: now implementslocal > global(wasglobal > local)newrelic.fargatehelper precedence: now implementslocal > global(wasglobal > local)values.yaml:
proxy: ""field with documentation for HTTP/HTTPS proxy configurationfluentBit.logLeveldefault from"info"to""(empty string), enablingglobal.verboseLoginheritanceTest Results
Global Values Coverage
All 27 global values from the nri-bundle global contract assessed:
Legend:
Yes- Chart includes explicit helm-unittest test coverage with dedicated test cases and assertionsNo- Value not applicable to this chart typeglobal-inheritance_test.yaml(2 tests) - Fixed precedence helper (local > global)global-inheritance_test.yaml(4 tests) - Fixed precedence + EU endpoint selection validates local winsglobal-inheritance_test.yaml(2 tests) - Fixed precedence (local > global)global-inheritance_test.yaml(2 tests) - Tested alongside customSecretNameglobal-inheritance_test.yaml(2 tests) - NEWLY ADDED via common-libraryglobal-inheritance_test.yaml(2 tests) - NEWLY ADDED via common-libraryglobal-inheritance_test.yaml(2 tests) +images_test.yaml- Existing coverage maintainedglobal-inheritance_test.yaml(2 tests) +images_test.yaml- Existing coverage maintainedimages_test.yaml- Existing coverage maintainedglobal-inheritance_test.yaml(2 tests) - NEWLY ADDEDglobal-inheritance_test.yaml(3 tests) - NEWLY ADDEDglobal-inheritance_test.yaml(2 tests) +serviceAccount_test.yaml- Existing coverage maintainedglobal-inheritance_test.yaml(4 tests) - NEWLY FIXED (now nil-safe)global-inheritance_test.yaml(4 tests) +dns_config_test.yamlglobal-inheritance_test.yaml(3 tests) - NEWLY ADDEDglobal-inheritance_test.yaml(3 tests) - NEWLY FIXED (now uses common-library)global-inheritance_test.yaml(3 tests) - NEWLY FIXED (now uses common-library)global-inheritance_test.yaml(3 tests) - NEWLY FIXED (now uses common-library)global-inheritance_test.yaml(4 tests) - NEWLY FIXED (preserves Fargate exclusion)global-inheritance_test.yaml(2 tests)global-inheritance_test.yaml(2 tests)global-inheritance_test.yaml(3 tests) - Reduces log attributesglobal-inheritance_test.yaml(3 tests) - Fixed precedence (local > global) + affinity testsglobal-inheritance_test.yaml(4 tests) - Fixed precedence (local > global) + endpoint selectionglobal-inheritance_test.yaml(4 tests) - NEWLY FIXED (boolean evaluation)Files Modified
Templates (3 files)
templates/daemonset.yaml- Fixed selector labels, verboseLog boolean evaluation, added proxy env vars, scheduling helpers, hostNetwork, labelstemplates/daemonset-windows.yaml- Identical changes to Linux DaemonSet for Windows node compatibilitytemplates/_helpers.tpl- Fixed precedence (local > global) for licenseKey, cluster, customSecretName, customSecretKey, nrStaging, and fargate helpersValues (1 file)
values.yaml- Added proxy field with documentation, fixed logLevel default (empty string enables global.verboseLog inheritance)Tests (1 file)
tests/global-inheritance_test.yaml- Comprehensive helm-unittest test cases validating all applicable global values (new file, uses YAML anchors for base set)No Breaking Changes
All changes maintain backward compatibility:
"info"to""- functionally identical (logLevel honored when explicitly set, global.verboseLog honored when not)Migration Path: Existing deployments continue to work without modification. Users can optionally set global values for cleaner configuration.
Build Status