mirror of
https://github.com/xcat2/xcat-core.git
synced 2026-11-19 08:52:15 +00:00
6dfcdcbc48
A diskless openEuler 22.03sp4 node netbooted, took a lease, reached a login prompt and answered ping, and then every xdsh and ssh answered "root@xcat59-cn: Permission denied (publickey)" while the node never reported "booted". reg_linux_diskless_installation_flat failed after 7072 s. xcatd on that management node logged "xCAT: Allowing getpostscript xcat59-cn" with no "from <peerhost>", then "Received malformed getpostscript requesting, ignore it." -- 100 times, with 0 "Sending scripts data" in the whole log. The green openEuler 24.03sp4 cell beside it logged 3 sends and 0 malformed. The client certificate named the node correctly; only the reverse lookup of the peer socket failed. getpostscript read _xcat_clienthost and nothing else, so it dropped every request. No postscript ran: remoteshell never installed root's authorized_keys, which is the ssh failure, and nothing updated node status, which is the stuck "powering-on". One cause, both symptoms. process_request now tries each name xCAT::DiscoveryUtils::request_client_names offers and takes the first that correlates to a node. A request that offers no name at all, and one whose names correlate to nothing, are now reported as what they are; the old message said the request was malformed, which sent two investigations into DNS and the netboot image. Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
120 lines
4.0 KiB
Perl
120 lines
4.0 KiB
Perl
# IBM(c) 2007 EPL license http://www.eclipse.org/legal/epl-v10.html
|
|
#-------------------------------------------------------
|
|
|
|
=head1
|
|
xCAT plugin package to handle getpostscript command
|
|
|
|
=cut
|
|
|
|
#-------------------------------------------------------
|
|
package xCAT_plugin::getpostscript;
|
|
use xCAT::Utils;
|
|
use xCAT::MsgUtils;
|
|
use xCAT::NodeRange;
|
|
use xCAT::DiscoveryUtils;
|
|
1;
|
|
|
|
#-------------------------------------------------------
|
|
|
|
=head3 handled_commands
|
|
|
|
Return list of commands handled by this plugin
|
|
|
|
=cut
|
|
|
|
#-------------------------------------------------------
|
|
|
|
sub handled_commands
|
|
{
|
|
return {
|
|
'getpostscript' => "getpostscript",
|
|
};
|
|
}
|
|
|
|
|
|
#-------------------------------------------------------
|
|
|
|
=head3 process_request
|
|
|
|
Process the command
|
|
|
|
=cut
|
|
|
|
#-------------------------------------------------------
|
|
sub process_request
|
|
{
|
|
my $request = shift;
|
|
my $callback = shift;
|
|
my $nodes = $request->{node};
|
|
my $command = $request->{command}->[0];
|
|
my $args = $request->{arg};
|
|
my $envs = $request->{env};
|
|
my $rsp;
|
|
my $i = 1;
|
|
my @nodes = @$nodes;
|
|
|
|
# do your processing here
|
|
# return info
|
|
|
|
|
|
my $client;
|
|
my @candidates;
|
|
if ($::XCATSITEVALS{nodeauthentication}) { #if requiring node authentication, this request will have a certificate associated with it, use it instead of name resolution
|
|
unless (ref $request->{username}) { return; } #TODO: log an attempt without credentials?
|
|
@candidates = ($request->{username}->[0]);
|
|
} else {
|
|
# The peer host and fqdn are a reverse lookup of the client socket, so both are empty when
|
|
# that lookup fails, however good the client credentials are. Asking only for the peer host
|
|
# cost every postscript of an openEuler 22.03sp4 node on 2026-10-24: the certificate named
|
|
# the node, the reverse lookup did not, and 100 requests were dropped while 0 were served.
|
|
# request_client_names adds the certificate name, and excludes the request's own node
|
|
# attribute, which the client sends and has not proved.
|
|
@candidates = xCAT::DiscoveryUtils::request_client_names($request);
|
|
unless (@candidates) {
|
|
xCAT::MsgUtils->trace(0, 'E', "Received getpostscript from a client this request does not identify: it carries no peer name and no client certificate name. Ignoring it.");
|
|
return;
|
|
}
|
|
}
|
|
|
|
foreach my $candidate (@candidates) {
|
|
next unless defined $candidate && $candidate ne '';
|
|
my ($node) = noderange($candidate);
|
|
if ($node) { $client = $node; last; }
|
|
}
|
|
unless ($client) { #Not able to do identify the host in question
|
|
xCAT::MsgUtils->trace(0, "E", "Received getpostscript from " . join(', ', @candidates) . ", none of which could be correlated to a node (domain mismatch?)");
|
|
return;
|
|
}
|
|
my $state;
|
|
if ($request->{scripttype}) { $state = $request->{scripttype}->[0]; }
|
|
|
|
require xCAT::Postage;
|
|
my $args = $request->{arg};
|
|
my @scriptcontents;
|
|
my $version = 0;
|
|
if (defined($args) && grep(/version2/, @$args)) {
|
|
$version = 2
|
|
}
|
|
my $notmpfiles;
|
|
my $nofiles;
|
|
|
|
# If not version=2, then we return the mypostscript file in an array.
|
|
if ($version != 2) {
|
|
$notmpfiles = 1; # no tmp files and no files
|
|
$nofiles = 1; # do not create /tftpboot/mypostscript/mypostscript.<nodename>
|
|
@scriptcontents = xCAT::Postage::makescript([$client], $state, $callback, $notmpfiles, $nofiles);
|
|
xCAT::MsgUtils->trace(0, "I", "getpostscript: Sending scripts data to $client...");
|
|
$rsp->{data} = \@scriptcontents;
|
|
$callback->($rsp);
|
|
} else { # version 2, make files, do not return array
|
|
# make the mypostscript.<nodename> file
|
|
# or the mypostscript.<nodename>.tmp file if precreatemypostscripts=0
|
|
# xcatdsklspost will wget the file
|
|
$notmpfiles = 0;
|
|
$nofiles = 0;
|
|
xCAT::Postage::makescript([$client], $state, $callback, $notmpfiles, $nofiles);
|
|
}
|
|
return 0;
|
|
}
|
|
|