mirror of
https://github.com/xcat2/xcat-core.git
synced 2026-10-07 10:06:39 +00:00
fix(provtest,dhcptest): refuse a second setup over a live fixture
Both fixtures record what they are about to change so teardown can put it back, and both truncated that record on entry. A setup run while one was already up therefore saved the fixture's own site table, dhcpd.conf and /etc/hosts as the originals, and the veth and namespace it no longer knew about survived the teardown that followed. Refuse when the state directory is there, naming the teardown to run.
This commit is contained in:
@@ -301,6 +301,10 @@ do_check() {
|
||||
}
|
||||
|
||||
do_setup() {
|
||||
# A second setup over a live fixture would save the fixture's own dhcpd.conf
|
||||
# and site table as the originals, so teardown would restore them instead of
|
||||
# what was there first. Refuse rather than leave the machine in that state.
|
||||
[ -d "$STATE" ] && die "a fixture is already up; run '$0 teardown' first"
|
||||
mkdir -p "$STATE" || die "cannot create $STATE"
|
||||
|
||||
# Recorded before it is changed, so teardown is exact rather than a guess.
|
||||
|
||||
@@ -463,6 +463,11 @@ define_node() {
|
||||
|
||||
do_setup() {
|
||||
local tmpl http dns tftp
|
||||
# A second setup over a live fixture would overwrite the record teardown
|
||||
# restores from -- the site table, /etc/hosts, the name server's
|
||||
# configuration -- and orphan the veth and the namespace it no longer knows
|
||||
# about. Refuse rather than leave the machine in that state.
|
||||
[ -d "$STATE" ] && die "a fixture is already up; run '$0 teardown' first"
|
||||
mkdir -p "$STATE" || die "cannot create $STATE"
|
||||
: > "$STATE/files"; : > "$STATE/dirs"
|
||||
: > "$STATE/nodes"; : > "$STATE/osimages"; : > "$STATE/services"
|
||||
|
||||
Reference in New Issue
Block a user