@@ -52,7 +52,8 @@ var oldAgentVersions = map[string]struct{}{
52
52
}
53
53
54
54
const (
55
- ActiveJavaAgentCmd = "-javaagent:/app/lib/.polaris/java_agent/polaris-java-agent/polaris-agent-core-bootstrap.jar"
55
+ ActiveJavaAgentCmd = "-javaagent:/app/lib/.polaris/java_agent/polaris-java-agent/polaris-agent-core-bootstrap.jar"
56
+ OldActiveJavaAgentCmd = "-javaagent:/app/lib/.polaris/java_agent/polaris-java-agent-%s/polaris-agent-core-bootstrap.jar"
56
57
)
57
58
58
59
func init () {
@@ -266,18 +267,32 @@ func (pb *PodPatchBuilder) updateContainer(opt *inject.PatchOptions, sidecarMode
266
267
}
267
268
if javaEnvIndex != - 1 {
268
269
oldVal := envs [javaEnvIndex ].Value
269
- envs [javaEnvIndex ] = corev1.EnvVar {
270
- Name : "JAVA_TOOL_OPTIONS" ,
271
- Value : oldVal + " " + ActiveJavaAgentCmd + javaToolOptionsValue ,
270
+ if _ , valid := oldAgentVersions [annonations [customJavaAgentVersion ]]; ! valid {
271
+ envs [javaEnvIndex ] = corev1.EnvVar {
272
+ Name : "JAVA_TOOL_OPTIONS" ,
273
+ Value : oldVal + " " + ActiveJavaAgentCmd + javaToolOptionsValue ,
274
+ }
275
+ } else {
276
+ envs [javaEnvIndex ] = corev1.EnvVar {
277
+ Name : "JAVA_TOOL_OPTIONS" ,
278
+ Value : oldVal + " " + fmt .Sprintf (OldActiveJavaAgentCmd , opt .ExternalInfo [customJavaAgentVersion ]),
279
+ }
272
280
}
273
281
}
274
282
}
275
283
if javaEnvIndex == - 1 {
276
284
// 注入 java agent 需要用到的参数信息
277
- container .Env = append (container .Env , corev1.EnvVar {
278
- Name : "JAVA_TOOL_OPTIONS" ,
279
- Value : ActiveJavaAgentCmd + javaToolOptionsValue ,
280
- })
285
+ if _ , valid := oldAgentVersions [annonations [customJavaAgentVersion ]]; ! valid {
286
+ container .Env = append (container .Env , corev1.EnvVar {
287
+ Name : "JAVA_TOOL_OPTIONS" ,
288
+ Value : ActiveJavaAgentCmd + javaToolOptionsValue ,
289
+ })
290
+ } else {
291
+ container .Env = append (container .Env , corev1.EnvVar {
292
+ Name : "JAVA_TOOL_OPTIONS" ,
293
+ Value : fmt .Sprintf (OldActiveJavaAgentCmd , opt .ExternalInfo [customJavaAgentVersion ]),
294
+ })
295
+ }
281
296
}
282
297
283
298
// container 需要新挂载磁盘
0 commit comments