From 4fc35dac87c96e4dd45052f8edde1fd602cee615 Mon Sep 17 00:00:00 2001
From: Adrian Pope <apope@anl.gov>
Date: Mon, 1 May 2023 16:36:32 -0500
Subject: [PATCH] updating based on changes to polaris queue rules

---
 polaris/polaris_nodes_build.sh       | 8 ++++++++
 polaris/polaris_nodes_debug.sh       | 5 ++++-
 polaris/polaris_nodes_demand.sh      | 3 ++-
 polaris/polaris_nodes_preemptable.sh | 8 ++++++++
 polaris/polaris_nodes_prod.sh        | 4 ++--
 5 files changed, 24 insertions(+), 4 deletions(-)
 create mode 100755 polaris/polaris_nodes_build.sh
 create mode 100755 polaris/polaris_nodes_preemptable.sh

diff --git a/polaris/polaris_nodes_build.sh b/polaris/polaris_nodes_build.sh
new file mode 100755
index 0000000..de153f5
--- /dev/null
+++ b/polaris/polaris_nodes_build.sh
@@ -0,0 +1,8 @@
+#! /bin/bash
+
+# goal: show state of build nodes excluded from prod queue
+# include: nodes marked as (build and demand)
+# exclude: nodes marked as debug
+# output: hostname, state
+
+pbsnodes -a -F json | jq -r '.nodes[] | select( (.resources_available.demand=="True" and .resources_available.build=="True") and .resources_available.debug!="True") | [.resources_available.host,.state] | @tsv'
diff --git a/polaris/polaris_nodes_debug.sh b/polaris/polaris_nodes_debug.sh
index 3b72553..905f91c 100755
--- a/polaris/polaris_nodes_debug.sh
+++ b/polaris/polaris_nodes_debug.sh
@@ -2,6 +2,9 @@
 
 # goal: show state of debug nodes excluded from prod queue
 # include: nodes marked as debug
+# exclude: nodes marked as build, demand
+# note: I think debug can run on any nodes other than build or demand, but
+# this script only show status for exclusively debug nodes, eg. debug=True
 # output: hostname, state
 
-pbsnodes -a -F json | jq -r '.nodes[] | select(.resources_available.debug=="True") | [.resources_available.host,.state] | @tsv'
+pbsnodes -a -F json | jq -r '.nodes[] | select(.resources_available.debug=="True" and .resources_available.build!="True" and .resources_available.demand!="True") | [.resources_available.host,.state] | @tsv'
diff --git a/polaris/polaris_nodes_demand.sh b/polaris/polaris_nodes_demand.sh
index 9dd3b30..0e560aa 100755
--- a/polaris/polaris_nodes_demand.sh
+++ b/polaris/polaris_nodes_demand.sh
@@ -2,6 +2,7 @@
 
 # goal: show state of demand nodes excluded from prod queue
 # include: nodes marked as demand
+# exclude: nodes marked as build
 # output: hostname, state
 
-pbsnodes -a -F json | jq -r '.nodes[] | select(.resources_available.demand=="True") | [.resources_available.host,.state] | @tsv'
+pbsnodes -a -F json | jq -r '.nodes[] | select(.resources_available.demand=="True" and .resources_available.build!="True") | [.resources_available.host,.state] | @tsv'
diff --git a/polaris/polaris_nodes_preemptable.sh b/polaris/polaris_nodes_preemptable.sh
new file mode 100755
index 0000000..c307c04
--- /dev/null
+++ b/polaris/polaris_nodes_preemptable.sh
@@ -0,0 +1,8 @@
+#! /bin/bash
+
+# goal: show state of preemptable nodes excluded from prod queue
+# include: nodes marked as demand
+# exclude: nodes marked as build, debug
+# output: hostname, state
+
+pbsnodes -a -F json | jq -r '.nodes[] | select(.resources_available.demand=="True" and .resources_available.build!="True" and .resources_available.debug!="True") | [.resources_available.host,.state] | @tsv'
diff --git a/polaris/polaris_nodes_prod.sh b/polaris/polaris_nodes_prod.sh
index 3360ff4..9532bae 100755
--- a/polaris/polaris_nodes_prod.sh
+++ b/polaris/polaris_nodes_prod.sh
@@ -3,8 +3,8 @@
 # goal: determine the max job size that could run in prod queue in near future
 # example: ./polaris_nodes_prod.sh | wc -l
 # include: nodes in "free" or "job-exclusive" state
-# exclude: nodes marked as "debug" or "demand"
+# exclude: nodes marked as debug, demand, build
 # output: hostname, state
 # issues: unsure how state relates to reservations on polaris
 
-pbsnodes -a -F json | jq -r '.nodes[] | select( (.state=="free" or .state=="job-exclusive") and .resources_available.debug!="True" and .resources_available.demand!="True") | [.resources_available.host,.state] | @tsv'
+pbsnodes -a -F json | jq -r '.nodes[] | select( (.state=="free" or .state=="job-exclusive") and .resources_available.debug!="True" and .resources_available.demand!="True" and .resources_available.build!="True") | [.resources_available.host,.state] | @tsv'
-- 
GitLab