From 2f807e346a051fe7a76986e19629cff3c9af8bb3 Mon Sep 17 00:00:00 2001 From: Paul Sarando Date: Thu, 30 May 2024 20:14:32 -0700 Subject: [PATCH] CORE-1997 Replace /callbacks/agave-job with /callbacks/tapis-job --- project.clj | 4 ++-- src/apps/routes/callbacks.clj | 13 ++++++------- src/apps/service/apps/tapis/jobs.clj | 3 +-- src/apps/service/callbacks.clj | 13 ++++++++----- 4 files changed, 17 insertions(+), 16 deletions(-) diff --git a/project.clj b/project.clj index fcd77d07..d7bf7299 100644 --- a/project.clj +++ b/project.clj @@ -26,12 +26,12 @@ [org.cyverse/authy "3.0.0-SNAPSHOT"] [org.cyverse/clojure-commons "3.0.7"] [org.cyverse/debug-utils "2.8.1"] - [org.cyverse/kameleon "3.0.6"] + [org.cyverse/kameleon "3.0.9-SNAPSHOT"] [org.cyverse/mescal "4.0.0-SNAPSHOT"] [org.cyverse/metadata-client "3.1.1"] [org.cyverse/common-cli "2.8.1"] [org.cyverse/common-cfg "2.8.2"] - [org.cyverse/common-swagger-api "3.4.4"] + [org.cyverse/common-swagger-api "3.4.5-SNAPSHOT"] [org.cyverse/cyverse-groups-client "0.1.8"] [org.cyverse/otel "0.2.5"] [org.cyverse/permissions-client "2.8.3"] diff --git a/src/apps/routes/callbacks.clj b/src/apps/routes/callbacks.clj index a119165b..8dc7f21a 100644 --- a/src/apps/routes/callbacks.clj +++ b/src/apps/routes/callbacks.clj @@ -2,7 +2,7 @@ (:use [apps.routes.schemas.callback] [common-swagger-api.schema] [common-swagger-api.schema.analyses :only [AnalysisIdPathParam]] - [common-swagger-api.schema.callbacks :only [AgaveJobStatusUpdateParams AgaveJobStatusUpdate]] + [common-swagger-api.schema.callbacks :only [TapisJobStatusUpdate]] [ring.util.http-response :only [ok]]) (:require [apps.service.callbacks :as callbacks])) @@ -13,10 +13,9 @@ :description "The jex-events service calls this endpoint when the status of a DE analysis changes" (ok (callbacks/update-de-job-status body))) - (POST "/agave-job/:job-id" [] + (POST "/tapis-job/:job-id" [] :path-params [job-id :- AnalysisIdPathParam] - :body [body (describe AgaveJobStatusUpdate "The updated job status information.")] - :query [params AgaveJobStatusUpdateParams] - :summary "Update the status of an Agave analysis." - :description "The DE registers this endpoint as a callback when it submts jobs to Agave." - (ok (callbacks/update-tapis-job-status job-id (:lastUpdated body) params)))) + :body [body (describe TapisJobStatusUpdate "The updated job status information.")] + :summary "Update the status of an Tapis analysis." + :description "The DE registers this endpoint as a callback when it submts jobs to Tapis." + (ok (callbacks/update-tapis-job-status job-id body)))) diff --git a/src/apps/service/apps/tapis/jobs.clj b/src/apps/service/apps/tapis/jobs.clj index 5c2999af..dd66ba12 100644 --- a/src/apps/service/apps/tapis/jobs.clj +++ b/src/apps/service/apps/tapis/jobs.clj @@ -16,8 +16,7 @@ (defn- build-callback-url [id] - (str (assoc (curl/url (config/tapis-callback-base) (str id)) - :query "status=${JOB_STATUS}&external-id=${JOB_ID}&end-time=${JOB_END_TIME}"))) + (str (curl/url (config/tapis-callback-base) (str id)))) (defn- format-submission [_ job-id result-folder-path {:keys [config] :as submission}] diff --git a/src/apps/service/callbacks.clj b/src/apps/service/callbacks.clj index a38c2948..9a8e06ca 100644 --- a/src/apps/service/callbacks.clj +++ b/src/apps/service/callbacks.clj @@ -12,9 +12,12 @@ (apps/update-job-status uuid)) (defn update-tapis-job-status - [job-id last-updated {:keys [status external-id end-time]}] + [job-id {{:keys [timestamp type data]} :event}] (service/assert-valid job-id "no job UUID provided") - (service/assert-valid status "no status provided") - (service/assert-valid external-id "no external job ID provided") - (log/info (str "received a status update for Tapis job " external-id ": status = " status)) - (apps/update-job-status job-id external-id status (first (remove string/blank? [end-time last-updated])))) + (service/assert-valid type "no status provided") + (let [{:keys [jobUuid]} (service/parse-json data) + ; The `event.type` will be a string like "jobs.JOB_NEW_STATUS.FINISHED" + status (string/replace type #".*\." "")] + (service/assert-valid jobUuid "no external job ID provided") + (log/info (str "received a status update for Tapis job " jobUuid ": type = " type ", status = " status)) + (apps/update-job-status job-id jobUuid status timestamp)))