Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add windows compatibility for diagnose port-conflict #27457

Open
wants to merge 27 commits into
base: main
Choose a base branch
from

Conversation

mwdd146980
Copy link
Contributor

What does this PR do?

Add windows compatibility for the diagnose port conflict suite. This builds on PR#25209.

Motivation

Making this feature available for Windows makes this feature available on all OSes.

Describe how to test/QA your changes

Check that the diagnose suite works properly for Windows:

  • when the agent isn't running and there is no port issue
  • when the agent is running and there is no port issue (the agent is detected as being the agent, so no issue is raised)
  • when some port is used by another process, it is reported
    You can use netcat to bind to a port:
netcat -nvlp 6062

Reviewer's Checklist

  • If known, an appropriate milestone has been selected; otherwise the Triage milestone is set.
  • Use the major_change label if your change either has a major impact on the code base, is impacting multiple teams or is changing important well-established internals of the Agent. This label will be use during QA to make sure each team pay extra attention to the changed behavior. For any customer facing change use a releasenote.
  • A release note has been added or the changelog/no-changelog label has been applied.
  • Changed code has automated tests for its functionality.
  • Adequate QA/testing plan information is provided if the qa/skip-qa label is not applied.
  • At least one team/.. label has been applied, indicating the team(s) that should QA this change.
  • If applicable, docs team has been notified or an issue has been opened on the documentation repo.
  • If applicable, the need-change/operator and need-change/helm labels have been applied.
  • If applicable, the k8s/<min-version> label, indicating the lowest Kubernetes version compatible with this feature.
  • If applicable, the config template has been updated.

@mwdd146980 mwdd146980 added this to the 7.57.0 milestone Jul 9, 2024
@mwdd146980 mwdd146980 requested a review from a team July 9, 2024 20:11
@mwdd146980 mwdd146980 self-assigned this Jul 9, 2024
@mwdd146980 mwdd146980 marked this pull request as ready for review July 9, 2024 20:24
@mwdd146980 mwdd146980 requested a review from a team as a code owner July 9, 2024 20:24
@mwdd146980 mwdd146980 changed the title initial commit windows support for the diagnose port-conflict command Jul 9, 2024
@mwdd146980 mwdd146980 changed the title windows support for the diagnose port-conflict command add windows compatibility for diagnose port-conflict Jul 9, 2024
@pr-commenter
Copy link

pr-commenter bot commented Jul 9, 2024

Regression Detector

Regression Detector Results

Run ID: 7672c513-aeb6-4501-bf38-ee3986aa02ae Metrics dashboard Target profiles

Baseline: 81e640e
Comparison: 1120fe1

Performance changes are noted in the perf column of each table:

  • ✅ = significantly better comparison variant performance
  • ❌ = significantly worse comparison variant performance
  • ➖ = no significant change in performance

No significant changes in experiment optimization goals

Confidence level: 90.00%
Effect size tolerance: |Δ mean %| ≥ 5.00%

There were no significant changes in experiment optimization goals at this confidence level and effect size tolerance.

Fine details of change detection per experiment

perf experiment goal Δ mean % Δ mean % CI trials links
tcp_syslog_to_blackhole ingress throughput +0.27 [+0.22, +0.32] 1 Logs
file_to_blackhole_500ms_latency egress throughput +0.13 [-0.12, +0.38] 1 Logs
idle memory utilization +0.11 [+0.06, +0.16] 1 Logs
file_to_blackhole_1000ms_latency egress throughput +0.04 [-0.45, +0.53] 1 Logs
uds_dogstatsd_to_api_cpu % cpu utilization +0.04 [-0.68, +0.76] 1 Logs
file_to_blackhole_0ms_latency egress throughput +0.02 [-0.32, +0.36] 1 Logs
file_to_blackhole_100ms_latency egress throughput +0.01 [-0.21, +0.23] 1 Logs
tcp_dd_logs_filter_exclude ingress throughput -0.00 [-0.01, +0.01] 1 Logs
uds_dogstatsd_to_api ingress throughput -0.01 [-0.12, +0.10] 1 Logs
file_to_blackhole_300ms_latency egress throughput -0.04 [-0.23, +0.15] 1 Logs
basic_py_check % cpu utilization -0.31 [-2.98, +2.37] 1 Logs
idle_all_features memory utilization -0.40 [-0.51, -0.29] 1 Logs
file_tree memory utilization -0.57 [-0.69, -0.44] 1 Logs
pycheck_lots_of_tags % cpu utilization -1.00 [-3.47, +1.47] 1 Logs
otel_to_otel_logs ingress throughput -1.25 [-2.05, -0.44] 1 Logs

