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

Added jvm and config custom variables #123

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
- Trino consul connect plugin source and build #?
- Using Trino docker image with tag 354 #106
- Support for Postrgres connector #105
- Support for custom JVM and config properties in Trino [#120](https://github.com/Skatteetaten/terraform-nomad-trino/issues/120)

### Fixed
- `make clean` will clean terraform state #?
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,8 @@ module "trino" {
| minio_vault_secret | Minio data-object contains vault related information to fetch credentials | obj(bool, string, string, string, string) | { <br> use_vault_provider = false, <br> vault_kv_policy_name = "kv-secret", <br> vault_kv_path = "secret/data/dev/trino", <br> vault_kv_field_access_name = "access_key", <br> vault_kv_field_secret_name = "secret_key" <br> } | no |
| postgres_service | Postgres data-object contains service_name, port, username, password and database_name | obj(string, number, string, string, string) | - | no |
| postgres_vault_secret | Set of properties to be able to fetch Postgres secrets from vault | obj(bool, string, string, string, string) | { <br> use_vault_provider = false, <br> vault_kv_policy_name = "kv-secret", <br> vault_kv_path = "secret/data/dev/trino", <br> vault_kv_field_username = "username", <br> vault_kv_field_password = "username" <br> } | no |
| trino_standalone_jvm_properties | Extra lines of configuration that will be added to Trino's 'jvm.config' file | list(string) | [""] | no |
| trino_standalone_config_properties | Extra lines of configuration that will be added to Trino's 'config.properties' file | list(string) | [""] | no |

## Outputs
| Name | Description | Type |
Expand Down
2 changes: 2 additions & 0 deletions conf/nomad/trino_standalone.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -257,13 +257,15 @@ node-scheduler.include-coordinator=true
http-server.http.port=8080
discovery-server.enabled=true
discovery.uri=http://127.0.0.1:8080
${trino_standalone_config_properties}
EOH
} # Total memory allocation is subtracted by 256MB to keep something for the OS.
template {
destination = "local/trino/jvm.config"
data = <<EOF
-server
-Xmx{{ env "NOMAD_MEMORY_LIMIT" | parseInt | subtract 256 }}M
${trino_standalone_jvm_properties}
EOF
}
template {
Expand Down
48 changes: 28 additions & 20 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ locals {
hive_config_properties = join("\n",
concat(var.hive_config_properties)
)
trino_standalone_jvm_properties = join("\n",
concat(var.trino_standalone_jvm_properties)
)
trino_standalone_config_properties = join("\n",
concat(var.trino_standalone_config_properties)
)

template_standalone = file("${path.module}/conf/nomad/trino_standalone.hcl")
template_cluster = file("${path.module}/conf/nomad/trino.hcl")
Expand Down Expand Up @@ -40,26 +46,28 @@ data "template_file" "template_nomad_job_trino" {
vault_policy_array = local.vault_kv_policy_name_set

# trino
service_name = var.service_name
node_types = jsonencode(local.node_types)
local_docker_image = var.local_docker_image
consul_image = var.consul_docker_image
shared_secret_user = var.shared_secret_user
use_vault_secret_provider = var.vault_secret.use_vault_provider
vault_kv_policy_name = var.vault_secret.vault_kv_policy_name
vault_kv_path = var.vault_secret.vault_kv_path
vault_kv_field_secret_name = var.vault_secret.vault_kv_field_secret_name
workers = var.workers
docker_image = var.docker_image
envs = local.trino_env_vars
hive_config_properties = local.hive_config_properties
debug = var.debug
memory = var.resource.memory
cpu = var.resource.cpu
consul_http_addr = var.consul_http_addr
use_canary = var.use_canary
cpu_proxy = var.resource_proxy.cpu
memory_proxy = var.resource_proxy.memory
service_name = var.service_name
node_types = jsonencode(local.node_types)
local_docker_image = var.local_docker_image
consul_image = var.consul_docker_image
shared_secret_user = var.shared_secret_user
use_vault_secret_provider = var.vault_secret.use_vault_provider
vault_kv_policy_name = var.vault_secret.vault_kv_policy_name
vault_kv_path = var.vault_secret.vault_kv_path
vault_kv_field_secret_name = var.vault_secret.vault_kv_field_secret_name
workers = var.workers
docker_image = var.docker_image
envs = local.trino_env_vars
hive_config_properties = local.hive_config_properties
debug = var.debug
memory = var.resource.memory
cpu = var.resource.cpu
consul_http_addr = var.consul_http_addr
use_canary = var.use_canary
cpu_proxy = var.resource_proxy.cpu
memory_proxy = var.resource_proxy.memory
trino_standalone_jvm_properties = local.trino_standalone_jvm_properties
trino_standalone_config_properties = local.trino_standalone_config_properties

# Memory allocations for trino is automatically tuned based on memory sizing set at the task driver level in nomad.
# Based on web-resources and trino community slack, we choose to allocate 75% (up to 80% should work) to the JVM
Expand Down
13 changes: 13 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,19 @@ variable "hive_config_properties" {
default = [""]
}

variable "trino_standalone_jvm_properties" {
type = list(string)
description = "Custom JVM config parameters that will be added to Trino's 'jvm.config'"
default = [""]
}

variable "trino_standalone_config_properties" {
type = list(string)
description = "Custom config properties that will be added to Trino's 'config.properties'"
default = [""]
}


######
# Service dependencies
######
Expand Down