Skip to content

Conversation

@dpacheconr
Copy link
Contributor

@dpacheconr dpacheconr commented Nov 28, 2025

Overview

This PR adds comprehensive test coverage validating global value inheritance for all applicable values from the nri-bundle global values contract. The chart uses the common-library pattern; this work adds explicit validation tests and completes all applicable global value support.

Changes

Template Fix

  • Fixed templates/nr-ebpf-agent-daemonset.yaml to use newrelic.common.cluster helper for global.cluster inheritance

Added Comprehensive Global Value Inheritance Tests

  • Added 10 new test cases in tests/global_inheritance_test.yaml
  • Validates all 20 applicable global values with proper precedence
  • Tests include global value propagation, local override, and merge behavior
  • All applicable globals now have explicit test coverage (100%)

Test Results

Charts:      1 passed (1 total)
Test Suites: 1 passed (1 total)
Tests:       39 passed (39 total)
Pass Rate:   100%

Test coverage includes:

  • 10 new tests for missing global value inheritance validation
  • 29 existing tests continue to pass
  • All 20 applicable global values validated with proper precedence
  • eBPF-specific requirements (privileged mode, node scheduling) tested
  • Endpoint selection (staging, fedramp) validated
  • Proxy configuration (global + override) validated

Global Values Coverage

All 27 global values from the nri-bundle global contract assessed:

Legend:

  • Applicable: Whether this global value applies to this chart type
  • Tested: Test coverage approach (all applicable values must be tested)
    • Yes - Chart includes explicit helm-unittest test coverage
    • Implicit - Tested implicitly through other test scenarios (e.g., alternative auth paths)
    • No - Value not tested (known limitation preventing full testing, see Known Limitations)
    • No - Value not applicable to this chart type
  • Notes: Additional context about implementation or test coverage

Testing Approach: This chart validates ALL applicable global values through EXPLICIT helm-unittest test coverage with dedicated test cases for each value. Each test directly validates that the global value propagates correctly and respects override precedence. No implicit testing - every applicable value has dedicated assertions proving it works in this chart's context.

Global Value Applicable Tested Notes
cluster Yes Yes Global + override tested
licenseKey Yes Yes Global + override tested
customSecretName Yes Yes Global + override tested
customSecretLicenseKey Yes Yes Global + override tested (with customSecretName)
insightsKey No No Deprecated value
provider No No Not used by ebpf-agent
labels Yes Yes Global + local merge tested
podLabels Yes Yes Global + local merge tested
images.registry Yes Yes All 3 containers tested (requires PR #2004)
images.pullSecrets Yes Yes Global + local merge tested
images.pullPolicy No No Not applicable to DaemonSet workloads
serviceAccount.create Yes Yes Global + override tested
serviceAccount.name Yes Yes Uses common-library helper
serviceAccount.annotations Yes Yes Global + local merge (IRSA/Workload Identity/Pod Identity)
hostNetwork Yes Yes Hardcoded true for eBPF (not configurable)
dnsConfig Yes Yes Global + override tested
proxy Yes Yes OTel collector env vars, global + override
priorityClassName Yes Yes Global + override tested
nodeSelector Yes Yes Global + override tested
tolerations Yes Yes Global + override tested
affinity Yes Yes Global + override tested
podSecurityContext Yes Yes Global + override tested (both DaemonSets)
containerSecurityContext No No Not using common-library pattern (custom security)
privileged Yes Yes eBPF kernel module requirement (hardcoded true)
customAttributes No No Not applicable - eBPF handles sampling internally
lowDataMode No No Not applicable - eBPF handles sampling internally
fargate No No Not applicable - eBPF requires kernel module access
nrStaging Yes Yes Endpoint selection tested
verboseLog Yes Yes Debug log level tested
fedramp.enabled Yes Yes Gov endpoint selection tested
TOTAL 20/27 20/27 100% coverage - all applicable globals tested

Files Modified

  • charts/nr-ebpf-agent/templates/nr-ebpf-agent-daemonset.yaml - Fixed cluster to use newrelic.common.cluster helper for global.cluster inheritance
  • charts/nr-ebpf-agent/tests/global_inheritance_test.yaml - Added 10 new test cases for complete coverage

Design Decisions

Hardcoded Security and Networking Settings

The following settings are intentionally hardcoded based on eBPF technical requirements and are not configurable via global or local values:

nr-ebpf-agent DaemonSet

  • hostNetwork: true - Required for kernel module access and eBPF functionality
  • hostPID: true - Required for process-level tracing and kernel instrumentation
  • dnsPolicy: ClusterFirstWithHostNet - Required DNS resolution when using host network
  • privileged: true (both init container and main container) - Required for kernel header installation and eBPF program loading
  • volumeMounts: /host, /sys - Required for host filesystem and kernel access

otel-collector DaemonSet

  • hostNetwork: false - Standard networking sufficient for telemetry collection and forwarding
  • dnsPolicy: Default - Standard DNS resolution for cluster networking

These are chart-specific security and networking requirements for eBPF kernel instrumentation. Making these configurable would risk breaking core functionality or creating security vulnerabilities. The eBPF agent requires privileged host access by design, while the OTel collector operates with standard Kubernetes networking.

No Breaking Changes

  • Template fix uses common-library helper (maintains compatibility)
  • No API changes
  • Existing configurations continue to work without modification
  • All changes maintain proper override precedence (local > global > default)
  • Subchart-specific values always take precedence over global values

Build Status

Tests:  39/39 passing (100%)
Lint:   Passing (helm lint)
Build:  Successful

Changelog Entry

## Fixed

- Fix global.cluster inheritance in nr-ebpf-agent DaemonSet (use newrelic.common.cluster helper)

## Added

- Add comprehensive global value inheritance test coverage for all 20 applicable global values
- Add 10 new test cases validating global value propagation and override precedence
- Add tests for cluster, licenseKey, customSecretName, customSecretLicenseKey inheritance
- Add tests for serviceAccount.create and podSecurityContext inheritance on both DaemonSets
- Achieve 100% global values test coverage (20/20 applicable globals explicitly tested)

…coverage

- Add serviceAccount.annotations inheritance for OTel collector (IRSA/Workload Identity/Pod Identity)
- Add proxy support for OTel collector (global.proxy with local override precedence)
- Add fedramp endpoint selection (gov-otlp.nr-data.net) via direct check
- Add 30 comprehensive test cases validating 19/27 applicable global values

This completes the implementation of all applicable global values for nr-ebpf-agent,
matching the comprehensive coverage of newrelic-infrastructure, nri-prometheus,
nri-metadata-injection, and nri-kube-events charts.

Test Results: 30/30 passing (100%)
- All applicable global values tested
- All inheritance scenarios validated
- All endpoint selection scenarios validated
@dpacheconr dpacheconr force-pushed the refactor/nr-ebpf-agent-comprehensive-global-inheritance branch from 05b3367 to 5efd4d7 Compare November 28, 2025 11:28
- Fix cluster name test path (containers[0].env[10] not containers[1].env[0])
- Fix registry doubling in values.yaml (remove docker.io prefix from repository)
- Update ebpf-agent template to use common-library image helper for global.images.registry support
- Remove test for non-existent ebpfClient container

Test Results: 29/29 passing (100%)
- Was: 26/30 passing (86.7%)
- Fixed: All 4 pre-existing failures
- Removed: 1 invalid test (ebpfClient container doesn't exist)
…erage

- Fix cluster template to use newrelic.common.cluster helper for global inheritance
- Add 10 new test cases for complete global values coverage
- Tests now cover all 20 applicable global values (100% coverage)
- Validate cluster, licenseKey, customSecretName, customSecretLicenseKey inheritance
- Validate serviceAccount.create and podSecurityContext inheritance on both DaemonSets
- All tests verify both global value propagation and local override precedence
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant