forked from discoposse/nomad-vagrant-lab
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add reproducer to hashicorp/nomad#14850
- Loading branch information
Pavel Valodzka
committed
Oct 17, 2022
1 parent
41c677b
commit 749f4bf
Showing
3 changed files
with
86 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#!/usr/bin/ruby | ||
|
||
require 'open-uri' | ||
require 'net/http' | ||
require 'json' | ||
|
||
ORIGIN = 'http://localhost:4646/' | ||
|
||
def request(cmd) | ||
JSON.parse(URI.open("#{ORIGIN}v1/#{cmd}").read) | ||
end | ||
|
||
def detect!(allocs) | ||
out = [] | ||
index_collisions_cont = Hash.new{|hsh, key| | ||
hsh[key] = Hash.new{|h,k| h[k] = [] } | ||
} | ||
|
||
max_version = allocs.map{|j| j['JobVersion'] }.max | ||
allocs.each do |j| | ||
client_status = j['ClientStatus'] | ||
next if client_status == 'complete' | ||
id, version, name = j['ID'], j['JobVersion'], j['Name'] | ||
if client_status == 'running' | ||
index_collisions_cont[version][name] << id | ||
end | ||
end | ||
|
||
has_collisions = false | ||
index_collisions_cont.each do |ver, index_collisions| | ||
index_collisions.each do |name, ids| | ||
next if ids.size == 1 | ||
puts("Collision detected:" + " #{ver.to_s} #{name}: #{ids.join(', ')}") | ||
has_collisions = true | ||
end | ||
end | ||
|
||
exit 1 if has_collisions | ||
end | ||
|
||
id = 'fail' | ||
detect!(request("job/#{id}/allocations")) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/bin/bash -x | ||
|
||
# I don't know if it matters, but cluster with the issue runs with a spread scheduler. | ||
curl -XPUT localhost:4646/v1/operator/scheduler/configuration --data '{"SchedulerAlgorithm":"spread"}' | ||
|
||
for i in {1..500} | ||
do | ||
nomad job run -var redeploy=$i test.nomad | ||
ruby detect.rb || exit 1 | ||
sleep 5 | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters