From fa74bae115dd7db73501bf75b5a72850921873b3 Mon Sep 17 00:00:00 2001
From: Morris Jette <jette@schedmd.com>
Date: Thu, 13 Apr 2017 14:18:14 -0600
Subject: [PATCH] Sanity check in perl api to make sure we get a new structure
 back from the perl api.

---
 contribs/torque/pbsnodes.pl | 4 +++-
 contribs/torque/qalter.pl   | 3 +++
 contribs/torque/qsub.pl     | 3 +++
 3 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/contribs/torque/pbsnodes.pl b/contribs/torque/pbsnodes.pl
index 7336e636b9c..8993229feb5 100755
--- a/contribs/torque/pbsnodes.pl
+++ b/contribs/torque/pbsnodes.pl
@@ -91,7 +91,9 @@ Main:
     # Use sole remaining argument as nodeIds
     my @nodeIds = @ARGV;
     my $slurm = Slurm::new();
-
+    if (!$slurm) {
+        die "Problem loading slurm.\n";
+    }
 
     # handle all of the node update operations
     if ( defined $clear || defined $offline || defined $reset ) {
diff --git a/contribs/torque/qalter.pl b/contribs/torque/qalter.pl
index d8c9fbed5f3..d0af2b3a447 100755
--- a/contribs/torque/qalter.pl
+++ b/contribs/torque/qalter.pl
@@ -73,6 +73,9 @@ if (@ARGV < 1) {
 	pod2usage(-message=>"Missing Job ID", -verbose=>0);
 } else {
 	$slurm = Slurm::new();
+	if (!$slurm) {
+		die "Problem loading slurm.\n";
+	}
 	$resp = $slurm->get_end_time($job_id);
 	if (not defined($resp)) {
 		pod2usage(-message=>"Job id $job_id not valid!", -verbose=>0);
diff --git a/contribs/torque/qsub.pl b/contribs/torque/qsub.pl
index 2c9b773c807..cb82d33ec64 100755
--- a/contribs/torque/qsub.pl
+++ b/contribs/torque/qsub.pl
@@ -418,6 +418,9 @@ if ($interactive) {
 	# If block is true wait for the job to finish
 	my($resp, $count);
 	my $slurm = Slurm::new();
+	if (!$slurm) {
+		die "Problem loading slurm.\n";
+	}
 	if ( (lc($block) eq "true" ) and ($command_exit_status == 0) ) {
 		sleep 2;
 		my($job) = $slurm->load_job($job_id);
-- 
GitLab