@@ -260,25 +260,42 @@ jobs:
260260 # -------------------------------------------------------
261261 - name : Check Postgres
262262 run : |
263+ # Detect major Splunk version from matrix
264+ SPLUNK_VERSION="${{ matrix.splunk_version }}"
265+ MAJOR_VERSION=$(echo "$SPLUNK_VERSION" | cut -d'.' -f1)
266+
267+ # If version is not numeric (e.g., "latest"), treat as latest/highest version
268+ if ! [[ "$MAJOR_VERSION" =~ ^[0-9]+$ ]]; then
269+ echo "Non-numeric version detected: ${SPLUNK_VERSION} — treating as latest (99)"
270+ MAJOR_VERSION=99
271+ fi
272+
273+ echo "Splunk version: ${SPLUNK_VERSION} (major: ${MAJOR_VERSION})"
274+
263275 if [ "${IS_UF}" = "1" ]; then
264276 echo "UF : disabling postsgres check"
265277 exit 0
278+ elif [ "$MAJOR_VERSION" -le 10 ]; then
279+ echo "Splunk Enterprise less than 10, no PG"
280+ exit 0
266281 else
267282 # Check if Postgres process is running inside container
268283 echo ""
269284 echo "--- Checking for Splunk Postgres process ---"
285+ # if Splunk 10.0 process is named postgres
286+ # for splunk 10.2 and newer, process name is splunk-postgres
270287 docker exec --user ${SPLUNK_USER} splunk bash -c \
271- "ps aux 2>/dev/null | grep -i [p]ostgres || echo 'No Postgres process found'" || true
288+ "ps aux 2>/dev/null | grep -i [p]ostgres grep -v grep || echo '❌ Error : No Postgres process found'" || true
272289
273- # Step 6d: Check if .pgpass file exists (indicates Postgres credentials are configured)
290+ # Check if .pgpass file exists (indicates Postgres credentials are configured)
274291 echo ""
275292 echo "--- Checking for Postgres credentials file ---"
276293 if docker exec --user ${SPLUNK_USER} splunk test -f ${SPLUNK_HOME}/var/packages/data/postgres/.pgpass 2>/dev/null; then
277294 PGPASS_FILE="${SPLUNK_HOME}/var/packages/data/postgres/.pgpass"
278295 echo "Found .pgpass in packages/data/postgres directory"
279296 else
280- echo "No .pgpass file found (this may be normal depending on Splunk version) "
281- exit 0
297+ echo "❌ ERROR No .pgpass file found"
298+ exit 1
282299 fi
283300
284301 # Step 6e: Attempt to verify Postgres connectivity (if psql is available)
@@ -294,19 +311,18 @@ jobs:
294311 -c '\l' 2>&1" || echo "CONNECTION_FAILED")
295312
296313 if echo "${PG_RESULT}" | grep -q "CONNECTION_FAILED\|could not connect\|FATAL"; then
297- echo "⚠️ WARNING : Could not connect to Postgres directly."
314+ echo "❌ ERROR : Could not connect to Postgres directly."
298315 echo "Output: ${PG_RESULT}"
299- echo "This may be normal if Postgres uses a different socket or port."
300- exit 0
316+ exit 1
301317 else
302318 echo "Postgres databases:"
303319 echo "${PG_RESULT}"
304320 echo ""
305321 echo "✅ Postgres connectivity verified"
306- # FIXME : List table in the database
307322 fi
308323 else
309- echo "psql binary not found at ${SPLUNK_HOME}/bin/psql — skipping direct connectivity test"
324+ echo "❌ ERROR: psql binary not found at ${SPLUNK_HOME}/bin/psql — skipping direct connectivity test"
325+ exit 1
310326 fi
311327
312328 fi
0 commit comments