Skip to content

Commit

Permalink
Allow small cpu requests for Synchrony pod
Browse files Browse the repository at this point in the history
  • Loading branch information
Yevhen Ivantsov committed Aug 21, 2023
1 parent 804005b commit d5ea60b
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/main/charts/confluence/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ Kubernetes: `>=1.21.x-0`
| synchrony.readinessProbe.initialDelaySeconds | int | `5` | The initial delay (in seconds) for the Synchrony container readiness probe, after which the probe will start running. |
| synchrony.readinessProbe.periodSeconds | int | `1` | How often (in seconds) the Synchrony container readiness probe will run |
| synchrony.replicaCount | int | `1` | Number of Synchrony pods |
| synchrony.resources.container.requests.cpu | string | `"2"` | Initial CPU request by Synchrony pod |
| synchrony.resources.container.requests.cpu | string | `"2"` | Initial CPU request by Synchrony pod. Because the container CPU request value is used in -XX:ActiveProcessorCount argument to Synchrony JVM only integers are allowed, e.g. 1, 2, 3 etc. If you want to have a small CPU claim, set it as 30m, 50m, etc. Any container cpu request value containing `m` character will be converted to -XX:ActiveProcessorCount=1 See: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/#meaning-of-cpu |
| synchrony.resources.container.requests.memory | string | `"2.5G"` | Initial Memory request Synchrony pod |
| synchrony.resources.jvm.maxHeap | string | `"2g"` | The minimum amount of heap memory that will be used by the Synchrony JVM |
| synchrony.resources.jvm.minHeap | string | `"1g"` | The maximum amount of heap memory that will be used by the Synchrony JVM |
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
{{ if .Values.synchrony.enabled }}
{{- $activeProcessorCount := 1 -}}
{{- $cpuRequest := .Values.synchrony.resources.container.requests.cpu | toString -}}
{{- if not (contains "m" $cpuRequest) }}
{{- $activeProcessorCount = .Values.synchrony.resources.container.requests.cpu -}}
{{- end }}
apiVersion: v1
kind: ConfigMap
metadata:
Expand All @@ -19,7 +24,7 @@ data:
{{- range .Values.synchrony.additionalJvmArgs }}
{{ . }} \
{{- end }}
-XX:ActiveProcessorCount={{ .Values.synchrony.resources.container.requests.cpu }} \
-XX:ActiveProcessorCount={{ $activeProcessorCount }} \
-classpath /opt/atlassian/confluence/confluence/WEB-INF/packages/synchrony-standalone.jar:/opt/atlassian/confluence/confluence/WEB-INF/lib/* \
synchrony.core \
sql
Expand Down
5 changes: 4 additions & 1 deletion src/main/charts/confluence/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1120,7 +1120,10 @@ synchrony:
#
container:
requests:
# -- Initial CPU request by Synchrony pod
# -- Initial CPU request by Synchrony pod. Because the container CPU request value is used in -XX:ActiveProcessorCount argument to Synchrony JVM
# only integers are allowed, e.g. 1, 2, 3 etc. If you want to have a small CPU claim, set it to 30m, 50m, etc.
# Any container cpu request value containing `m` character will be converted to -XX:ActiveProcessorCount=1
# See: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/#meaning-of-cpu
#
cpu: "2"

Expand Down
8 changes: 8 additions & 0 deletions src/test/config/kind/common-values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,11 @@ monitoring:
createDashboards: true
dashboardLabels:
grafana_dashboard: dc_monitoring

synchrony:
enabled: true
resources:
container:
requests:
cpu: 20m
memory: 1G
29 changes: 29 additions & 0 deletions src/test/java/test/SynchronyTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,35 @@ void synchrony_entrypoint(Product product) throws Exception {
.hasTextContaining("-XX:ActiveProcessorCount=2");
}

@ParameterizedTest
@EnumSource(value = Product.class, names = "confluence")
void synchrony_small_cpu_request(Product product) throws Exception {
final var resources = helm.captureKubeResourcesFromHelmChart(product, Map.of(
"synchrony.enabled", "true",
"synchrony.resources.container.requests.cpu", "20m"
));

final var entrypoint = resources.get(Kind.ConfigMap, product.getHelmReleaseName() + "-synchrony-entrypoint")
.getNode("data", "start-synchrony.sh");

assertThat(entrypoint)
.hasTextContaining("-XX:ActiveProcessorCount=1");
}

@ParameterizedTest
@EnumSource(value = Product.class, names = "confluence")
void synchrony_custom_cpu_request(Product product) throws Exception {
final var resources = helm.captureKubeResourcesFromHelmChart(product, Map.of(
"synchrony.enabled", "true",
"synchrony.resources.container.requests.cpu", "5"
));

final var entrypoint = resources.get(Kind.ConfigMap, product.getHelmReleaseName() + "-synchrony-entrypoint")
.getNode("data", "start-synchrony.sh");

assertThat(entrypoint)
.hasTextContaining("-XX:ActiveProcessorCount=5");
}
@ParameterizedTest
@EnumSource(value = Product.class, names = "confluence")
void synchrony_replica_count(Product product) throws Exception {
Expand Down

0 comments on commit d5ea60b

Please sign in to comment.