Skip to content

Fix command for java auto instrumentation on windows nodes #188

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

Merged
merged 5 commits into from
Jun 19, 2024

Conversation

lisguo
Copy link
Contributor

@lisguo lisguo commented Jun 18, 2024

Issue #, if available: N/A

Description of changes:

  • Fix command for java auto instrumentation on windows to use cmd.exe
  • Modifies the injection logic to use the following command to copy the instrumentation jar:
Command:
      CMD
      /c
      copy
      javaagent.jar
      \otel-auto-instrumentation-java

The above will be injected for pods with the kubernetes.io/os: windows node selector. The EKS documentation requires this selector be added to pods.


This will not enable support for windows. The operator still needs a windows build of the auto instrumentation image.

Tested using a dev build on a windows node and saw java app running:

Defaulted container "sample-app" out of: sample-app, opentelemetry-auto-instrumentation-java (init)
Picked up JAVA_TOOL_OPTIONS:  -javaagent:/otel-auto-instrumentation-java/javaagent.jar
OpenJDK 64-Bit Server VM warning: Sharing is only supported for boot loader classes because bootstrap classpath has been appended
[otel.javaagent 2024-06-18 15:01:56:503 +0000] [main] INFO io.opentelemetry.javaagent.tooling.VersionLogger - opentelemetry-javaagent - version: 1.33.0-aws-SNAPSHOT
[otel.javaagent 2024-06-18 15:01:58:070 +0000] [main] INFO software.amazon.opentelemetry.javaagent.providers.AwsApplicationSignalsCustomizerProvider - AWS Application Signals enabled

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@lisguo lisguo requested review from movence and okankoAMZ June 18, 2024 15:44
Copy link
Contributor

@okankoAMZ okankoAMZ left a comment

Choose a reason for hiding this comment

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

just have a small question


var (
commandLinux = []string{"cp", "/javaagent.jar", javaInstrMountPath + "/javaagent.jar"}
commandWindows = []string{"CMD", "/c", "copy", "javaagent.jar", javaInstrMountPathWindows}
Copy link
Contributor

Choose a reason for hiding this comment

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

Just curious is there a reason why we use CMD /c instead of Copy-Item?

Copy link
Contributor Author

@lisguo lisguo Jun 18, 2024

Choose a reason for hiding this comment

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

windows nanoserver doesn't come with powershell so the sdk container wouldn't be able to run Copy-Item directly:

    Command:
      Copy-Item
      javaagent.jar
      \otel-auto-instrumentation-java
    State:          Waiting
      Reason:       RunContainerError
    Last State:     Terminated
      Reason:       StartError
      Message:      failed to start containerd task "a8f40a5dc034e4a566e577b42d0e86cd8d9e96ca70817c696b6a57bd5f32d39b": hcs::System::CreateProcess a8f40a5dc034e4a566e577b42d0e86cd8d9e96ca70817c696b6a57bd5f32d39b: The system cannot find the file specified.: unknown
      Exit Code:    128
...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated the description to not say powershell, but just cmd.exe

javaInitContainerName = initContainerName + "-java"
javaVolumeName = volumeName + "-java"
javaInstrMountPath = "/otel-auto-instrumentation-java"
javaInstrMountPathWindows = "\\otel-auto-instrumentation-java"
Copy link
Contributor

Choose a reason for hiding this comment

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

do we need a test case for this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Test case was added in func TestInjectJavaagentWindows

@lisguo lisguo merged commit bb0bd1c into aws:main Jun 19, 2024
6 checks passed
@lisguo lisguo deleted the windows branch June 19, 2024 14:14
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.

3 participants