Skip to content
This repository has been archived by the owner on Dec 26, 2022. It is now read-only.

Commit

Permalink
Use nomad-native attribute for host IP
Browse files Browse the repository at this point in the history
Now that hashicorp/nomad#12817 is merged in as
of Nomad 1.3.2, we should stop using the hax to get the host IP and
instead use Nomad's native method to get the host IP.
  • Loading branch information
ThomasWunderlich committed Aug 18, 2022
1 parent d9f2725 commit 50e97c0
Show file tree
Hide file tree
Showing 9 changed files with 15 additions and 39 deletions.
2 changes: 0 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ DIST_DIR = $(GRAPL_ROOT)/dist
COMPOSE_USER=${UID}:${GID}
COMPOSE_IGNORE_ORPHANS=1
COMPOSE_PROJECT_NAME ?= grapl
# Get a non-loopback private ip for the host. Order is not guaranteed, but that's ok
CONSUL_DNS_IP = $(shell hostname --all-ip-addresses | awk '{ print $$1 }')

export

Expand Down
1 change: 0 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ services:
PULUMI_CONFIG_PASSPHRASE: local-grapl-passphrase
DOCKER_USER: "${UID}:${GID}"
GRAPL_ROOT: "${GRAPL_ROOT}"
CONSUL_DNS_IP: "${CONSUL_DNS_IP}"
WITH_PULUMI_TRACING: "${WITH_PULUMI_TRACING}"
# Other environment variables like MG_ALPHAS are passed in via
# Pulumi.local-grapl.yaml
Expand Down
10 changes: 1 addition & 9 deletions nomad/grapl-core.nomad
Original file line number Diff line number Diff line change
Expand Up @@ -196,12 +196,6 @@ variable "google_client_id" {
description = "Google client ID used for authenticating web users via Sign In With Google"
}

variable "dns_server" {
type = string
description = "The network.dns.server value. This should be equivalent to the host's ip in order to communicate with dnsmasq and allow consul dns to be available from within containers. This can be replaced as of Nomad 1.3.0 with variable interpolation per https://github.com/hashicorp/nomad/issues/11851."
default = ""
}

locals {
dgraph_zero_grpc_private_port_base = 5080
dgraph_zero_http_private_port_base = 6080
Expand Down Expand Up @@ -240,9 +234,7 @@ locals {
redis_host = local._redis[0]
redis_port = local._redis[1]

# TODO once we upgrade to nomad 1.3.0 replace this with attr.unique.network.ip-address (variable interpolation is
# added for network.dns as of 1.3.0
dns_servers = [var.dns_server]
dns_servers = [attr.unique.network.ip-address]

# Grapl services
graphql_endpoint_port = 5000
Expand Down
10 changes: 1 addition & 9 deletions nomad/grapl-ingress.nomad
Original file line number Diff line number Diff line change
@@ -1,14 +1,6 @@
variable "dns_server" {
type = string
description = "The network.dns.server value. This should be equivalent to the host's ip in order to communicate with dnsmasq and allow consul dns to be available from within containers. This can be replaced as of Nomad 1.3.0 with variable interpolation per https://github.com/hashicorp/nomad/issues/11851."
default = ""
}

locals {
web_ui_port = 1234
# TODO once we upgrade to nomad 1.3.0 replace this with attr.unique.network.ip-address (variable interpolation is
# added for network.dns as of 1.3.0
dns_servers = [var.dns_server]
dns_servers = [attr.unique.network.ip-address]
}

job "grapl-ingress" {
Expand Down
10 changes: 1 addition & 9 deletions nomad/rust-integration-tests.nomad
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,6 @@ variable "user_session_table" {
description = "The name of the DynamoDB user session table"
}

variable "dns_server" {
type = string
description = "The network.dns.server value. This should be equivalent to the host's ip in order to communicate with dnsmasq and allow consul dns to be available from within containers. This can be replaced as of Nomad 1.3.0 with variable interpolation per https://github.com/hashicorp/nomad/issues/11851."
default = ""
}

variable "organization_management_db" {
type = object({
hostname = string
Expand All @@ -88,9 +82,7 @@ variable "plugin_work_queue_db" {
}

locals {
# TODO once we upgrade to nomad 1.3.0 replace this with attr.unique.network.ip-address (variable interpolation is
# added for network.dns as of 1.3.0
dns_servers = [var.dns_server]
dns_servers = [attr.unique.network.ip-address]
}

job "rust-integration-tests" {
Expand Down
12 changes: 12 additions & 0 deletions nomad/template_smple.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"name": "foo",
"count": 1,
"container_image": "bar",
"env": {
"key": "value"
},
"service_type": "grpc",
"upstreams": {
"service": "port"
}
}
2 changes: 0 additions & 2 deletions pulumi/grapl/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,6 @@ def main() -> None:
aws_env_vars_for_local=aws_env_vars_for_local,
aws_region=aws.get_region().name,
container_images=_container_images(artifacts),
dns_server=config.CONSUL_DNS_IP,
kafka_bootstrap_servers=kafka.bootstrap_servers(),
kafka_credentials=kafka_service_credentials,
kafka_consumer_groups=kafka_consumer_groups,
Expand Down Expand Up @@ -288,7 +287,6 @@ def main() -> None:
nomad_grapl_ingress = NomadJob(
"grapl-ingress",
jobspec=path_from_root("nomad/grapl-ingress.nomad").resolve(),
vars={"dns_server": config.CONSUL_DNS_IP},
opts=pulumi.ResourceOptions(
provider=nomad_provider,
# This dependson ensures we've switched the web-ui protocol to http instead of tcp prior. Otherwise there's
Expand Down
6 changes: 0 additions & 6 deletions pulumi/infra/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,6 @@
# note: this ${} is interpolated inside Nomad
HOST_IP_IN_NOMAD: Final[str] = "${attr.unique.network.ip-address}"

# This is equivalent to what "${attr.unique.network.ip-address}" resolves to but is used for cases where variable
# interpolation is not available such as network.dns prior to Nomad 1.3.0
# Hax: If this is not available such as in Buildkite, we'll default to Google DNS for now.
# This should be going away once https://github.com/hashicorp/nomad/pull/12817 is merged
CONSUL_DNS_IP: Final[str] = os.getenv("CONSUL_DNS_IP", "8.8.8.8")


def to_bool(input: str | bool | None) -> bool | None:
if isinstance(input, bool):
Expand Down
1 change: 0 additions & 1 deletion pulumi/rust_integration_tests/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ def main() -> None:
"aws_env_vars_for_local": grapl_stack.aws_env_vars_for_local,
"aws_region": aws.get_region().name,
"container_images": _rust_integration_container_images(artifacts),
"dns_server": config.CONSUL_DNS_IP,
"kafka_bootstrap_servers": kafka.bootstrap_servers(),
"kafka_consumer_group": kafka.consumer_group("integration-tests"),
"kafka_credentials": kafka_credentials,
Expand Down

0 comments on commit 50e97c0

Please sign in to comment.