Skip to content

Commit

Permalink
Fix the test_named_addr related bug
Browse files Browse the repository at this point in the history
  • Loading branch information
lens0021 committed Oct 6, 2024
1 parent 28c7a1a commit 9abc188
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 19 deletions.
18 changes: 9 additions & 9 deletions jobs/fastcgi.nomad
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@ variable "test" {
default = false
}

variable "main_nomad_addr" {
variable "main_nomad_private_ip" {
type = string
default = ""
}

variable "test_nomad_public_ip" {
type = string
default = ""
}
Expand All @@ -20,11 +25,6 @@ variable "test_include_mysql" {
default = false
}

variable "test_nomad_addr" {
type = string
default = ""
}

locals {
main = !var.test
}
Expand Down Expand Up @@ -74,7 +74,7 @@ job "fastcgi" {
args = [
"-c",
var.test_include_mysql ? "echo -n 'Waiting for service'; until nslookup mysql.service.consul 127.0.0.1:8600 2>&1 >/dev/null; do echo '.'; sleep 2; done"
: "echo -n 'Waiting for service'; until nc -z ${var.main_nomad_addr} 3306 < /dev/null; do echo '.'; sleep 2; done",
: "echo -n 'Waiting for service'; until nc -z ${var.main_nomad_private_ip} 3306 < /dev/null; do echo '.'; sleep 2; done",
]
}

Expand Down Expand Up @@ -254,9 +254,9 @@ job "fastcgi" {
MEDIAWIKI_SKIP_IMPORT_SITES = "1"
MEDIAWIKI_SKIP_UPDATE = "0"

MEDIAWIKI_SERVER = "http://${var.test_nomad_addr}"
MEDIAWIKI_SERVER = "http://${var.test_nomad_public_ip}"

WG_DB_SERVER = var.test_include_mysql ? NOMAD_UPSTREAM_ADDR_mysql : var.main_nomad_addr
WG_DB_SERVER = var.test_include_mysql ? NOMAD_UPSTREAM_ADDR_mysql : "${var.main_nomad_private_ip}:3306"
WG_DB_USER = "mediawiki"
WG_DB_PASSWORD = var.mysql_password_mediawiki
}
Expand Down
10 changes: 5 additions & 5 deletions jobs/http.nomad
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ variable "test" {
default = false
}

variable "test_nomad_addr" {
variable "test_nomad_public_ip" {
type = string
default = ""
}
Expand Down Expand Up @@ -115,9 +115,9 @@ job "http" {
dynamic "env" {
for_each = var.test ? [{}] : []
content {
CADDYPATH = "/etc/caddycerts"
FASTCGI_ADDR = var.test ? NOMAD_UPSTREAM_ADDR_fastcgi : "127.0.0.1:9000"
TEST_NOMAD_ADDR = var.test_nomad_addr
CADDYPATH = "/etc/caddycerts"
FASTCGI_ADDR = var.test ? NOMAD_UPSTREAM_ADDR_fastcgi : "127.0.0.1:9000"
TEST_NOMAD_PUBLIC_IP = var.test_nomad_public_ip
}
}

Expand Down Expand Up @@ -193,7 +193,7 @@ variable "caddyfile_for_test" {
auto_https off
order mwcache before rewrite
}
http://127.0.0.1:80 http://localhost:80 http://{$TEST_NOMAD_ADDR}:80
http://127.0.0.1:80 http://localhost:80 http://{$TEST_NOMAD_PUBLIC_IP}:80
root * /srv/femiwiki.com
php_fastcgi {$FASTCGI_ADDR}
file_server
Expand Down
2 changes: 1 addition & 1 deletion terraform/base.tf
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ provider "nomad" {

provider "nomad" {
alias = "test"
address = data.terraform_remote_state.aws.outputs.test_nomad_addr
address = "http://${data.terraform_remote_state.aws.outputs.test_nomad_public_ip}:4646"
secret_id = var.test_nomad_token
consul_token = var.test_consul_token
region = "global"
Expand Down
8 changes: 4 additions & 4 deletions terraform/mediawiki.tf
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@ resource "nomad_job" "test_fastcgi" {
allow_fs = true
vars = {
test = true
main_nomad_addr = data.terraform_remote_state.aws.outputs.nomad_addr
main_nomad_private_ip = data.terraform_remote_state.aws.outputs.nomad_private_ip
mysql_password_mediawiki = var.mysql_password_mediawiki
test_nomad_addr = data.terraform_remote_state.aws.outputs.test_nomad_addr
test_nomad_public_ip = data.terraform_remote_state.aws.outputs.test_nomad_public_ip
test_include_mysql = false
}
}
Expand Down Expand Up @@ -97,8 +97,8 @@ resource "nomad_job" "test_http" {
hcl2 {
allow_fs = true
vars = {
test = true
test_nomad_addr = data.terraform_remote_state.aws.outputs.test_nomad_addr
test = true
test_nomad_public_ip = data.terraform_remote_state.aws.outputs.test_nomad_public_ip
}
}
}

0 comments on commit 9abc188

Please sign in to comment.