Bounds Checks

perf experiment bounds_check_name replicates_passed
file_to_blackhole_0ms_latency memory_usage 10/10
file_to_blackhole_1000ms_latency memory_usage 10/10
file_to_blackhole_100ms_latency memory_usage 10/10
file_to_blackhole_300ms_latency memory_usage 10/10
file_to_blackhole_500ms_latency memory_usage 10/10
idle memory_usage 10/10

Explanation

A regression test is an A/B test of target performance in a repeatable rig, where "performance" is measured as "comparison variant minus baseline variant" for an optimization goal (e.g., ingress throughput). Due to intrinsic variability in measuring that goal, we can only estimate its mean value for each experiment; we report uncertainty in that value as a 90.00% confidence interval denoted "Δ mean % CI".

For each experiment, we decide whether a change in performance is a "regression" -- a change worth investigating further -- if all of the following criteria are true:

  1. Its estimated |Δ mean %| ≥ 5.00%, indicating the change is big enough to merit a closer look.

  2. Its 90.00% confidence interval "Δ mean % CI" does not contain zero, indicating that if our statistical model is accurate, there is at least a 90.00% chance there is a difference in performance between baseline and comparison variants.

  3. Its configuration does not mark it "erratic".

@pr-commenter
Copy link

pr-commenter bot commented Jul 9, 2024

Test changes on VM

Use this command from test-infra-definitions to manually test this PR changes on a VM:

inv create-vm --pipeline-id=46218115 --os-family=ubuntu

Note: This applies to commit 1120fe1

Copy link
Contributor

@iglendd iglendd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made a fist pass. Need to look again. But the biggest concern is that the functionality returning module name from pid or rather entry require admin privilege. I wondering how did it worked for you at all

if err != windows.ERROR_INSUFFICIENT_BUFFER {
return "", err
}
if desiredLen > 1<<20 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How big is 2 to 20 power in KB?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1024 KB. Is that ok?

owningModuleInfo [16]uint64
}

func moduleInfo[entryType moduleInfoConstraint](entry *entryType, proc *windows.LazyProc) (string, error) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not know how it would work in context of agent.exe process because by default it runs as non-administrator, But a comment from https://learn.microsoft.com/en-us/windows/win32/api/iphlpapi/nf-iphlpapi-getownermodulefromtcpentry

For computers running on Windows Vista or later, accessing the pModuleName and pModulePath members of the TCPIP_OWNER_MODULE_BASIC_INFO structure is limited by user account control (UAC). If an application that calls this function is executed by a user logged on as a member of the Administrators group other than the built-in Administrator, this call will succeed but access to these members returns an empty string unless the application has been marked in the manifest file with a requestedExecutionLevel set to requireAdministrator. If the application on Windows Vista or later lacks this manifest file, a user logged on as a member of the Administrators group other than the built-in Administrator must then be executing the application in an enhanced shell as the built-in Administrator (RunAs administrator) for access to the protected pModuleName and pModulePath members to be allowed.

How did it work for you. It is not a new limitation, builtin netstat has the same problem

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I'm running into a problem because the diagnose command can tell that the APM and process agent ports are being utilized, but it can't tell what process is utilizing them. So we end up getting failures here:

24. --------------
  FAIL apm_config.debug.port
  Diagnosis: Required port 5012 is already used by an another process (PID=2204).

24. --------------
  FAIL apm_config.receiver_port
  Diagnosis: Required port 8126 is already used by an another process (PID=2204).

24. --------------
  FAIL process_config.expvar_port
  Diagnosis: Required port 6062 is already used by an another process (PID=3640).

24. --------------
  FAIL process_config.cmd_port
  Diagnosis: Required port 6162 is already used by an another process (PID=3640).

Another bug is that the list outputs every entry as 24 when it should be rising from 1-24.

Do you have any ideas on how to check the process name from the process ID? Otherwise I might just add some verbiage to say "Check if process ID xxxx is an Agent component or something else."

@mwdd146980 mwdd146980 requested a review from a team as a code owner July 11, 2024 13:40
@mwdd146980 mwdd146980 modified the milestones: 7.57.0, 7.60.0 Oct 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants