diff --git a/api/compute/v1alpha1/common.go b/api/compute/v1alpha1/common.go index c8974b24b..aa8d276e8 100644 --- a/api/compute/v1alpha1/common.go +++ b/api/compute/v1alpha1/common.go @@ -241,6 +241,7 @@ type JavaRuntime struct { JarLocation string `json:"jarLocation,omitempty"` ExtraDependenciesDir string `json:"extraDependenciesDir,omitempty"` Log *RuntimeLogConfig `json:"log,omitempty"` + JavaOpts []string `json:"javaOpts,omitempty"` } // PythonRuntime contains the python runtime configs diff --git a/api/compute/v1alpha1/zz_generated.deepcopy.go b/api/compute/v1alpha1/zz_generated.deepcopy.go index a0aee9b86..e90cff285 100644 --- a/api/compute/v1alpha1/zz_generated.deepcopy.go +++ b/api/compute/v1alpha1/zz_generated.deepcopy.go @@ -524,6 +524,11 @@ func (in *JavaRuntime) DeepCopyInto(out *JavaRuntime) { *out = new(RuntimeLogConfig) (*in).DeepCopyInto(*out) } + if in.JavaOpts != nil { + in, out := &in.JavaOpts, &out.JavaOpts + *out = make([]string, len(*in)) + copy(*out, *in) + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new JavaRuntime. diff --git a/charts/function-mesh-operator/charts/admission-webhook/templates/crd-compute.functionmesh.io-functionmeshes.yaml b/charts/function-mesh-operator/charts/admission-webhook/templates/crd-compute.functionmesh.io-functionmeshes.yaml index 339c1e274..caee4319e 100644 --- a/charts/function-mesh-operator/charts/admission-webhook/templates/crd-compute.functionmesh.io-functionmeshes.yaml +++ b/charts/function-mesh-operator/charts/admission-webhook/templates/crd-compute.functionmesh.io-functionmeshes.yaml @@ -173,6 +173,10 @@ spec: type: string jarLocation: type: string + javaOpts: + items: + type: string + type: array log: properties: level: @@ -3389,6 +3393,10 @@ spec: type: string jarLocation: type: string + javaOpts: + items: + type: string + type: array log: properties: level: @@ -6452,6 +6460,10 @@ spec: type: string jarLocation: type: string + javaOpts: + items: + type: string + type: array log: properties: level: diff --git a/charts/function-mesh-operator/charts/admission-webhook/templates/crd-compute.functionmesh.io-functions.yaml b/charts/function-mesh-operator/charts/admission-webhook/templates/crd-compute.functionmesh.io-functions.yaml index 47d49558c..8077cf141 100644 --- a/charts/function-mesh-operator/charts/admission-webhook/templates/crd-compute.functionmesh.io-functions.yaml +++ b/charts/function-mesh-operator/charts/admission-webhook/templates/crd-compute.functionmesh.io-functions.yaml @@ -192,6 +192,10 @@ spec: type: string jarLocation: type: string + javaOpts: + items: + type: string + type: array log: properties: level: diff --git a/charts/function-mesh-operator/charts/admission-webhook/templates/crd-compute.functionmesh.io-sinks.yaml b/charts/function-mesh-operator/charts/admission-webhook/templates/crd-compute.functionmesh.io-sinks.yaml index 46831756a..9cc98fc05 100644 --- a/charts/function-mesh-operator/charts/admission-webhook/templates/crd-compute.functionmesh.io-sinks.yaml +++ b/charts/function-mesh-operator/charts/admission-webhook/templates/crd-compute.functionmesh.io-sinks.yaml @@ -187,6 +187,10 @@ spec: type: string jarLocation: type: string + javaOpts: + items: + type: string + type: array log: properties: level: diff --git a/charts/function-mesh-operator/charts/admission-webhook/templates/crd-compute.functionmesh.io-sources.yaml b/charts/function-mesh-operator/charts/admission-webhook/templates/crd-compute.functionmesh.io-sources.yaml index c881a1271..fd7bf58b5 100644 --- a/charts/function-mesh-operator/charts/admission-webhook/templates/crd-compute.functionmesh.io-sources.yaml +++ b/charts/function-mesh-operator/charts/admission-webhook/templates/crd-compute.functionmesh.io-sources.yaml @@ -121,6 +121,10 @@ spec: type: string jarLocation: type: string + javaOpts: + items: + type: string + type: array log: properties: level: diff --git a/config/crd/bases/compute.functionmesh.io_functionmeshes.yaml b/config/crd/bases/compute.functionmesh.io_functionmeshes.yaml index 3fa99fd94..c0bde847f 100644 --- a/config/crd/bases/compute.functionmesh.io_functionmeshes.yaml +++ b/config/crd/bases/compute.functionmesh.io_functionmeshes.yaml @@ -174,6 +174,10 @@ spec: type: string jarLocation: type: string + javaOpts: + items: + type: string + type: array log: properties: level: @@ -3439,6 +3443,10 @@ spec: type: string jarLocation: type: string + javaOpts: + items: + type: string + type: array log: properties: level: @@ -6551,6 +6559,10 @@ spec: type: string jarLocation: type: string + javaOpts: + items: + type: string + type: array log: properties: level: diff --git a/config/crd/bases/compute.functionmesh.io_functions.yaml b/config/crd/bases/compute.functionmesh.io_functions.yaml index c0f5daa9c..a299b2530 100644 --- a/config/crd/bases/compute.functionmesh.io_functions.yaml +++ b/config/crd/bases/compute.functionmesh.io_functions.yaml @@ -171,6 +171,10 @@ spec: type: string jarLocation: type: string + javaOpts: + items: + type: string + type: array log: properties: level: diff --git a/config/crd/bases/compute.functionmesh.io_sinks.yaml b/config/crd/bases/compute.functionmesh.io_sinks.yaml index 02bdd5faa..8ab9caf63 100644 --- a/config/crd/bases/compute.functionmesh.io_sinks.yaml +++ b/config/crd/bases/compute.functionmesh.io_sinks.yaml @@ -166,6 +166,10 @@ spec: type: string jarLocation: type: string + javaOpts: + items: + type: string + type: array log: properties: level: diff --git a/config/crd/bases/compute.functionmesh.io_sources.yaml b/config/crd/bases/compute.functionmesh.io_sources.yaml index d90d9e129..3e7c0da91 100644 --- a/config/crd/bases/compute.functionmesh.io_sources.yaml +++ b/config/crd/bases/compute.functionmesh.io_sources.yaml @@ -100,6 +100,10 @@ spec: type: string jarLocation: type: string + javaOpts: + items: + type: string + type: array log: properties: level: diff --git a/controllers/spec/common.go b/controllers/spec/common.go index 9a32bfe3a..48cba928a 100644 --- a/controllers/spec/common.go +++ b/controllers/spec/common.go @@ -344,11 +344,11 @@ func MakePodTemplate(container *corev1.Container, volumes []corev1.Volume, } func MakeJavaFunctionCommand(downloadPath, packageFile, name, clusterName, generateLogConfigCommand, logLevel, details, memory, extraDependenciesDir, uid string, - authProvided, tlsProvided bool, secretMaps map[string]v1alpha1.SecretRef, state *v1alpha1.Stateful, + javaOpts []string, authProvided, tlsProvided bool, secretMaps map[string]v1alpha1.SecretRef, state *v1alpha1.Stateful, tlsConfig TLSConfig, authConfig *v1alpha1.AuthConfig) []string { processCommand := setShardIDEnvironmentVariableCommand() + " && " + generateLogConfigCommand + strings.Join(getProcessJavaRuntimeArgs(name, packageFile, clusterName, logLevel, details, - memory, extraDependenciesDir, uid, authProvided, tlsProvided, secretMaps, state, tlsConfig, authConfig), " ") + memory, extraDependenciesDir, uid, javaOpts, authProvided, tlsProvided, secretMaps, state, tlsConfig, authConfig), " ") if downloadPath != "" && !utils.EnableInitContainers { // prepend download command if the downPath is provided downloadCommand := strings.Join(getLegacyDownloadCommand(downloadPath, packageFile, authProvided, tlsProvided, @@ -781,7 +781,7 @@ func setShardIDEnvironmentVariableCommand() string { } func getProcessJavaRuntimeArgs(name, packageName, clusterName, logLevel, details, memory, extraDependenciesDir, uid string, - authProvided, tlsProvided bool, secretMaps map[string]v1alpha1.SecretRef, state *v1alpha1.Stateful, + javaOpts []string, authProvided, tlsProvided bool, secretMaps map[string]v1alpha1.SecretRef, state *v1alpha1.Stateful, tlsConfig TLSConfig, authConfig *v1alpha1.AuthConfig) []string { classPath := "/pulsar/instances/java-instance.jar" if extraDependenciesDir != "" { @@ -807,6 +807,7 @@ func getProcessJavaRuntimeArgs(name, packageName, clusterName, logLevel, details "-Dpulsar.function.log.file=" + fmt.Sprintf("%s-${%s}", name, EnvShardID), setLogLevel, "-Xmx" + memory, + strings.Join(javaOpts, " "), "org.apache.pulsar.functions.instance.JavaInstanceMain", "--jar", packageName, diff --git a/controllers/spec/function.go b/controllers/spec/function.go index fbfa9dcdb..60160b2b7 100644 --- a/controllers/spec/function.go +++ b/controllers/spec/function.go @@ -140,7 +140,7 @@ func makeFunctionCommand(function *v1alpha1.Function) []string { parseJavaLogLevel(function.Spec.Java), generateFunctionDetailsInJSON(function), getDecimalSIMemory(spec.Resources.Requests.Memory()), spec.Java.ExtraDependenciesDir, string(function.UID), - spec.Pulsar.AuthSecret != "", spec.Pulsar.TLSSecret != "", function.Spec.SecretsMap, + spec.Java.JavaOpts, spec.Pulsar.AuthSecret != "", spec.Pulsar.TLSSecret != "", function.Spec.SecretsMap, function.Spec.StateConfig, function.Spec.Pulsar.TLSConfig, function.Spec.Pulsar.AuthConfig) } } else if spec.Python != nil { diff --git a/controllers/spec/sink.go b/controllers/spec/sink.go index 1d9174cec..b1d82474f 100644 --- a/controllers/spec/sink.go +++ b/controllers/spec/sink.go @@ -136,8 +136,8 @@ func MakeSinkCommand(sink *v1alpha1.Sink) []string { parseJavaLogLevel(sink.Spec.Java), generateSinkDetailsInJSON(sink), getDecimalSIMemory(spec.Resources.Requests.Memory()), spec.Java.ExtraDependenciesDir, string(sink.UID), - spec.Pulsar.AuthSecret != "", spec.Pulsar.TLSSecret != "", spec.SecretsMap, spec.StateConfig, - spec.Pulsar.TLSConfig, spec.Pulsar.AuthConfig) + spec.Java.JavaOpts, spec.Pulsar.AuthSecret != "", spec.Pulsar.TLSSecret != "", spec.SecretsMap, + spec.StateConfig, spec.Pulsar.TLSConfig, spec.Pulsar.AuthConfig) } func generateSinkDetailsInJSON(sink *v1alpha1.Sink) string { diff --git a/controllers/spec/source.go b/controllers/spec/source.go index 923d54080..cefe02ca7 100644 --- a/controllers/spec/source.go +++ b/controllers/spec/source.go @@ -125,15 +125,14 @@ func makeSourceVolumeMounts(source *v1alpha1.Source) []corev1.VolumeMount { func makeSourceCommand(source *v1alpha1.Source) []string { spec := source.Spec - return MakeJavaFunctionCommand( - spec.Java.JarLocation, spec.Java.Jar, + return MakeJavaFunctionCommand(spec.Java.JarLocation, spec.Java.Jar, spec.Name, spec.ClusterName, generateJavaLogConfigCommand(source.Spec.Java), parseJavaLogLevel(source.Spec.Java), generateSourceDetailsInJSON(source), getDecimalSIMemory(spec.Resources.Requests.Memory()), spec.Java.ExtraDependenciesDir, string(source.UID), - spec.Pulsar.AuthSecret != "", spec.Pulsar.TLSSecret != "", spec.SecretsMap, spec.StateConfig, - spec.Pulsar.TLSConfig, spec.Pulsar.AuthConfig) + spec.Java.JavaOpts, spec.Pulsar.AuthSecret != "", spec.Pulsar.TLSSecret != "", spec.SecretsMap, + spec.StateConfig, spec.Pulsar.TLSConfig, spec.Pulsar.AuthConfig) } func generateSourceDetailsInJSON(source *v1alpha1.Source) string { diff --git a/manifests/crd.yaml b/manifests/crd.yaml index 9c063265b..e0ac7558a 100644 --- a/manifests/crd.yaml +++ b/manifests/crd.yaml @@ -185,6 +185,10 @@ spec: type: string jarLocation: type: string + javaOpts: + items: + type: string + type: array log: properties: level: @@ -3078,6 +3082,10 @@ spec: type: string jarLocation: type: string + javaOpts: + items: + type: string + type: array log: properties: level: @@ -5798,6 +5806,10 @@ spec: type: string jarLocation: type: string + javaOpts: + items: + type: string + type: array log: properties: level: @@ -8720,6 +8732,10 @@ spec: type: string jarLocation: type: string + javaOpts: + items: + type: string + type: array log: properties: level: @@ -11692,6 +11708,10 @@ spec: type: string jarLocation: type: string + javaOpts: + items: + type: string + type: array log: properties: level: @@ -14491,6 +14511,10 @@ spec: type: string jarLocation: type: string + javaOpts: + items: + type: string + type: array log: properties: level: