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 1 commit
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
15 changes: 15 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,12 @@ type BookkeeperImageSpec struct {
ImageSpec
}

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

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"`
}
109 changes: 109 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.

3 changes: 3 additions & 0 deletions pkg/controller/pravega/bookie.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,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 @@ -217,6 +218,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 @@ -226,6 +228,7 @@ func MakeBookieConfigMap(pravegaCluster *v1alpha1.PravegaCluster) *corev1.Config
"-XX:NumberOfGCLogFiles=5",
"-XX:GCLogFileSize=64m",
}
gcLoggingOpts = util.OverrideDefaultJVMOptions(gcLoggingOpts, pravegaCluster.Spec.Bookkeeper.JVM.GcLoggingOpts)

configData := map[string]string{
"BOOKIE_MEM_OPTS": strings.Join(memoryOpts, " "),
Expand Down
11 changes: 8 additions & 3 deletions pkg/controller/pravega/pravega_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,23 +143,28 @@ func configureControllerTLSSecrets(podSpec *corev1.PodSpec, p *api.PravegaCluste
}

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

jvmOpts := []string{
"-Xms512m",
"-XX:+ExitOnOutOfMemoryError",
"-XX:+CrashOnOutOfMemoryError",
"-XX:+HeapDumpOnOutOfMemoryError",
"-Dpravegaservice.clusterName=" + p.Name,
}

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
10 changes: 7 additions & 3 deletions pkg/controller/pravega/pravega_segmentstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,26 +148,30 @@ 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",
"-XX:+HeapDumpOnOutOfMemoryError",
"-Dpravegaservice.clusterName=" + p.Name,
}

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))
}

configData := map[string]string{
"AUTHORIZATION_ENABLED": "false",
"CLUSTER_NAME": p.Name,
Expand Down
Loading