Skip to content
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

Issue 226: Pass jvm options #247

Merged
merged 10 commits into from
Sep 18, 2019
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions example/cr-detailed.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,13 @@ spec:
# Default is 60
codahaleStatsOutputFrequencySeconds: "30"

# Pass the JVM options to Bookkeeper
jvm:
memoryOpts: ["-Xms2g", "-XX:MaxDirectMemorySize=2g"]
gcOpts: ["-XX:MaxGCPauseMillis=20"]
gcLoggingOpts: ["-XX:NumberOfGCLogFiles=10"]
extraOpts: []

pravega:
image:
repository: pravega/pravega
Expand Down Expand Up @@ -134,3 +141,8 @@ spec:
pravegaservice.enableTls: "true"
pravegaservice.certFile: "/etc/secret-volume/segmentStore01.pem"
pravegaservice.keyFile: "/etc/secret-volume/segmentStore01.key.pem"

# Pass the JVM options to controller and segmentstore
jvm:
Tristan1900 marked this conversation as resolved.
Show resolved Hide resolved
controller: ["-XX:MaxDirectMemorySize=1g"]
segmentstore: ["-XX:MaxDirectMemorySize=1g"]
16 changes: 16 additions & 0 deletions pkg/apis/pravega/v1alpha1/bookkeeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@ type BookkeeperSpec struct {
// in bookkeeper. Some examples can be found here
// https://github.com/apache/bookkeeper/blob/master/docker/README.md
Options map[string]string `json:"options"`

// JVM is the JVM options for bookkeeper. It will be passed to the JVM for performance tuning.
// If this field is not specified, the operator will use a set of default
// options that is good enough for general deployment.
JVM *BookkeeperJVMOptions `json:"jvm"`
Tristan1900 marked this conversation as resolved.
Show resolved Hide resolved
}

func (s *BookkeeperSpec) withDefaults() (changed bool) {
Expand Down Expand Up @@ -130,6 +135,10 @@ func (s *BookkeeperSpec) withDefaults() (changed bool) {
s.Options = map[string]string{}
}

if s.JVM == nil {
s.JVM = &BookkeeperJVMOptions{}
}

Tristan1900 marked this conversation as resolved.
Show resolved Hide resolved
return changed
}

Expand All @@ -138,6 +147,13 @@ type BookkeeperImageSpec struct {
ImageSpec
}

type BookkeeperJVMOptions struct {
MemoryOpts []string `json:"memoryOpts"`
GcOpts []string `json:"gcOpts"`
GcLoggingOpts []string `json:"gcLoggingOpts"`
ExtraOpts []string `json:"extraOpts"`
}

func (s *BookkeeperImageSpec) withDefaults() (changed bool) {
if s.Repository == "" {
changed = true
Expand Down
17 changes: 17 additions & 0 deletions pkg/apis/pravega/v1alpha1/pravega.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,11 @@ type PravegaSpec struct {
// https://github.com/pravega/pravega/blob/master/config/config.properties
Options map[string]string `json:"options"`

// JVM is the JVM options for controller and segmentstore. It will be passed to the JVM
// for performance tuning. If this field is not specified, the operator will use a set of default
// options that is good enough for general deployment.
JVM *PravegaJVMOptions `json:"jvm"`
Tristan1900 marked this conversation as resolved.
Show resolved Hide resolved

// CacheVolumeClaimTemplate is the spec to describe PVC for the Pravega cache.
// This field is optional. If no PVC spec, stateful containers will use
// emptyDir as volume
Expand Down Expand Up @@ -139,6 +144,13 @@ func (s *PravegaSpec) withDefaults() (changed bool) {
s.Options = map[string]string{}
}

if s.JVM == nil {
changed = true
s.JVM = &PravegaJVMOptions{}
s.JVM.Controller = []string{}
Tristan1900 marked this conversation as resolved.
Show resolved Hide resolved
s.JVM.Segmentstore = []string{}
}

if s.CacheVolumeClaimTemplate == nil {
changed = true
s.CacheVolumeClaimTemplate = &v1.PersistentVolumeClaimSpec{
Expand Down Expand Up @@ -262,3 +274,8 @@ type HDFSSpec struct {
Root string `json:"root"`
ReplicationFactor int32 `json:"replicationFactor"`
}

type PravegaJVMOptions struct {
Controller []string `json:"controller"`
Segmentstore []string `json:"segmentstore"`
}
114 changes: 114 additions & 0 deletions pkg/apis/pravega/v1alpha1/zz_generated.deepcopy.go

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

9 changes: 9 additions & 0 deletions pkg/controller/pravega/bookie.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ func MakeBookieConfigMap(pravegaCluster *v1alpha1.PravegaCluster) *corev1.Config
"-XX:MaxRAMFraction=2",
)
}
memoryOpts = util.OverrideDefaultJVMOptions(memoryOpts, pravegaCluster.Spec.Bookkeeper.JVM.MemoryOpts)

gcOpts := []string{
"-XX:+UseG1GC",
Expand All @@ -230,6 +231,7 @@ func MakeBookieConfigMap(pravegaCluster *v1alpha1.PravegaCluster) *corev1.Config
"-XX:+DisableExplicitGC",
"-XX:-ResizePLAB",
}
gcOpts = util.OverrideDefaultJVMOptions(gcOpts, pravegaCluster.Spec.Bookkeeper.JVM.GcOpts)

gcLoggingOpts := []string{
"-XX:+PrintGCDetails",
Expand All @@ -239,11 +241,18 @@ func MakeBookieConfigMap(pravegaCluster *v1alpha1.PravegaCluster) *corev1.Config
"-XX:NumberOfGCLogFiles=5",
"-XX:GCLogFileSize=64m",
}
gcLoggingOpts = util.OverrideDefaultJVMOptions(gcLoggingOpts, pravegaCluster.Spec.Bookkeeper.JVM.GcLoggingOpts)

extraOpts := []string{}
if pravegaCluster.Spec.Bookkeeper.JVM.ExtraOpts != nil {
extraOpts = pravegaCluster.Spec.Bookkeeper.JVM.ExtraOpts
}

configData := map[string]string{
"BOOKIE_MEM_OPTS": strings.Join(memoryOpts, " "),
"BOOKIE_GC_OPTS": strings.Join(gcOpts, " "),
"BOOKIE_GC_LOGGING_OPTS": strings.Join(gcLoggingOpts, " "),
"BOOKIE_EXTRA_OPTS": strings.Join(extraOpts, " "),
"ZK_URL": pravegaCluster.Spec.ZookeeperUri,
"BK_useHostNameAsBookieID": "true",
"PRAVEGA_CLUSTER_NAME": pravegaCluster.ObjectMeta.Name,
Expand Down
10 changes: 8 additions & 2 deletions pkg/controller/pravega/pravega_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,11 @@ func addSecretVolumeWithMount(podSpec *corev1.PodSpec, p *api.PravegaCluster,
}

func MakeControllerConfigMap(p *api.PravegaCluster) *corev1.ConfigMap {
var javaOpts = []string{
javaOpts := []string{
"-Dpravegaservice.clusterName=" + p.Name,
}

jvmOpts := []string{
"-Xms512m",
"-XX:+ExitOnOutOfMemoryError",
"-XX:+CrashOnOutOfMemoryError",
Expand All @@ -182,13 +186,15 @@ func MakeControllerConfigMap(p *api.PravegaCluster) *corev1.ConfigMap {

if match, _ := util.CompareVersions(p.Spec.Version, "0.4.0", ">="); match {
// Pravega < 0.4 uses a Java version that does not support the options below
javaOpts = append(javaOpts,
jvmOpts = append(jvmOpts,
"-XX:+UnlockExperimentalVMOptions",
"-XX:+UseCGroupMemoryLimitForHeap",
"-XX:MaxRAMFraction=2",
)
}

javaOpts = append(javaOpts, util.OverrideDefaultJVMOptions(jvmOpts, p.Spec.Pravega.JVM.Controller)...)

for name, value := range p.Spec.Pravega.Options {
javaOpts = append(javaOpts, fmt.Sprintf("-D%v=%v", name, value))
}
Expand Down
9 changes: 7 additions & 2 deletions pkg/controller/pravega/pravega_segmentstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,10 @@ func makeSegmentstorePodSpec(p *api.PravegaCluster) corev1.PodSpec {

func MakeSegmentstoreConfigMap(p *api.PravegaCluster) *corev1.ConfigMap {
javaOpts := []string{
"-Dpravegaservice.clusterName=" + p.Name,
}

jvmOpts := []string{
"-Xms1g",
"-XX:+ExitOnOutOfMemoryError",
"-XX:+CrashOnOutOfMemoryError",
Expand All @@ -170,17 +174,18 @@ func MakeSegmentstoreConfigMap(p *api.PravegaCluster) *corev1.ConfigMap {

if match, _ := util.CompareVersions(p.Spec.Version, "0.4.0", ">="); match {
// Pravega < 0.4 uses a Java version that does not support the options below
javaOpts = append(javaOpts,
jvmOpts = append(jvmOpts,
"-XX:+UnlockExperimentalVMOptions",
"-XX:+UseCGroupMemoryLimitForHeap",
"-XX:MaxRAMFraction=2",
)
}

javaOpts = append(javaOpts, util.OverrideDefaultJVMOptions(jvmOpts, p.Spec.Pravega.JVM.Segmentstore)...)

for name, value := range p.Spec.Pravega.Options {
javaOpts = append(javaOpts, fmt.Sprintf("-D%v=%v", name, value))
}

authEnabledStr := fmt.Sprint(p.Spec.Authentication.IsEnabled())
configData := map[string]string{
"AUTHORIZATION_ENABLED": authEnabledStr,
Expand Down
Loading