Skip to content

Commit

Permalink
Add java opts (#484)
Browse files Browse the repository at this point in the history
* Add java opts field

* generate code

* Change java opts to array

* Generate codes
  • Loading branch information
jiangpengcheng authored Nov 16, 2022
1 parent bfc58d5 commit 92e8a16
Show file tree
Hide file tree
Showing 15 changed files with 88 additions and 10 deletions.
1 change: 1 addition & 0 deletions api/compute/v1alpha1/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions api/compute/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,10 @@ spec:
type: string
jarLocation:
type: string
javaOpts:
items:
type: string
type: array
log:
properties:
level:
Expand Down Expand Up @@ -3389,6 +3393,10 @@ spec:
type: string
jarLocation:
type: string
javaOpts:
items:
type: string
type: array
log:
properties:
level:
Expand Down Expand Up @@ -6452,6 +6460,10 @@ spec:
type: string
jarLocation:
type: string
javaOpts:
items:
type: string
type: array
log:
properties:
level:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,10 @@ spec:
type: string
jarLocation:
type: string
javaOpts:
items:
type: string
type: array
log:
properties:
level:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,10 @@ spec:
type: string
jarLocation:
type: string
javaOpts:
items:
type: string
type: array
log:
properties:
level:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,10 @@ spec:
type: string
jarLocation:
type: string
javaOpts:
items:
type: string
type: array
log:
properties:
level:
Expand Down
12 changes: 12 additions & 0 deletions config/crd/bases/compute.functionmesh.io_functionmeshes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,10 @@ spec:
type: string
jarLocation:
type: string
javaOpts:
items:
type: string
type: array
log:
properties:
level:
Expand Down Expand Up @@ -3439,6 +3443,10 @@ spec:
type: string
jarLocation:
type: string
javaOpts:
items:
type: string
type: array
log:
properties:
level:
Expand Down Expand Up @@ -6551,6 +6559,10 @@ spec:
type: string
jarLocation:
type: string
javaOpts:
items:
type: string
type: array
log:
properties:
level:
Expand Down
4 changes: 4 additions & 0 deletions config/crd/bases/compute.functionmesh.io_functions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,10 @@ spec:
type: string
jarLocation:
type: string
javaOpts:
items:
type: string
type: array
log:
properties:
level:
Expand Down
4 changes: 4 additions & 0 deletions config/crd/bases/compute.functionmesh.io_sinks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,10 @@ spec:
type: string
jarLocation:
type: string
javaOpts:
items:
type: string
type: array
log:
properties:
level:
Expand Down
4 changes: 4 additions & 0 deletions config/crd/bases/compute.functionmesh.io_sources.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,10 @@ spec:
type: string
jarLocation:
type: string
javaOpts:
items:
type: string
type: array
log:
properties:
level:
Expand Down
7 changes: 4 additions & 3 deletions controllers/spec/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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 != "" {
Expand All @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion controllers/spec/function.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions controllers/spec/sink.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
7 changes: 3 additions & 4 deletions controllers/spec/source.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
24 changes: 24 additions & 0 deletions manifests/crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,10 @@ spec:
type: string
jarLocation:
type: string
javaOpts:
items:
type: string
type: array
log:
properties:
level:
Expand Down Expand Up @@ -3078,6 +3082,10 @@ spec:
type: string
jarLocation:
type: string
javaOpts:
items:
type: string
type: array
log:
properties:
level:
Expand Down Expand Up @@ -5798,6 +5806,10 @@ spec:
type: string
jarLocation:
type: string
javaOpts:
items:
type: string
type: array
log:
properties:
level:
Expand Down Expand Up @@ -8720,6 +8732,10 @@ spec:
type: string
jarLocation:
type: string
javaOpts:
items:
type: string
type: array
log:
properties:
level:
Expand Down Expand Up @@ -11692,6 +11708,10 @@ spec:
type: string
jarLocation:
type: string
javaOpts:
items:
type: string
type: array
log:
properties:
level:
Expand Down Expand Up @@ -14491,6 +14511,10 @@ spec:
type: string
jarLocation:
type: string
javaOpts:
items:
type: string
type: array
log:
properties:
level:
Expand Down

0 comments on commit 92e8a16

Please sign in to comment.