Skip to content

Commit

Permalink
feat: make critical batch jobs fail more noisily (#2835)
Browse files Browse the repository at this point in the history
This commit adds an error handler to the wrapper script that runs the
batch job workload, so that if it fails unexpectedly due to being run
with `set -e`/`set -u` we stand a better chance of GCP's error reporting
alerting us to it, or at least having additional context in the logs
when investigating.

This is because until we get proper k8s job monitoring implemented,
we're solely dependent on error reporting alerting us to job failures.
  • Loading branch information
andrewpollock authored Nov 6, 2024
1 parent 641ab21 commit e3a7245
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
8 changes: 8 additions & 0 deletions vulnfeeds/cmd/combine-to-osv/run_combine_to_osv_convert.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@
## This script is intended to be the entrypoint of the docker image.
## with the working directory being the root of the repository

function __error_handing__() {
local last_status_code=$1;
local error_line_number=$2;
echo 1>&2 "Error - exited with status $last_status_code at line $error_line_number";
}

trap '__error_handing__ $? $LINENO' ERR

set -eu

INPUT_BUCKET="${INPUT_GCS_BUCKET:=cve-osv-conversion}"
Expand Down
8 changes: 8 additions & 0 deletions vulnfeeds/cmd/download-cves/mirror_nvd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@
# discontinued by the NVD.
# They are saved to GCS for use by combine-to-osv and the NVD to OSV conversion.

function __error_handing__() {
local last_status_code=$1;
local error_line_number=$2;
echo 1>&2 "Error - exited with status $last_status_code at line $error_line_number";
}

trap '__error_handing__ $? $LINENO' ERR

set -e

echo "Downloading the entire NVD"
Expand Down
8 changes: 8 additions & 0 deletions vulnfeeds/cmd/nvd-cve-osv/run_cve_to_osv_generation.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@
# specified.
# It assumes it is running in a Docker container

function __error_handing__() {
local last_status_code=$1;
local error_line_number=$2;
echo 1>&2 "Error - exited with status $last_status_code at line $error_line_number";
}

trap '__error_handing__ $? $LINENO' ERR

set -e
set -u

Expand Down

0 comments on commit e3a7245

Please sign in to comment.