fix: reject non-NGINX processes, classify nginx master by cmdline role instead of PPID#1837
Open
ShubhenduSinghF5 wants to merge 2 commits into
Open
fix: reject non-NGINX processes, classify nginx master by cmdline role instead of PPID#1837ShubhenduSinghF5 wants to merge 2 commits into
ShubhenduSinghF5 wants to merge 2 commits into
Conversation
Contributor
|
✅ All required contributors have signed the F5 CLA for this PR. Thank you! |
Codecov Report❌ Patch coverage is
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
Continue to review full report in Codecov by Harness.
🚀 New features to boost your workflow:
|
Author
|
I have hereby read the F5 CLA and agree to its terms |
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.
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.
CONTRIBUTINGdocumentmake install-toolsand have attached any dependency changes to this pull requestREADME.md)