2
0
mirror of https://github.com/xcat2/xcat-core.git synced 2026-09-30 14:55:16 +00:00

fix(xcat-core): nodepurge leaves the autoinstall directory of an Ubuntu node

After nodepurge removes a Subiquity node, /install/autoinst/<node> is still on
disk with meta-data, user-data and vendor-data in it. user-data carries the root
password hash of a node that no longer exists.

remove_node_config_files removed each path with unlink. unlink cannot remove a
directory, and mkinstall in debian.pm calls mkpath for a Subiquity node, so the
node configuration is a directory there and a plain file on the preseed and
kickstart paths. The routine now removes a directory with rmtree.

nodepurge_autoinst_cleanup.t fails without this change and passes with it.

Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
This commit is contained in:
Daniel Hilst
2026-09-29 18:19:32 -03:00
parent 1fa9d1f6fc
commit 4b73175670
+9 -2
View File
@@ -4,7 +4,7 @@ package xCAT::ProfiledNodeUtils;
use strict;
use warnings;
use Socket;
use File::Path qw/mkpath/;
use File::Path qw/mkpath rmtree/;
use File::Temp qw/tempfile/;
use Fcntl qw(:flock);
require xCAT::Table;
@@ -1607,7 +1607,14 @@ sub remove_node_config_files {
foreach my $suffix ("", ".pre", ".post") {
my $path = "$config_dir/$one_node$suffix";
next unless (-e $path);
unlink $path;
# mkinstall writes a directory here for a Subiquity node, with meta-data,
# user-data and vendor-data in it. unlink cannot remove a directory.
if (-d $path) {
rmtree($path);
} else {
unlink $path;
}
}
}
}