Skip to content

Commit

Permalink
Merge pull request #67 from slr71/main
Browse files Browse the repository at this point in the history
CORE-2006: dependency updates.
  • Loading branch information
slr71 authored Aug 7, 2024
2 parents 12d7a10 + cc29658 commit 32de036
Show file tree
Hide file tree
Showing 39 changed files with 425 additions and 598 deletions.
1 change: 0 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/pom.xml
*jar
!opentelemetry-javaagent.jar
/bin
/lib
/classes
Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/pom.xml
*jar
!opentelemetry-javaagent.jar
/bin
/lib
/classes
Expand Down
14 changes: 7 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
FROM clojure:openjdk-17-lein-alpine
FROM clojure:temurin-22-lein-jammy

WORKDIR /usr/src/app

RUN apk add --no-cache git
RUN apt-get update && \
apt-get install -y git && \
rm -rf /var/lib/apt/lists/*

RUN ln -s "/opt/openjdk-17/bin/java" "/bin/data-info"

ENV OTEL_TRACES_EXPORTER none
RUN ln -s "/opt/java/openjdk/bin/java" "/bin/data-info"

COPY project.clj /usr/src/app/
RUN lein deps

COPY conf/main/logback.xml /usr/src/app/
COPY . /usr/src/app

RUN lein uberjar && \
RUN lein do clean, uberjar && \
cp target/data-info-standalone.jar .

ENTRYPOINT ["data-info", "-Dlogback.configurationFile=/etc/iplant/de/logging/data-info-logging.xml", "-javaagent:/usr/src/app/opentelemetry-javaagent.jar", "-Dotel.resource.attributes=service.name=data-info", "-cp", ".:data-info-standalone.jar", "data_info.core"]
ENTRYPOINT ["data-info", "-Dlogback.configurationFile=/etc/iplant/de/logging/data-info-logging.xml", "-cp", ".:data-info-standalone.jar", "data_info.core"]
CMD ["--help"]

ARG git_commit=unknown
Expand Down
File renamed without changes.
Binary file removed opentelemetry-javaagent.jar
Binary file not shown.
61 changes: 29 additions & 32 deletions project.clj
Original file line number Diff line number Diff line change
Expand Up @@ -14,57 +14,54 @@
:url "http://iplantcollaborative.org/sites/default/files/iPLANT-LICENSE.txt"}
:manifest {"Git-Ref" ~(git-ref)}
:uberjar-name "data-info-standalone.jar"
:dependencies [[org.clojure/clojure "1.11.1"]
[cheshire "5.12.0"
:dependencies [[org.clojure/clojure "1.11.3"]
[cheshire "5.13.0"
:exclusions [[com.fasterxml.jackson.dataformat/jackson-dataformat-cbor]
[com.fasterxml.jackson.dataformat/jackson-dataformat-smile]
[com.fasterxml.jackson.core/jackson-annotations]
[com.fasterxml.jackson.core/jackson-databind]
[com.fasterxml.jackson.core/jackson-core]]]
[com.cemerick/url "0.1.1" :exclusions [com.cemerick/clojurescript.test]]
[dire "0.5.4"]
[org.cyverse/dire "0.5.5-SNAPSHOT"]
[me.raynes/fs "1.4.6"]
[org.apache.tika/tika-core "2.9.1"]
[org.apache.tika/tika-core "2.9.2" :exclusions [org.slf4j/slf4j-api]]
[net.sf.opencsv/opencsv "2.3"]
[de.ubercode.clostache/clostache "1.4.0" :exclusions [org.clojure/core.incubator]]
[org.cyverse/clj-irods "0.3.5"]
[org.cyverse/clj-icat-direct "2.9.5"
:exclusions [[org.slf4j/slf4j-log4j12]
[org.cyverse/clj-irods "0.3.6"]
[org.cyverse/clj-icat-direct "2.9.6"
:exclusions [[org.slf4j/slf4j-api]
[org.slf4j/slf4j-log4j12]
[log4j]]]
[org.cyverse/clj-jargon "3.1.0"
:exclusions [[org.slf4j/slf4j-log4j12]
[org.cyverse/clj-jargon "3.1.1"
:exclusions [[org.slf4j/slf4j-api]
[org.slf4j/slf4j-log4j12]
[log4j]]]
[javax.servlet/servlet-api "2.5"]
[metosin/compojure-api "1.1.13"]
[ring/ring-jetty-adapter "1.11.0"] ;; update this when underlying ring version changes, probably
[org.slf4j/slf4j-api "1.7.31"]
[org.cyverse/otel "0.2.5"]
[org.cyverse/clojure-commons "3.0.7"]
[org.cyverse/common-cli "2.8.1"]
[org.cyverse/common-cfg "2.8.2"]
[org.cyverse/common-swagger-api "3.4.4"]
[org.cyverse/heuristomancer "2.8.6"]
[org.cyverse/kameleon "3.0.8"]
[org.cyverse/metadata-client "3.1.1"]
[org.cyverse/async-tasks-client "0.0.4"]
[org.cyverse/metadata-files "2.1.0"]
[org.cyverse/oai-ore "1.0.3"]
[org.cyverse/service-logging "2.8.3"]
[org.cyverse/event-messages "0.0.1"]
[com.novemberain/langohr "3.5.1"]
[metosin/compojure-api "1.1.14"]
[ring/ring-jetty-adapter "1.12.2" :exclusions [org.slf4j/slf4j-api]]
[org.cyverse/clojure-commons "3.0.9-SNAPSHOT"]
[org.cyverse/common-cli "2.8.2"]
[org.cyverse/common-cfg "2.8.3"]
[org.cyverse/common-swagger-api "3.4.5"]
[org.cyverse/heuristomancer "2.8.7"]
[org.cyverse/kameleon "3.0.10"]
[org.cyverse/metadata-client "3.1.2"]
[org.cyverse/async-tasks-client "0.0.5"]
[org.cyverse/metadata-files "2.1.1"]
[org.cyverse/oai-ore "1.0.4"]
[org.cyverse/service-logging "2.8.4"]
[com.novemberain/langohr "5.4.0"]
[slingshot "0.12.2"]]
:eastwood {:exclude-namespaces [data-info.routes.schemas.tickets
data-info.routes.schemas.stats
data-info.routes.schemas.sharing
data-info.routes.schemas.trash
:test-paths]
:linters [:wrong-arity :wrong-ns-form :wrong-pre-post :wrong-tag :misplaced-docstrings]}
:plugins [[jonase/eastwood "1.4.2"]
:plugins [[jonase/eastwood "1.4.3"]
[lein-ancient "0.7.0"]
[test2junit "1.1.3"]]
[test2junit "1.4.4"]]
:profiles {:dev {:plugins [[lein-ring "0.12.5"]]
:resource-paths ["conf/test"]
:jvm-opts ["-Dotel.javaagent.enabled=false"]}
:resource-paths ["conf/test"]}
:repl {:source-paths ["repl"]}
:uberjar {:aot :all}}
:main ^:skip-aot data-info.core
Expand All @@ -73,4 +70,4 @@
:port 31360
:auto-reload? false}
:uberjar-exclusions [#".*[.]SF" #"LICENSE" #"NOTICE"]
:jvm-opts ["-Dlogback.configurationFile=/etc/iplant/de/logging/data-info-logging.xml" "-javaagent:./opentelemetry-javaagent.jar" "-Dotel.resource.attributes=service.name=data-info"])
:jvm-opts ["-Dlogback.configurationFile=/etc/iplant/de/logging/data-info-logging.xml"])
8 changes: 0 additions & 8 deletions src/data_info/amqp.clj
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,6 @@
(handler channel metadata msg)
(log/error (format "[amqp/message-router] [%s] [%s] unroutable" routing-key (String. msg))))))

(defn connect
[exchange-cfg queue-cfg handlers]
(let [channel (lch/open (rmq/connect {:uri (config/amqp-uri)}))]
(log/info (format "[amqp/connect] [%s]" (config/amqp-uri)))
(declare-exchange channel exchange-cfg)
(declare-queue channel exchange-cfg queue-cfg (keys handlers))
(lc/blocking-subscribe channel (:name queue-cfg) (partial message-router handlers))))

(defn publish-msg
[routing-key msg]
(try+
Expand Down
100 changes: 49 additions & 51 deletions src/data_info/clients/async_tasks.clj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
[clojure.string :as string]
[clj-irods.core :refer [make-threadpool]]
[clj-irods.cache-tools :as c]
[otel.otel :as otel]
[async-tasks-client.core :as async-tasks-client]))

;; https://stackoverflow.com/questions/12068640/retrying-something-3-times-before-throwing-an-exception-in-clojure
Expand All @@ -27,16 +26,14 @@

(defn- retry-via-threadpool
[pool retries handler f & args]
(let [ag (agent nil)
s (otel/current-span)]
(send-via pool ag (fn [_nil] (c/otel-with-subspan [s]
(try+
(apply retry-with-handler retries handler f args)
(catch Object o
{::error o})))))
(let [ag (agent nil)]
(send-via pool ag (fn [_nil] (try+
(apply retry-with-handler retries handler f args)
(catch Object o
{::error o}))))
(delay (if-let [err (::error @ag)]
(throw+ err)
@ag))))
(throw+ err)
@ag))))

(defn get-by-id
[id]
Expand Down Expand Up @@ -68,49 +65,50 @@

(defn run-async-thread
[async-task-id thread-function prefix]
(otel/with-span [outer-span ["run-async-thread" {:kind :producer :attributes {"async-task-id" (str async-task-id)}}]]
(let [^Runnable task-thread (fn []
(with-open [_ (otel/span-scope outer-span)]
(otel/with-span [s ["async thread" {:kind :consumer :attributes {"async-task-id" (str async-task-id)}}]]
(thread-function async-task-id))))]
(.start (Thread. task-thread (str prefix "-" (string/replace async-task-id #".*/tasks/" "")))))
async-task-id))
(let [^Runnable task-thread (fn [] (thread-function async-task-id))]
(.start (Thread. task-thread (str prefix "-" (string/replace async-task-id #".*/tasks/" "")))))
async-task-id)

(defn create-update-fn [async-task-id pool]
(fn [path action]
(log/info "Updating async task:" async-task-id ":" path action)
;; we use the thread pool version here to be non-blocking, but elsewhere we use it so things happen in order (but
;; deref the result to wait for the result before continuing)
(retry-via-threadpool
pool 3
(fn [e t] (log/error (:throwable t) "failed updating async task"))
add-status async-task-id {:status "running"
:detail (format "[%s] %s: %s" (config/service-identifier) path (name action))})))

(defn paths-async-thread
([async-task-id jargon-fn end-fn]
(paths-async-thread async-task-id jargon-fn end-fn true))
([async-task-id jargon-fn end-fn use-client-user?]
(otel/with-span [s ["paths-async-thread" {:attributes {"async-task-id" (str async-task-id)}}]]
(let [pool (make-threadpool (str async-task-id "-async-tasks-update") 1)
{:keys [username] :as async-task} (get-by-id async-task-id)
update-fn (fn [path action]
(otel/with-span [s ["update-fn"]]
(log/info "Updating async task:" async-task-id ":" path action)
;; we use the thread pool version here to be non-blocking, but elsewhere we use it so things happen in order (but deref the result to wait for the result before continuing)
(retry-via-threadpool pool 3
(fn [e t] (log/error (:throwable t) "failed updating async task"))
add-status async-task-id {:status "running" :detail (format "[%s] %s: %s" (config/service-identifier) path (name action))})))]
(try+
(deref (retry-via-threadpool pool 3
(fn [e t] (log/error (:throwable t) "failed updating async task with started status"))
add-status async-task-id {:status "started"}))
(if use-client-user?
(irods/with-jargon-exceptions :client-user username [cm]
(otel/with-span [s ["jargon-fn" {:attributes {"client-user" username}}]]
(jargon-fn cm async-task update-fn)))
(irods/with-jargon-exceptions [cm]
(otel/with-span [s ["jargon-fn"]]
(jargon-fn cm async-task update-fn))))
;; For the completed statuses we want a lot of retries because the presence or absence of an end date controls locking behavior
(deref (retry-via-threadpool pool 100
(fn [e t] (log/error (:throwable t) "failed updating async task with completed status"))
add-completed-status async-task-id {:status "completed" :detail (str "[" (config/service-identifier) "]")}))
(otel/with-span [s ["end-fn"]]
(end-fn async-task false))
(catch Object _
(log/error (:throwable &throw-context) "failed processing async task" async-task-id)
(deref (retry-via-threadpool pool 100
(fn [e t] (log/error (:throwable t) "failed updating async task with completed status"))
add-completed-status async-task-id {:status "failed" :detail (format "[%s] %s" (config/service-identifier) (pr-str (:throwable &throw-context)))}))
(end-fn async-task true))))
(log/info "Finished processing async task " async-task-id))))
(let [pool (make-threadpool (str async-task-id "-async-tasks-update") 1)
{:keys [username] :as async-task} (get-by-id async-task-id)
update-fn (create-update-fn async-task-id pool)]
(try+
(deref (retry-via-threadpool pool 3
(fn [e t] (log/error (:throwable t) "failed updating async task with started status"))
add-status async-task-id {:status "started"}))
(if use-client-user?
(irods/with-jargon-exceptions :client-user username [cm]
(jargon-fn cm async-task update-fn))
(irods/with-jargon-exceptions [cm] (jargon-fn cm async-task update-fn)))
;; For the completed statuses we want a lot of retries because the presence or absence of an end date controls
;; locking behavior
(deref (retry-via-threadpool
pool 100
(fn [e t] (log/error (:throwable t) "failed updating async task with completed status"))
add-completed-status async-task-id {:status "completed" :detail (str "[" (config/service-identifier) "]")}))
(end-fn async-task false)
(catch Object _
(log/error (:throwable &throw-context) "failed processing async task" async-task-id)
(deref (retry-via-threadpool
pool 100
(fn [e t] (log/error (:throwable t) "failed updating async task with completed status"))
add-completed-status async-task-id
{:status "failed"
:detail (format "[%s] %s" (config/service-identifier) (pr-str (:throwable &throw-context)))}))
(end-fn async-task true))))
(log/info "Finished processing async task " async-task-id)))
9 changes: 0 additions & 9 deletions src/data_info/core.clj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
[data-info.routes :as routes]
[data-info.util.config :as config]
[data-info.amqp :as amqp]
[data-info.events :as events]
[me.raynes.fs :as fs]
[common-cli.core :as ccli]
[service-logging.thread-context :as tc]
Expand Down Expand Up @@ -69,13 +68,6 @@
(icat/configure-icat))


(defn listen-for-events
[]
(let [exchange-cfg (events/exchange-config)
queue-cfg (events/queue-config)]
(amqp/connect exchange-cfg queue-cfg {"events.data-info.ping" events/ping-handler})))


(defn- cli-options
[]
[["-c" "--config PATH" "Path to the config file"
Expand All @@ -101,5 +93,4 @@
(ccli/exit 1 "The config file is not readable."))
(load-configuration-from-file (:config options))
(icat/configure-icat)
(.start (Thread. listen-for-events))
(run-jetty))))
29 changes: 0 additions & 29 deletions src/data_info/events.clj

This file was deleted.

46 changes: 23 additions & 23 deletions src/data_info/routes.clj
Original file line number Diff line number Diff line change
Expand Up @@ -29,29 +29,29 @@

(defapi app
(swagger-routes
{:ui config/docs-uri
:options {:ui {:supported-submit-methods ["get", "post", "put", "delete", "patch", "head"]
:validator-url nil}}
:data {:info {:title "Discovery Environment Data Info API"
:description "Documentation for the Discovery Environment Data Info REST API"
:version "2.8.0"}
:tags [{:name "service-info", :description "Service Information"}
{:name "data-by-id", :description "Data Operations (by ID)"}
{:name "data", :description "Data Operations"}
{:name "tickets", :description "Ticket Operations"}
{:name "bulk", :description "Bulk Operations"}
{:name "navigation", :description "Navigation"}
{:name "users", :description "User Operations"}
{:name "filetypes", :description "File Type Metadata"}
{:name "groups", :description "Group Operations"}]}})
(middleware
[add-user-to-context
wrap-query-params
wrap-lcase-params
params/wrap-keyword-params
[wrap-exceptions cx/exception-handlers]
util/req-logger
log-validation-errors]
{:ui config/docs-uri
:options {:ui {:supported-submit-methods ["get", "post", "put", "delete", "patch", "head"]
:validator-url nil}}
:data {:info {:title "Discovery Environment Data Info API"
:description "Documentation for the Discovery Environment Data Info REST API"
:version "2.8.0"}
:tags [{:name "service-info", :description "Service Information"}
{:name "data-by-id", :description "Data Operations (by ID)"}
{:name "data", :description "Data Operations"}
{:name "tickets", :description "Ticket Operations"}
{:name "bulk", :description "Bulk Operations"}
{:name "navigation", :description "Navigation"}
{:name "users", :description "User Operations"}
{:name "filetypes", :description "File Type Metadata"}
{:name "groups", :description "Group Operations"}]}})
(context "/" []
:middleware [add-user-to-context
wrap-query-params
wrap-lcase-params
params/wrap-keyword-params
[wrap-exceptions cx/exception-handlers]
util/req-logger
log-validation-errors]
status-routes/status
data-routes/data-operations
rename-routes/rename-routes
Expand Down
Loading

0 comments on commit 32de036

Please sign in to comment.