-
Notifications
You must be signed in to change notification settings - Fork 28
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,11 +10,17 @@ import ( | |
) | ||
|
||
const ( | ||
envJavaToolsOptions = "JAVA_TOOL_OPTIONS" | ||
javaJVMArgument = " -javaagent:/otel-auto-instrumentation-java/javaagent.jar" | ||
javaInitContainerName = initContainerName + "-java" | ||
javaVolumeName = volumeName + "-java" | ||
javaInstrMountPath = "/otel-auto-instrumentation-java" | ||
envJavaToolsOptions = "JAVA_TOOL_OPTIONS" | ||
javaJVMArgument = " -javaagent:/otel-auto-instrumentation-java/javaagent.jar" | ||
javaInitContainerName = initContainerName + "-java" | ||
javaVolumeName = volumeName + "-java" | ||
javaInstrMountPath = "/otel-auto-instrumentation-java" | ||
javaInstrMountPathWindows = "\\otel-auto-instrumentation-java" | ||
) | ||
|
||
var ( | ||
commandLinux = []string{"cp", "/javaagent.jar", javaInstrMountPath + "/javaagent.jar"} | ||
commandWindows = []string{"CMD", "/c", "copy", "javaagent.jar", javaInstrMountPathWindows} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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? There was a problem hiding this comment. Choose a reason for hiding this commentThe 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:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Updated the description to not say powershell, but just cmd.exe |
||
) | ||
|
||
func injectJavaagent(javaSpec v1alpha1.Java, pod corev1.Pod, index int) (corev1.Pod, error) { | ||
|
@@ -59,10 +65,15 @@ func injectJavaagent(javaSpec v1alpha1.Java, pod corev1.Pod, index int) (corev1. | |
}, | ||
}}) | ||
|
||
command := commandLinux | ||
if pod.Spec.NodeSelector["kubernetes.io/os"] == "windows" { | ||
command = commandWindows | ||
} | ||
|
||
pod.Spec.InitContainers = append(pod.Spec.InitContainers, corev1.Container{ | ||
Name: javaInitContainerName, | ||
Image: javaSpec.Image, | ||
Command: []string{"cp", "/javaagent.jar", javaInstrMountPath + "/javaagent.jar"}, | ||
Command: command, | ||
Resources: javaSpec.Resources, | ||
VolumeMounts: []corev1.VolumeMount{{ | ||
Name: javaVolumeName, | ||
|
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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