Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
13 changes: 0 additions & 13 deletions api/v1/coherence_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -1691,12 +1691,6 @@ type JvmGarbageCollectorSpec struct {
// +listType=atomic
// +optional
Args []string `json:"args,omitempty"`
// Enable the following GC logging args -verbose:gc -XX:+PrintGCDetails -XX:+PrintGCTimeStamps
// -XX:+PrintHeapAtGC -XX:+PrintTenuringDistribution -XX:+PrintGCApplicationStoppedTime
// -XX:+PrintGCApplicationConcurrentTime
// Default is true
// +optional
Logging *bool `json:"logging,omitempty"`
}

// CreateEnvVars creates the GC environment variables for the Coherence container.
Expand All @@ -1714,13 +1708,6 @@ func (in *JvmGarbageCollectorSpec) CreateEnvVars() []corev1.EnvVar {
envVars = append(envVars, corev1.EnvVar{Name: EnvVarJvmGcCollector, Value: *in.Collector})
}

// Enable or disable GC logging
if in != nil && in.Logging != nil {
envVars = append(envVars, corev1.EnvVar{Name: EnvVarJvmGcLogging, Value: BoolPtrToString(in.Logging)})
} else {
envVars = append(envVars, corev1.EnvVar{Name: EnvVarJvmGcLogging, Value: "false"})
}

return envVars
}

