Skip to content

Commit

Permalink
Add a property for default sidecar mem limit
Browse files Browse the repository at this point in the history
Signed-off-by: Oleksandr Garagatyi <ogaragat@redhat.com>
  • Loading branch information
Oleksandr Garagatyi committed Sep 17, 2018
1 parent 10502cf commit 036f044
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 8 deletions.
Expand Up @@ -97,6 +97,9 @@ che.workspace.exec_linux_amd64=${che.home}/lib/linux_amd64/exec
# RAM limit default for each machine that has no RAM settings in environment.
che.workspace.default_memory_limit_mb=1024

# RAM limit default for each sidecar that has no RAM settings in Che plugin configuration.
che.workspace.sidecar.default_memory_limit_mb=128

# RAM request default for each machine that has no explicit RAM settings in environment.
# this amount will be allocated on workspace container creation
# this property might not be supported by all infrastructure implementations:
Expand Down
7 changes: 5 additions & 2 deletions deploy/kubernetes/helm/che/templates/configmap.yaml
Expand Up @@ -80,6 +80,9 @@ data:
{{- if .Values.workspaceDefaultRamRequest }}
CHE_WORKSPACE_DEFAULT_MEMORY_REQUEST_MB: {{ .Values.workspaceDefaultRamRequest }}
{{- end }}
{{- if .Values.workspaceDefaultRamRequest }}
CHE_WORKSPACE_DEFAULT_MEMORY_LIMIT_MB: {{ .Values.workspaceDefaultRamRequest }}
{{- if .Values.workspaceDefaultRamLimit }}
CHE_WORKSPACE_DEFAULT_MEMORY_LIMIT_MB: {{ .Values.workspaceDefaultRamLimit }}
{{- end }}
{{- if .Values.workspaceSidecarDefaultRamLimit }}
CHE_WORKSPACE_SIDECAR_DEFAULT__MEMORY__LIMIT__MB: {{ .Values.workspaceSidecarDefaultRamLimit }}
{{- end }}
7 changes: 7 additions & 0 deletions deploy/kubernetes/helm/che/templates/deployment.yaml
Expand Up @@ -283,6 +283,13 @@ spec:
configMapKeyRef:
key: CHE_WORKSPACE_DEFAULT_MEMORY_LIMIT_MB
name: che
{{- end }}
{{- if .Values.workspaceSidecarDefaultRamLimit }}
- name: CHE_WORKSPACE_SIDECAR_DEFAULT__MEMORY__LIMIT__MB
valueFrom:
configMapKeyRef:
key: CHE_WORKSPACE_SIDECAR_DEFAULT__MEMORY__LIMIT__MB
name: che
{{- end }}
image: {{ .Values.cheImage }}
imagePullPolicy: {{ .Values.cheImagePullPolicy }}
Expand Down
1 change: 1 addition & 0 deletions deploy/kubernetes/helm/che/values.yaml
Expand Up @@ -24,6 +24,7 @@ cheKeycloakClientId: "che-public"
#customOidcProvider: ""
#workspaceDefaultRamRequest: ""
#workspaceDefaultRamLimit: ""
#workspaceSidecarDefaultRamLimit: ""

global:
cheNamespace: ""
Expand Down
7 changes: 6 additions & 1 deletion deploy/openshift/templates/che-server-template.yaml
Expand Up @@ -139,6 +139,8 @@ objects:
value: "${CHE_INFRA_KUBERNETES_PVC_QUANTITY}"
- name: PROTOCOL
value: "${PROTOCOL}"
- name: CHE_WORKSPACE_SIDECAR_DEFAULT__MEMORY__LIMIT__MB
value: "${CHE_WORKSPACE_SIDECAR_DEFAULT__MEMORY__LIMIT__MB}"
- name: ROUTING_SUFFIX
value: "${ROUTING_SUFFIX}"
- name: OPENSHIFT_IDENTITY_PROVIDER_CERTIFICATE
Expand All @@ -159,7 +161,6 @@ objects:
initialDelaySeconds: 50
failureThreshold: 3
timeoutSeconds: 2
name: che
readinessProbe:
httpGet:
path: /api/system/state
Expand Down Expand Up @@ -287,6 +288,10 @@ parameters:
displayName: Eclipse Che plugin registry URL
description: Url that used to get meta information about Eclipse Che tooling
value: 'NULL'
- name: CHE_WORKSPACE_SIDECAR_DEFAULT__MEMORY__LIMIT__MB
displayName: Plugin sidecar default memory limit
description: Plugin sidecar default memory limit in megabytes
value: '128'
labels:
app: che
template: che
Expand Up @@ -60,13 +60,13 @@
@Beta
public class KubernetesPluginsToolingApplier implements ChePluginsApplier {

private final String defaultMachineMemorySizeAttribute;
private final String defaultSidecarMemorySizeAttribute;

@Inject
public KubernetesPluginsToolingApplier(
@Named("che.workspace.default_memory_mb") long defaultMachineMemorySizeMB) {
this.defaultMachineMemorySizeAttribute =
String.valueOf(defaultMachineMemorySizeMB * 1024 * 1024);
@Named("che.workspace.sidecar.default_memory_limit_mb") long defaultSidecarMemorySizeMB) {
this.defaultSidecarMemorySizeAttribute =
String.valueOf(defaultSidecarMemorySizeMB * 1024 * 1024);
}

@Override
Expand Down Expand Up @@ -224,7 +224,7 @@ private void normalizeMemory(
if (ramLimit > 0) {
attributes.put(MEMORY_LIMIT_ATTRIBUTE, String.valueOf(ramLimit));
} else {
attributes.put(MEMORY_LIMIT_ATTRIBUTE, defaultMachineMemorySizeAttribute);
attributes.put(MEMORY_LIMIT_ATTRIBUTE, defaultSidecarMemorySizeAttribute);
}
}

Expand Down

0 comments on commit 036f044

Please sign in to comment.