@@ -40,7 +40,6 @@ import (
40
40
autov2 "k8s.io/api/autoscaling/v2"
41
41
v1 "k8s.io/api/batch/v1"
42
42
corev1 "k8s.io/api/core/v1"
43
- "k8s.io/apimachinery/pkg/api/resource"
44
43
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
45
44
"k8s.io/apimachinery/pkg/util/intstr"
46
45
"k8s.io/client-go/kubernetes/scheme"
@@ -340,14 +339,14 @@ func makePodTemplate(container *corev1.Container, filebeatContainer *corev1.Cont
340
339
}
341
340
}
342
341
343
- func MakeJavaFunctionCommand (downloadPath , packageFile , name , clusterName , generateLogConfigCommand , logLevel , details , extraDependenciesDir , uid string , memory * resource. Quantity ,
342
+ func MakeJavaFunctionCommand (downloadPath , packageFile , name , clusterName , generateLogConfigCommand , logLevel , details , extraDependenciesDir , uid string ,
344
343
javaOpts []string , hasPulsarctl , hasWget , authProvided , tlsProvided bool , secretMaps map [string ]v1alpha1.SecretRef ,
345
344
state * v1alpha1.Stateful ,
346
345
tlsConfig TLSConfig , authConfig * v1alpha1.AuthConfig ,
347
346
maxPendingAsyncRequests * int32 , logConfigFileName string ) []string {
348
347
processCommand := setShardIDEnvironmentVariableCommand () + " && " + generateLogConfigCommand +
349
348
strings .Join (getProcessJavaRuntimeArgs (name , packageFile , clusterName , logLevel , details ,
350
- extraDependenciesDir , uid , memory , javaOpts , authProvided , tlsProvided , secretMaps , state , tlsConfig ,
349
+ extraDependenciesDir , uid , javaOpts , authProvided , tlsProvided , secretMaps , state , tlsConfig ,
351
350
authConfig , maxPendingAsyncRequests , logConfigFileName ), " " )
352
351
if downloadPath != "" && ! utils .EnableInitContainers {
353
352
// prepend download command if the downPath is provided
@@ -1091,7 +1090,7 @@ func setShardIDEnvironmentVariableCommand() string {
1091
1090
}
1092
1091
1093
1092
func getProcessJavaRuntimeArgs (name , packageName , clusterName , logLevel , details , extraDependenciesDir , uid string ,
1094
- memory * resource. Quantity , javaOpts []string , authProvided , tlsProvided bool , secretMaps map [string ]v1alpha1.SecretRef ,
1093
+ javaOpts []string , authProvided , tlsProvided bool , secretMaps map [string ]v1alpha1.SecretRef ,
1095
1094
state * v1alpha1.Stateful ,
1096
1095
tlsConfig TLSConfig , authConfig * v1alpha1.AuthConfig ,
1097
1096
maxPendingAsyncRequests * int32 , logConfigFileName string ) []string {
@@ -1113,7 +1112,6 @@ func getProcessJavaRuntimeArgs(name, packageName, clusterName, logLevel, details
1113
1112
},
1114
1113
" " )
1115
1114
}
1116
- xmsMemory := resource .NewScaledQuantity (memory .Value ()/ 2 , 0 )
1117
1115
args := []string {
1118
1116
"exec" ,
1119
1117
"java" ,
@@ -1124,9 +1122,12 @@ func getProcessJavaRuntimeArgs(name, packageName, clusterName, logLevel, details
1124
1122
"-Dpulsar.function.log.dir=logs/functions" ,
1125
1123
"-Dpulsar.function.log.file=" + fmt .Sprintf ("%s-${%s}" , name , EnvShardID ),
1126
1124
setLogLevel ,
1127
- "-Xmx" + getDecimalSIMemory ( memory ) ,
1128
- "-Xms" + getDecimalSIMemory ( xmsMemory ) ,
1125
+ "-XX:InitialRAMPercentage=20" ,
1126
+ "-XX:MaxRAMPercentage=40" ,
1129
1127
"-XX:+UseG1GC" ,
1128
+ "-XX:+HeapDumpOnOutOfMemoryError" ,
1129
+ "-XX:HeapDumpPath=/pulsar/tmp/heapdump-%p.hprof" ,
1130
+ "-Xlog:gc*:file=/pulsar/logs/gc.log:time,level,tags:filecount=5,filesize=10M" ,
1130
1131
strings .Join (javaOpts , " " ),
1131
1132
"org.apache.pulsar.functions.instance.JavaInstanceMain" ,
1132
1133
"--jar" ,
@@ -1904,15 +1905,6 @@ func getPythonSecretProviderArgs(secretMaps map[string]v1alpha1.SecretRef) []str
1904
1905
return ret
1905
1906
}
1906
1907
1907
- func calcInstanceMemoryResources (resources corev1.ResourceRequirements ) * resource.Quantity {
1908
- if resources .Requests .Memory () == resources .Limits .Memory () {
1909
- // if request and limit are the same, use the value * 0.9 as the instance (JVM) memory size, to prevent OOM
1910
- return resource .NewQuantity (int64 (float64 (resources .Requests .Memory ().Value ())* 0.9 ), resource .DecimalSI )
1911
- }
1912
- // if request and limit are different, use the request value as the instance (JVM) memory size
1913
- return resources .Requests .Memory ()
1914
- }
1915
-
1916
1908
func getGenericSecretProviderArgs (secretMaps map [string ]v1alpha1.SecretRef , language string ) []string {
1917
1909
var ret []string
1918
1910
if len (secretMaps ) > 0 {
@@ -1931,14 +1923,6 @@ func getGenericSecretProviderArgs(secretMaps map[string]v1alpha1.SecretRef, lang
1931
1923
return ret
1932
1924
}
1933
1925
1934
- // Java command requires memory values in resource.DecimalSI format
1935
- func getDecimalSIMemory (quantity * resource.Quantity ) string {
1936
- if quantity .Format == resource .DecimalSI {
1937
- return quantity .String ()
1938
- }
1939
- return resource .NewQuantity (quantity .Value (), resource .DecimalSI ).String ()
1940
- }
1941
-
1942
1926
func getTLSTrustCertPath (tlsVolume TLSConfig , path string ) string {
1943
1927
return fmt .Sprintf ("%s/%s" , tlsVolume .GetMountPath (), path )
1944
1928
}
0 commit comments