Skip to content

Commit

Permalink
This commit introduces support to:
Browse files Browse the repository at this point in the history
- Mount a separate volume for the shared data
- Do not mount the volume destinated for the unix socket if tcp is
  chosen as socket type for the communication agent/worker
  • Loading branch information
jfonseca-aneo committed Jan 16, 2025
1 parent 1330940 commit 361aa2a
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM mcr.microsoft.com/dotnet/aspnet:8.0 as base-linux
RUN groupadd --gid 5000 armonikuser && useradd --home-dir /home/armonikuser --create-home --uid 5000 --gid 5000 --shell /bin/sh --skel /dev/null armonikuser
RUN mkdir /cache /local_storage && chown armonikuser: /cache /local_storage
RUN mkdir /cache /local_storage /comm && chown armonikuser: /cache /local_storage /comm
USER armonikuser
ENTRYPOINT [ "dotnet" ]

Expand Down
1 change: 1 addition & 0 deletions terraform/modules/compute_plane/locals.tf
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,5 @@ locals {
]
gen_env = [for k, v in var.generated_env_vars : "${k}=${v}"]
polling_agent_name = "${var.polling_agent.name}${var.replica_counter}"
socket_vol = var.socket_type == "tcp" ? {} : { (var.polling_agent.shared_socket) = one(docker_volume.socket_vol[*].name) }
}
34 changes: 29 additions & 5 deletions terraform/modules/compute_plane/main.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
resource "docker_volume" "socket_vol" {
name = "socket_vol${var.replica_counter}"
count = var.socket_type == "tcp" ? 0 : 1
name = "socket_vol${var.replica_counter}"

}

resource "docker_volume" "comm_vol" {
name = "comm_vol${var.replica_counter}"
}

resource "docker_image" "worker" {
Expand Down Expand Up @@ -27,10 +33,19 @@ resource "docker_container" "worker" {
external = var.worker.port + var.replica_counter
}

dynamic "mounts" {
for_each = local.socket_vol
content {
type = "volume"
target = mounts.value
source = mounts.key
}
}

mounts {
type = "volume"
target = var.polling_agent.shared_socket
source = docker_volume.socket_vol.name
target = var.polling_agent.shared_data
source = docker_volume.comm_vol.name
}
}

Expand Down Expand Up @@ -59,8 +74,17 @@ resource "docker_container" "polling_agent" {

mounts {
type = "volume"
target = var.polling_agent.shared_socket
source = docker_volume.socket_vol.name
target = var.polling_agent.shared_data
source = docker_volume.comm_vol.name
}

dynamic "mounts" {
for_each = local.socket_vol
content {
type = "volume"
target = mounts.value
source = mounts.key
}
}

restart = "unless-stopped"
Expand Down
2 changes: 1 addition & 1 deletion terraform/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ variable "compute_plane" {
// env for the agent and env for the worker
// They will be used for both
shared_socket = optional(string, "/cache")
shared_data = optional(string, "/cache")
shared_data = optional(string, "/comm")
})
})
default = {
Expand Down

0 comments on commit 361aa2a

Please sign in to comment.