Skip to content

fix: reject non-NGINX processes, classify nginx master by cmdline role instead of PPID#1837

Open
ShubhenduSinghF5 wants to merge 2 commits into
nginx:dev-v2from
ShubhenduSinghF5:ss-fix-nginx-process
Open

fix: reject non-NGINX processes, classify nginx master by cmdline role instead of PPID#1837
ShubhenduSinghF5 wants to merge 2 commits into
nginx:dev-v2from
ShubhenduSinghF5:ss-fix-nginx-process

Conversation

@ShubhenduSinghF5

@ShubhenduSinghF5 ShubhenduSinghF5 commented Jul 23, 2026

Copy link
Copy Markdown

EnvironmentType.Processes() inferred IsMaster by checking whether a candidate nginx process's PPID was itself in the discovered nginx-process set — any nginx-named process whose parent was not another nginx process was flagged as a master.

This breaks when another tool injects a helper process that borrows the nginx: cmdline convention and runs under PID 1. A concrete case observed in the field: Dynatrace OneAgent injects a [nginx: OneAgent companion process] (name nginx, ppid 1), which the PPID heuristic classifies as a second master. Downstream, UpdateNginxDetailsFromProcesses keys nginxDetailsMap by the derived nginxId, both "masters" collide on the same key, and Go's non-deterministic map iteration decides which PID the agent sends the reload SIGHUP to. When the impostor wins, nginx -s reload silently no-ops while the agent still reports success.

Align v2's nginx master-process classification with the approach already used in NGINX Agent v3 [pkg/nginxprocess.Process.IsMaster] identify the master by the nginx-reported role prefix on the process command line rather than by parent-PID inference.

Proposed changes

Add [isNginxMaster(cmd string) bool] — mirrors the v3 implementation, checks for the nginx: master / {nginx-debug} nginx: master cmdline prefix.
Use it in Processes() in place of the PPID-based inference.
[isNginxProcess] (the collection filter) is unchanged; only role classification moves from PPID to cmdline.

Checklist

Before creating a PR, run through this checklist and mark each as complete.

  • I have read the CONTRIBUTING document
  • I have run make install-tools and have attached any dependency changes to this pull request
  • If applicable, I have added tests that prove my fix is effective or that my feature works
  • If applicable, I have checked that any relevant tests pass after adding my changes
  • If applicable, I have updated any relevant documentation (README.md)
  • If applicable, I have tested my cross-platform changes on Ubuntu 22, Redhat 8, SUSE 15 and FreeBSD 13

@ShubhenduSinghF5
ShubhenduSinghF5 requested a review from a team as a code owner July 23, 2026 10:29
@github-actions github-actions Bot added bug Something isn't working chore Pull requests for routine tasks labels Jul 23, 2026
@github-actions

github-actions Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

✅ All required contributors have signed the F5 CLA for this PR. Thank you!
Posted by the CLA Assistant Lite bot.

@codecov

codecov Bot commented Jul 23, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 75.00000% with 1 line in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (dev-v2@be022db). Learn more about missing BASE report.

Files with missing lines Patch % Lines
src/core/environment.go 75.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##             dev-v2    #1837   +/-   ##
=========================================
  Coverage          ?   52.33%           
=========================================
  Files             ?       51           
  Lines             ?     3518           
  Branches          ?        0           
=========================================
  Hits              ?     1841           
  Misses            ?     1531           
  Partials          ?      146           
Files with missing lines Coverage Δ
src/core/environment.go 57.36% <75.00%> (ø)

Continue to review full report in Codecov by Harness.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update be022db...c5af143. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ShubhenduSinghF5 ShubhenduSinghF5 changed the title fix: reject non-NGINX processes that borrow the "nginx:" cmdline prefix fix: reject non-NGINX processes, classify nginx master by cmdline role instead of PPID Jul 23, 2026
@ShubhenduSinghF5

Copy link
Copy Markdown
Author

I have hereby read the F5 CLA and agree to its terms

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working chore Pull requests for routine tasks

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant