-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Add new workloads #25106
base: main
Are you sure you want to change the base?
Add new workloads #25106
Changes from 4 commits
25cf0ba
05aaa42
abba21b
33bd028
e2c65d1
80f8b0a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -65,7 +65,8 @@ scenario "upgrade" { | |
module = module.provision_cluster | ||
variables { | ||
name = local.cluster_name | ||
nomad_local_binary = step.copy_initial_binary.nomad_local_binary | ||
nomad_local_binary = step.copy_initial_binary.binary_path[matrix.os] | ||
nomad_local_binary_server = step.copy_initial_binary.binary_path[local.server_os] | ||
server_count = var.server_count | ||
client_count_linux = local.linux_count | ||
client_count_windows_2016 = local.windows_count | ||
|
@@ -91,6 +92,14 @@ scenario "upgrade" { | |
cert_file = step.provision_cluster.cert_file | ||
key_file = step.provision_cluster.key_file | ||
nomad_token = step.provision_cluster.nomad_token | ||
workloads = { | ||
service_raw_exec = { job_spec = "jobs/raw-exec-service.nomad.hcl", alloc_count = 3, type = "service" } | ||
service_docker = { job_spec = "jobs/docker-service.nomad.hcl", alloc_count = 3, type = "service" } | ||
system_docker = { job_spec = "jobs/docker-system.nomad.hcl", alloc_count = 0, type = "system" } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The alloc count for system jobs doesn't really matter, its set to 0 to emphasis it |
||
batch_docker = { job_spec = "jobs/docker-batch.nomad.hcl", alloc_count = 3, type = "batch" } | ||
batch_raw_exec = { job_spec = "jobs/raw-exec-batch.nomad.hcl", alloc_count = 3, type = "batch" } | ||
system_raw_exec = { job_spec = "jobs/raw-exec-system.nomad.hcl", alloc_count = 0, type = "system" } | ||
} | ||
} | ||
|
||
verifies = [ | ||
|
@@ -150,8 +159,8 @@ scenario "upgrade" { | |
arch = local.arch | ||
edition = matrix.edition | ||
product_version = var.upgrade_version | ||
os = matrix.os | ||
download_binary = false | ||
oss = [local.server_os, matrix.os] | ||
download_binaries = false | ||
} | ||
} | ||
|
||
|
@@ -193,8 +202,8 @@ scenario "upgrade" { | |
ssh_key_path = step.provision_cluster.ssh_key_file | ||
artifactory_username = var.artifactory_username | ||
artifactory_token = var.artifactory_token | ||
artifact_url = step.fetch_upgrade_binary.artifact_url | ||
artifact_sha = step.fetch_upgrade_binary.artifact_sha | ||
artifact_url = step.fetch_upgrade_binary.artifact_url[local.server_os] | ||
artifact_sha = step.fetch_upgrade_binary.artifact_sha[local.server_os] | ||
} | ||
} | ||
|
||
|
@@ -235,27 +244,6 @@ scenario "upgrade" { | |
] | ||
} | ||
|
||
/* step "run_workloads" { | ||
depends_on = [step.server_upgrade_test_cluster_health] | ||
|
||
description = <<-EOF | ||
Verify the health of the cluster by running new workloads | ||
EOF | ||
|
||
module = module.run_workloads | ||
variables { | ||
nomad_addr = step.provision_cluster.nomad_addr | ||
ca_file = step.provision_cluster.ca_file | ||
cert_file = step.provision_cluster.cert_file | ||
key_file = step.provision_cluster.key_file | ||
nomad_token = step.provision_cluster.nomad_token | ||
} | ||
|
||
verifies = [ | ||
quality.nomad_register_job, | ||
] | ||
} | ||
*/ | ||
step "upgrade_clients" { | ||
depends_on = [step.server_upgrade_test_cluster_health] | ||
|
||
|
@@ -295,8 +283,8 @@ scenario "upgrade" { | |
ssh_key_path = step.provision_cluster.ssh_key_file | ||
artifactory_username = var.artifactory_username | ||
artifactory_token = var.artifactory_token | ||
artifact_url = step.fetch_upgrade_binary.artifact_url | ||
artifact_sha = step.fetch_upgrade_binary.artifact_sha | ||
artifact_url = step.fetch_upgrade_binary.artifact_url[matrix.os] | ||
artifact_sha = step.fetch_upgrade_binary.artifact_sha[matrix.os] | ||
} | ||
} | ||
|
||
|
@@ -377,4 +365,12 @@ scenario "upgrade" { | |
value = step.provision_cluster.nomad_token | ||
sensitive = true | ||
} | ||
|
||
output "binary_path" { | ||
value = step.copy_initial_binary.binary_path | ||
} | ||
|
||
output "allocs" { | ||
value = step.run_initial_workloads.allocs_count | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# Copyright (c) HashiCorp, Inc. | ||
# SPDX-License-Identifier: BUSL-1.1 | ||
variable "alloc_count" { | ||
type = number | ||
default = 1 | ||
} | ||
|
||
job "batch-docker" { | ||
type = "batch" | ||
|
||
group "batch-docker" { | ||
count = var.alloc_count | ||
|
||
task "batch-docker" { | ||
driver = "docker" | ||
|
||
config { | ||
image = "alpine:latest" | ||
command = "sh" | ||
args = ["-c", "while true; do sleep 30000; done"] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Batch workloads are a little tricky -- we probably want to make sure that they can complete and not get rescheduled by client/server restarts, rather than having them wait forever. But that'll require some new assertion logic, so let's come back to that. |
||
|
||
} | ||
|
||
resources { | ||
cpu = 50 | ||
memory = 64 | ||
} | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,8 +20,8 @@ job "service-docker" { | |
} | ||
|
||
resources { | ||
cpu = 100 | ||
memory = 128 | ||
cpu = 50 | ||
memory = 64 | ||
} | ||
} | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# Copyright (c) HashiCorp, Inc. | ||
# SPDX-License-Identifier: BUSL-1.1 | ||
variable "alloc_count" { | ||
type = number | ||
default = 1 | ||
} | ||
|
||
job "system-docker" { | ||
type = "system" | ||
|
||
group "system-docker" { | ||
|
||
task "system-docker" { | ||
driver = "docker" | ||
|
||
config { | ||
image = "alpine:latest" | ||
command = "sh" | ||
args = ["-c", "while true; do sleep 30000; done"] | ||
Comment on lines
+17
to
+19
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For service/system jobs, we should probably use a workload where we can assert more about it than "is the alloc running?". |
||
|
||
} | ||
|
||
resources { | ||
cpu = 50 | ||
memory = 64 | ||
} | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# Copyright (c) HashiCorp, Inc. | ||
# SPDX-License-Identifier: BUSL-1.1 | ||
|
||
variable "alloc_count" { | ||
type = number | ||
default = 1 | ||
} | ||
|
||
job "batch-raw-exec" { | ||
type = "batch" | ||
|
||
group "batch-raw-exec" { | ||
count = var.alloc_count | ||
|
||
task "batch-raw-exec" { | ||
driver = "raw_exec" | ||
|
||
config { | ||
command = "bash" | ||
args = ["-c", "./local/runme.sh"] | ||
} | ||
|
||
template { | ||
data = <<EOH | ||
#!/bin/bash | ||
|
||
while true; do | ||
sleep 30000 | ||
done | ||
EOH | ||
destination = "local/runme.sh" | ||
perms = "755" | ||
} | ||
|
||
resources { | ||
cpu = 50 | ||
memory = 64 | ||
} | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,6 +35,11 @@ EOH | |
destination = "local/runme.sh" | ||
perms = "755" | ||
} | ||
|
||
resources { | ||
cpu = 50 | ||
memory = 64 | ||
} | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# Copyright (c) HashiCorp, Inc. | ||
# SPDX-License-Identifier: BUSL-1.1 | ||
|
||
variable "alloc_count" { | ||
type = number | ||
default = 1 | ||
} | ||
|
||
job "system-raw-exec" { | ||
type = "system" | ||
|
||
group "system-raw-exec" { | ||
|
||
task "system-raw-exec" { | ||
driver = "raw_exec" | ||
|
||
config { | ||
command = "bash" | ||
args = ["-c", "./local/runme.sh"] | ||
} | ||
|
||
template { | ||
data = <<EOH | ||
#!/bin/bash | ||
|
||
while true; do | ||
sleep 30000 | ||
done | ||
EOH | ||
destination = "local/runme.sh" | ||
perms = "755" | ||
} | ||
|
||
resources { | ||
cpu = 50 | ||
memory = 64 | ||
} | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,27 @@ | ||
# Copyright (c) HashiCorp, Inc. | ||
# SPDX-License-Identifier: BUSL-1.1 | ||
|
||
/* output "jobs_count" { | ||
value = length(local.job_names) | ||
} */ | ||
|
||
output "jobs_count" { | ||
description = "The number of jobs thar should be running in the cluster" | ||
value = length(var.workloads) + chomp(enos_local_exec.get_jobs.stdout) | ||
} | ||
|
||
output "new_jobs_count" { | ||
description = "The number of jobs that were triggered by the module" | ||
value = length(var.workloads) | ||
} | ||
|
||
output "allocs_count" { | ||
description = "The number of allocs that should be running in the cluster" | ||
value = sum([for wl in var.workloads : wl.alloc_count]) | ||
value = local.system_job_count * chomp(enos_local_exec.get_nodes.stdout) + local.service_batch_allocs + chomp(enos_local_exec.get_allocs.stdout) | ||
} | ||
|
||
output "nodes" { | ||
description = "Number of current clients in the cluster" | ||
value = chomp(enos_local_exec.get_nodes.stdout) | ||
} | ||
|
||
output "new_allocs_count" { | ||
description = "The number of allocs that should be running in the cluster" | ||
value = local.system_job_count * chomp(enos_local_exec.get_nodes.stdout) + local.service_batch_allocs | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What's this output for? It doesn't match There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Im trying to make this module aware of existing allocs so it outputs all the running allocs, new and old, and the output can be directly used for a next step in enos, because it does not accept functions as step.variables, so this output helps me debug There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Makes sense! Let's update the descriptions to make that clear. Right now this is the same as |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should rebase this PR on #25172 once that's been merged.