meta-quanta: gbs: Add retry to read-margin-temp-wait.sh

Add 3 x 1 second retries for WCTemp and default to a sane WCTemp if 0 is
read.

Signed-off-by: Brandon Kim <brandonkim@google.com>
Change-Id: Ia87e704d2e5e0990a0727cd37290084f8eda2df6
diff --git a/meta-quanta/meta-gbs/recipes-quanta/fans/read-margin-temp/read-margin-temp-wait.sh b/meta-quanta/meta-gbs/recipes-quanta/fans/read-margin-temp/read-margin-temp-wait.sh
index 992e40a..8dd4087 100644
--- a/meta-quanta/meta-gbs/recipes-quanta/fans/read-margin-temp/read-margin-temp-wait.sh
+++ b/meta-quanta/meta-gbs/recipes-quanta/fans/read-margin-temp/read-margin-temp-wait.sh
@@ -27,13 +27,28 @@
         Present | awk '{print $2}')"
 
     if [[ "$presentState" == "true" ]]; then
-        wcTemp="$(
-            busctl get-property xyz.openbmc_project.nvme.manager \
-                ${nvmePath}${i} \
-                xyz.openbmc_project.Sensor.Threshold.Critical \
-                CriticalHigh | awk '{print $2}'
-        )"
-        wcTemp="$((wcTemp * 1000))"
+        actualWCTemp=0
+        for ((j = 0; j < 3; j++)); do
+            actualWCTemp="$(
+                busctl get-property xyz.openbmc_project.nvme.manager \
+                    ${nvmePath}${i} \
+                    xyz.openbmc_project.Sensor.Threshold.Critical \
+                    CriticalHigh | awk '{print $2}'
+            )"
+            if [[ "${actualWCTemp}" -ne 0 ]]; then
+                break
+            fi
+
+            echo "${nvmePath}${i} WCTemp was read to be 0, retrying after 1 sec sleep"
+            sleep 1
+        done
+
+        if [[ "${actualWCTemp}" -eq 0 ]]; then
+            echo "${nvmePath}${i} WCTemp was read to be 0, setting to default WCTemp: ${wcTemp}"
+            actualWCTemp="${wcTemp}"
+        fi
+
+        wcTemp="$((actualWCTemp * 1000))"
         if [[ -z "$nvmeList" ]]; then
             nvmeList="\"nvme"${i}"\""
         else