Expand Down
13 changes: 5 additions & 8 deletions api/v1/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ package v1_test
import (
"encoding/json"
"fmt"
"os"
"sort"
"strings"
"testing"

"github.com/go-test/deep"
. "github.com/onsi/gomega"
coh "github.com/oracle/coherence-operator/api/v1"
Expand All @@ -20,10 +25,6 @@ import (
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/utils/ptr"
"os"
"sort"
"strings"
"testing"
)

const (
Expand Down Expand Up @@ -344,10 +345,6 @@ func createMinimalExpectedPodSpec(deployment coh.CoherenceResource) corev1.PodTe
Name: "COHERENCE_WKA",
Value: deployment.GetWKA(),
},
{
Name: "JVM_GC_LOGGING",
Value: "false",
},
{
Name: "JVM_USE_CONTAINER_LIMITS",
Value: "true",
Expand Down
1 change: 0 additions & 1 deletion api/v1/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,6 @@ const (
EnvVarJvmDebugAttach = "JVM_DEBUG_ATTACH"
EnvVarJvmGcArgs = "JVM_GC_ARGS"
EnvVarJvmGcCollector = "JVM_GC_COLLECTOR"
EnvVarJvmGcLogging = "JVM_GC_LOGGING"
EnvVarJvmMemoryHeap = "JVM_HEAP_SIZE"
EnvVarJvmMemoryInitialHeap = "JVM_INITIAL_HEAP_SIZE"
EnvVarJvmMemoryMaxHeap = "JVM_MAX_HEAP_SIZE"
Expand Down
46 changes: 3 additions & 43 deletions api/v1/create_job_jvmspec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@
package v1_test

import (
"testing"

coh "github.com/oracle/coherence-operator/api/v1"
corev1 "k8s.io/api/core/v1"
"testing"
)

func TestCreateJobWithEmptyJvmSpec(t *testing.T) {
Expand Down Expand Up @@ -241,8 +242,7 @@ func TestCreateJobWithJvmSpecWithGarbageCollectorArgs(t *testing.T) {
spec := coh.CoherenceResourceSpec{
JVM: &coh.JVMSpec{
Gc: &coh.JvmGarbageCollectorSpec{
Args: []string{"-XX:GC-ArgOne", "-XX:GC-ArgTwo"},
Logging: nil,
Args: []string{"-XX:GC-ArgOne", "-XX:GC-ArgTwo"},
},
},
}
Expand All @@ -257,46 +257,6 @@ func TestCreateJobWithJvmSpecWithGarbageCollectorArgs(t *testing.T) {
assertJobCreation(t, deployment, jobExpected)
}

func TestCreateJobWithJvmSpecWithGarbageCollectorLoggingFalse(t *testing.T) {

spec := coh.CoherenceResourceSpec{
JVM: &coh.JVMSpec{
Gc: &coh.JvmGarbageCollectorSpec{
Logging: boolPtr(false),
},
},
}

// Create the test deployment
deployment := createTestCoherenceJob(spec)
// Create expected Job
jobExpected := createMinimalExpectedJob(deployment)
addEnvVarsToAllJobContainers(jobExpected, corev1.EnvVar{Name: "JVM_GC_LOGGING", Value: "false"})

// assert that the Job is as expected
assertJobCreation(t, deployment, jobExpected)
}

func TestCreateJobWithJvmSpecWithGarbageCollectorLoggingTrue(t *testing.T) {

spec := coh.CoherenceResourceSpec{
JVM: &coh.JVMSpec{
Gc: &coh.JvmGarbageCollectorSpec{
Logging: boolPtr(true),
},
},
}

// Create the test deployment
deployment := createTestCoherenceJob(spec)
// Create expected Job
jobExpected := createMinimalExpectedJob(deployment)
addEnvVarsToAllJobContainers(jobExpected, corev1.EnvVar{Name: "JVM_GC_LOGGING", Value: "true"})

// assert that the Job is as expected
assertJobCreation(t, deployment, jobExpected)
}

func TestCreateJobWithJvmSpecWithDiagnosticsVolume(t *testing.T) {

hostPath := &corev1.HostPathVolumeSource{Path: "/home/root/debug"}
Expand Down
64 changes: 2 additions & 62 deletions api/v1/create_statefulset_jvmspec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@
package v1_test

import (
"testing"

coh "github.com/oracle/coherence-operator/api/v1"
corev1 "k8s.io/api/core/v1"
"testing"
)

func TestCreateStatefulSetWithEmptyJvmSpec(t *testing.T) {
Expand Down Expand Up @@ -236,67 +237,6 @@ func TestCreateStatefulSetWithJvmSpecWithGarbageCollector(t *testing.T) {
assertStatefulSetCreation(t, deployment, stsExpected)
}

func TestCreateStatefulSetWithJvmSpecWithGarbageCollectorArgs(t *testing.T) {

spec := coh.CoherenceResourceSpec{
JVM: &coh.JVMSpec{
Gc: &coh.JvmGarbageCollectorSpec{
Args: []string{"-XX:GC-ArgOne", "-XX:GC-ArgTwo"},
Logging: nil,
},
},
}

// Create the test deployment
deployment := createTestDeployment(spec)
// Create expected StatefulSet
stsExpected := createMinimalExpectedStatefulSet(deployment)
addEnvVarsToAll(stsExpected, corev1.EnvVar{Name: "JVM_GC_ARGS", Value: "-XX:GC-ArgOne -XX:GC-ArgTwo"})

// assert that the StatefulSet is as expected
assertStatefulSetCreation(t, deployment, stsExpected)
}

func TestCreateStatefulSetWithJvmSpecWithGarbageCollectorLoggingFalse(t *testing.T) {

spec := coh.CoherenceResourceSpec{
JVM: &coh.JVMSpec{
Gc: &coh.JvmGarbageCollectorSpec{
Logging: boolPtr(false),
},
},
}

// Create the test deployment
deployment := createTestDeployment(spec)
// Create expected StatefulSet
stsExpected := createMinimalExpectedStatefulSet(deployment)
addEnvVarsToAll(stsExpected, corev1.EnvVar{Name: "JVM_GC_LOGGING", Value: "false"})

// assert that the StatefulSet is as expected
assertStatefulSetCreation(t, deployment, stsExpected)
}

func TestCreateStatefulSetWithJvmSpecWithGarbageCollectorLoggingTrue(t *testing.T) {

spec := coh.CoherenceResourceSpec{
JVM: &coh.JVMSpec{
Gc: &coh.JvmGarbageCollectorSpec{
Logging: boolPtr(true),
},
},
}

// Create the test deployment
deployment := createTestDeployment(spec)
// Create expected StatefulSet
stsExpected := createMinimalExpectedStatefulSet(deployment)
addEnvVarsToAll(stsExpected, corev1.EnvVar{Name: "JVM_GC_LOGGING", Value: "true"})

// assert that the StatefulSet is as expected
assertStatefulSetCreation(t, deployment, stsExpected)
}

func TestCreateStatefulSetWithJvmSpecWithDiagnosticsVolume(t *testing.T) {

hostPath := &corev1.HostPathVolumeSource{Path: "/home/root/debug"}
Expand Down
1 change: 0 additions & 1 deletion docs/about/04_coherence_spec.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,6 @@ JvmGarbageCollectorSpec is options for managing the JVM garbage collector.
| Field | Description | Type | Required
m| collector | The name of the JVM garbage collector to use. G1 - adds the -XX:+UseG1GC option CMS - adds the -XX:+UseConcMarkSweepGC option Parallel - adds the -XX:+UseParallelGC Default - use the JVMs default collector The field value is case insensitive If not set G1 is used. If set to a value other than those above then the default collector for the JVM will be used. m| *string | false
m| args | Args specifies the GC options to pass to the JVM. m| []string | false
m| logging | Enable the following GC logging args -verbose:gc -XX:+PrintGCDetails -XX:+PrintGCTimeStamps -XX:+PrintHeapAtGC -XX:+PrintTenuringDistribution -XX:+PrintGCApplicationStoppedTime -XX:+PrintGCApplicationConcurrentTime Default is true m| *bool | false
|===

<<Table of Contents,Back to TOC>>
Expand Down
32 changes: 1 addition & 31 deletions docs/jvm/040_gc.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
== Garbage Collector Settings

The `Coherence` CRD has fields in the `jvm.gc` section to allow certain garbage collection parameters to be set.
These include GC logging, setting the collector to use and arbitrary GC arguments.
These setting the collector to use and arbitrary GC arguments.

[IMPORTANT]
====
Expand All @@ -26,36 +26,6 @@ added in the Coherence resource spec.
Alternatively specify a different garbage collector, ideally on a version of Java this old, use CMS.
====

=== Enable GC Logging

To enable GC logging set the `jvm.gc.logging` field to `true`.
For example:
[source,yaml]
----
apiVersion: coherence.oracle.com/v1
kind: Coherence
metadata:
name: storage
spec:
jvm:
gc:
logging: true
----

Setting the field to true adds the following JVM arguments to the JVM in the `coherence` container:
----
-verbose:gc
-XX:+PrintGCDetails
-XX:+PrintGCTimeStamps
-XX:+PrintHeapAtGC
-XX:+PrintTenuringDistribution
-XX:+PrintGCApplicationStoppedTime
-XX:+PrintGCApplicationConcurrentTime
----

If different GC logging arguments are required then the relevant JVM arguments can be added to either the
`jvm.args` field or the `jvm.gc.args` field.

=== Set the Garbage Collector

The garbage collector to use can be set using the `jvm.gc.collector` field.
Expand Down
11 changes: 0 additions & 11 deletions pkg/runner/cmd_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -415,15 +415,4 @@ func populateServerDetails(details *run_details.RunDetails) {
details.AddDiagnosticOption("-XX:+PrintCommandLineFlags")
details.AddDiagnosticOption("-XX:+PrintFlagsFinal")
}

// Add GC logging parameters if required
if details.IsEnvTrue(v1.EnvVarJvmGcLogging) {
details.AddMemoryOption("-verbose:gc")
details.AddMemoryOption("-XX:+PrintGCDetails")
details.AddMemoryOption("-XX:+PrintGCTimeStamps")
details.AddMemoryOption("-XX:+PrintHeapAtGC")
details.AddMemoryOption("-XX:+PrintTenuringDistribution")
details.AddMemoryOption("-XX:+PrintGCApplicationStoppedTime")
details.AddMemoryOption("-XX:+PrintGCApplicationConcurrentTime")
}
}
50 changes: 2 additions & 48 deletions pkg/runner/runner_jvm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@
package runner

import (
"testing"

. "github.com/onsi/gomega"
coh "github.com/oracle/coherence-operator/api/v1"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/utils/ptr"
"testing"
)

func TestJvmArgsEmpty(t *testing.T) {
Expand Down Expand Up @@ -331,53 +332,6 @@ func TestJvmGarbageCollectorZGC(t *testing.T) {
g.Expect(e.OsCmd.Args).To(ConsistOf(expected))
}

func TestJvmGarbageCollectorLoggingTrue(t *testing.T) {
g := NewGomegaWithT(t)

d := &coh.Coherence{
ObjectMeta: metav1.ObjectMeta{Name: "test"},
Spec: coh.CoherenceStatefulSetResourceSpec{
CoherenceResourceSpec: coh.CoherenceResourceSpec{
JVM: &coh.JVMSpec{
Gc: &coh.JvmGarbageCollectorSpec{
Logging: ptr.To(true),
},
},
},
},
}

expectedArgs := append(GetExpectedArgsFileContent(),
"-verbose:gc",
"-XX:+PrintGCDetails",
"-XX:+PrintGCTimeStamps",
"-XX:+PrintHeapAtGC",
"-XX:+PrintTenuringDistribution",
"-XX:+PrintGCApplicationStoppedTime",
"-XX:+PrintGCApplicationConcurrentTime")

verifyConfigFilesWithArgs(t, d, expectedArgs)

args := []string{"server", "--dry-run"}
env := EnvVarsFromDeployment(t, d)

e, err := ExecuteWithArgsAndNewViper(env, args)
g.Expect(err).NotTo(HaveOccurred())
g.Expect(e).NotTo(BeNil())
g.Expect(e.OsCmd).NotTo(BeNil())

g.Expect(e.OsCmd.Dir).To(Equal(TestAppDir))
g.Expect(e.OsCmd.Path).To(Equal(GetJavaCommand()))
g.Expect(e.OsCmd.Args).To(ConsistOf(GetMinimalExpectedArgsWith(t,
"-verbose:gc",
"-XX:+PrintGCDetails",
"-XX:+PrintGCTimeStamps",
"-XX:+PrintHeapAtGC",
"-XX:+PrintTenuringDistribution",
"-XX:+PrintGCApplicationStoppedTime",
"-XX:+PrintGCApplicationConcurrentTime")))
}

func TestJvmGarbageCollectorArgsEmpty(t *testing.T) {
g := NewGomegaWithT(t)

Expand Down
Loading