Skip to content

Commit

Permalink
Add support for Database resource group manager
Browse files Browse the repository at this point in the history
  • Loading branch information
yassan committed Nov 7, 2024
1 parent 4630167 commit e5f8517
Show file tree
Hide file tree
Showing 9 changed files with 285 additions and 120 deletions.
2 changes: 1 addition & 1 deletion charts/trino/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.33.0
version: 0.34.0

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
Expand Down
130 changes: 72 additions & 58 deletions charts/trino/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# trino

![Version: 0.33.0](https://img.shields.io/badge/Version-0.33.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 464](https://img.shields.io/badge/AppVersion-464-informational?style=flat-square)
![Version: 0.34.0](https://img.shields.io/badge/Version-0.34.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 464](https://img.shields.io/badge/AppVersion-464-informational?style=flat-square)

Fast distributed SQL query engine for big data analytics that helps you explore your data universe

Expand Down Expand Up @@ -175,65 +175,79 @@ Fast distributed SQL query engine for big data analytics that helps you explore
```
* `resourceGroups` - object, default: `{}`

Resource groups file is mounted to /etc/trino/resource-groups/resource-groups.json
Example:
[Resource groups control](https://trino.io/docs/current/admin/resource-groups.html)
Set the type property to either:
* `configmap`, and provide the Resource groups file contents in `resourceGroupsConfig`,
* `properties`, and provide configuration properties in `properties`.
Properties example:
```yaml
type: properties
properties: |
resource-groups.configuration-manager=db
resource-groups.config-db-url=jdbc:mysql://trino-mysql.mysql.svc.cluster.local:3306/resource_groups
resource-groups.config-db-user=username
resource-groups.config-db-password=password
```
Config map example:
```yaml
type: configmap
# Resource groups file is mounted to /etc/trino/resource-groups/resource-groups.json
resourceGroupsConfig: |-
{
"rootGroups": [
{
"name": "global",
"softMemoryLimit": "80%",
"hardConcurrencyLimit": 100,
"maxQueued": 100,
"schedulingPolicy": "fair",
"jmxExport": true,
"subGroups": [
{
"name": "admin",
"softMemoryLimit": "30%",
"hardConcurrencyLimit": 20,
"maxQueued": 10
},
{
"name": "finance_human_resources",
"softMemoryLimit": "20%",
"hardConcurrencyLimit": 15,
"maxQueued": 10
},
{
"name": "general",
"softMemoryLimit": "30%",
"hardConcurrencyLimit": 20,
"maxQueued": 10
},
{
"name": "readonly",
"softMemoryLimit": "10%",
"hardConcurrencyLimit": 5,
"maxQueued": 5
}
]
}
],
"selectors": [
{
"user": "admin",
"group": "global.admin"
},
{
"group": "finance|human_resources",
"group": "global.finance_human_resources"
},
{
"user": "alice",
"group": "global.readonly"
},
{
"group": "global.general"
}
]
}
{
"rootGroups": [
{
"name": "global",
"softMemoryLimit": "80%",
"hardConcurrencyLimit": 100,
"maxQueued": 100,
"schedulingPolicy": "fair",
"jmxExport": true,
"subGroups": [
{
"name": "admin",
"softMemoryLimit": "30%",
"hardConcurrencyLimit": 20,
"maxQueued": 10
},
{
"name": "finance_human_resources",
"softMemoryLimit": "20%",
"hardConcurrencyLimit": 15,
"maxQueued": 10
},
{
"name": "general",
"softMemoryLimit": "30%",
"hardConcurrencyLimit": 20,
"maxQueued": 10
},
{
"name": "readonly",
"softMemoryLimit": "10%",
"hardConcurrencyLimit": 5,
"maxQueued": 5
}
]
}
],
"selectors": [
{
"user": "admin",
"group": "global.admin"
},
{
"group": "finance|human_resources",
"group": "global.finance_human_resources"
},
{
"user": "alice",
"group": "global.readonly"
},
{
"group": "global.general"
}
]
}
```
* `additionalNodeProperties` - list, default: `[]`

Expand Down
13 changes: 12 additions & 1 deletion charts/trino/templates/configmap-coordinator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,20 @@ data:
{{- end }}

{{- if .Values.resourceGroups }}
{{- if eq .Values.resourceGroups.type "configmap" }}
resource-groups.properties: |
resource-groups.configuration-manager=file
resource-groups.config-file={{ .Values.server.config.path }}/resource-groups/resource-groups.json
{{- else if eq .Values.resourceGroups.type "properties" }}
resource-groups.properties: |
{{- if .Values.resourceGroups.properties }}
{{- .Values.resourceGroups.properties | nindent 4 }}
{{- else}}
{{- fail "resourceGroups.properties is required when resourceGroups.type is 'properties'." }}
{{- end }}
{{- else}}
{{- fail "Invalid resourceGroups.type value. It must be either 'configmap' or 'properties'." }}
{{- end }}
{{- end }}

{{- if .Values.server.exchangeManager }}
Expand Down Expand Up @@ -151,7 +162,7 @@ data:
{{ $fileName }}: |
{{- tpl $fileContent $ | nindent 4 }}
{{- end }}
{{- if .Values.resourceGroups }}
{{- if eq .Values.resourceGroups.type "configmap" }}
---
apiVersion: v1
kind: ConfigMap
Expand Down
4 changes: 2 additions & 2 deletions charts/trino/templates/deployment-coordinator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ spec:
configMap:
name: {{ template "trino.fullname" . }}-access-control-volume-coordinator
{{- end }}
{{- if .Values.resourceGroups }}
{{- if eq .Values.resourceGroups.type "configmap" }}
- name: resource-groups-volume
configMap:
name: {{ template "trino.fullname" . }}-resource-groups-volume-coordinator
Expand Down Expand Up @@ -146,7 +146,7 @@ spec:
- mountPath: {{ .Values.server.config.path }}/access-control
name: access-control-volume
{{- end }}
{{- if .Values.resourceGroups }}
{{- if eq .Values.resourceGroups.type "configmap" }}
- mountPath: {{ .Values.server.config.path }}/resource-groups
name: resource-groups-volume
{{- end }}
Expand Down
33 changes: 33 additions & 0 deletions charts/trino/templates/tests/test-resource-groups-db.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{{- if eq .Values.resourceGroups.type "properties" }}
apiVersion: v1
kind: Pod
metadata:
name: {{ include "trino.fullname" . }}-test-add-resourcegroups-data
labels:
{{- include "trino.labels" . | nindent 4 }}
app.kubernetes.io/component: test
test: add-resource-groups-data
annotations:
"helm.sh/hook": test
"helm.sh/hook-weight": "-1"
spec:
containers:
- name: mysql-client
image: bitnami/mysql:8.1
command:
- /bin/sh
- -c
- |
echo "Inserting data into MySQL";
mysql -h trino-resource-groups-db-mysql.mysql.svc.cluster.local -u trino -ppass0000 resource_groups -e "
-- create a root group 'admin' with NULL parent
INSERT INTO resource_groups (name, soft_memory_limit, hard_concurrency_limit, max_queued, scheduling_policy, environment)
VALUES ('admin', '100%', 50, 100, 'query_priority', 'production');
-- use ID of 'admin' resource group for selector
INSERT INTO selectors (resource_group_id, user_regex, priority) VALUES ((SELECT resource_group_id FROM resource_groups WHERE name = 'admin'), 'admin', 6);
-- check data
SELECT * FROM resource_groups;
SELECT * FROM selectors;";
sleep 5
restartPolicy: Never
{{- end }}
128 changes: 71 additions & 57 deletions charts/trino/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -183,66 +183,80 @@ accessControl: {}
# ```

resourceGroups: {}
# resourceGroups -- Resource groups file is mounted to /etc/trino/resource-groups/resource-groups.json
# resourceGroups -- [Resource groups control](https://trino.io/docs/current/admin/resource-groups.html)
# @raw
# Example:
# Set the type property to either:
# * `configmap`, and provide the Resource groups file contents in `resourceGroupsConfig`,
# * `properties`, and provide configuration properties in `properties`.
# Properties example:
# ```yaml
# type: properties
# properties: |
# resource-groups.configuration-manager=db
# resource-groups.config-db-url=jdbc:mysql://trino-mysql.mysql.svc.cluster.local:3306/resource_groups
# resource-groups.config-db-user=username
# resource-groups.config-db-password=password
# ```
# Config map example:
# ```yaml
# type: configmap
# # Resource groups file is mounted to /etc/trino/resource-groups/resource-groups.json
# resourceGroupsConfig: |-
# {
# "rootGroups": [
# {
# "name": "global",
# "softMemoryLimit": "80%",
# "hardConcurrencyLimit": 100,
# "maxQueued": 100,
# "schedulingPolicy": "fair",
# "jmxExport": true,
# "subGroups": [
# {
# "name": "admin",
# "softMemoryLimit": "30%",
# "hardConcurrencyLimit": 20,
# "maxQueued": 10
# },
# {
# "name": "finance_human_resources",
# "softMemoryLimit": "20%",
# "hardConcurrencyLimit": 15,
# "maxQueued": 10
# },
# {
# "name": "general",
# "softMemoryLimit": "30%",
# "hardConcurrencyLimit": 20,
# "maxQueued": 10
# },
# {
# "name": "readonly",
# "softMemoryLimit": "10%",
# "hardConcurrencyLimit": 5,
# "maxQueued": 5
# }
# ]
# }
# ],
# "selectors": [
# {
# "user": "admin",
# "group": "global.admin"
# },
# {
# "group": "finance|human_resources",
# "group": "global.finance_human_resources"
# },
# {
# "user": "alice",
# "group": "global.readonly"
# },
# {
# "group": "global.general"
# }
# ]
# }
# {
# "rootGroups": [
# {
# "name": "global",
# "softMemoryLimit": "80%",
# "hardConcurrencyLimit": 100,
# "maxQueued": 100,
# "schedulingPolicy": "fair",
# "jmxExport": true,
# "subGroups": [
# {
# "name": "admin",
# "softMemoryLimit": "30%",
# "hardConcurrencyLimit": 20,
# "maxQueued": 10
# },
# {
# "name": "finance_human_resources",
# "softMemoryLimit": "20%",
# "hardConcurrencyLimit": 15,
# "maxQueued": 10
# },
# {
# "name": "general",
# "softMemoryLimit": "30%",
# "hardConcurrencyLimit": 20,
# "maxQueued": 10
# },
# {
# "name": "readonly",
# "softMemoryLimit": "10%",
# "hardConcurrencyLimit": 5,
# "maxQueued": 5
# }
# ]
# }
# ],
# "selectors": [
# {
# "user": "admin",
# "group": "global.admin"
# },
# {
# "group": "finance|human_resources",
# "group": "global.finance_human_resources"
# },
# {
# "user": "alice",
# "group": "global.readonly"
# },
# {
# "group": "global.general"
# }
# ]
# }
# ```

additionalNodeProperties: []
Expand Down
15 changes: 15 additions & 0 deletions test-resource-groups-properties-values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Resource Groups 'properties' values to test.
# This is a YAML-formatted file.

server:
log:
trino:
level: INFO

resourceGroups:
type: properties
properties: |
resource-groups.configuration-manager=db
resource-groups.config-db-url=jdbc:mysql://trino-resource-groups-db-mysql.mysql.svc.cluster.local:3306/resource_groups
resource-groups.config-db-user=trino
resource-groups.config-db-password=pass0000
Loading

0 comments on commit e5f8517

Please sign in to comment.