Skip to content

Commit

Permalink
stream to artifact-store works now
Browse files Browse the repository at this point in the history
  • Loading branch information
TimoKramer committed Mar 2, 2020
1 parent 509cbc9 commit f7eb578
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 19 deletions.
24 changes: 10 additions & 14 deletions src/bob/artifact/core.clj
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,10 @@
[group name number artifact run-id path store-name]
(if-let [{url :url} (db/get-artifact-store states/db {:name store-name})]
(f/try-all [_ (log/debugf "Streaming from container with id %s and path %s" run-id path)
stream (clojure.java.io/input-stream
(java.io.ByteArrayInputStream.
(.getBytes
(docker/invoke states/containers {:op :ContainerArchive
:params {:id run-id
:path path}})
"UTF-8")))
stream (docker/invoke states/containers {:op :ContainerArchive
:params {:id run-id
:path path}
:as :stream})
upload-url (clojure.string/join "/"
[url
"bob_artifact"
Expand All @@ -130,13 +127,12 @@

(comment
(docker/ops (docker/client {:category :containers :conn states/docker-conn}))
(let [foo (clojure.java.io/input-stream (java.io.ByteArrayInputStream.
(.getBytes
(docker/invoke states/containers {:op :ContainerArchive
:params
{:id "35d5802cbf85"
:path "/root/my-source/target/default+uberjar/wendy"}}) "UTF-8")))]
@(http/post "http://localhost:8001/bob_artifact/wendy/build/1/wendy" {:multipart [{:name "data" :content foo}]}))
(let [foo (docker/invoke states/containers {:op :ContainerArchive
:params
{:id "clever_swartz"
:path "/root/my-source/target/default+uberjar/wendy"}
:as :stream})]
@(http/post "http://localhost:8001/bob_artifact/wendy/build/3/wendy" {:multipart [{:name "data" :content foo}]}))
(upload-artifact "dev" "test" 1 "poetry.lock" "0be7b883382b" "/opt" "s3")

(db/register-artifact-store states/db {:name "s3"
Expand Down
4 changes: 2 additions & 2 deletions src/bob/execution/internals.clj
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@
:params {:body {:Image image}}})]
(if (contains? result :message)
(u/log-and-fail "Could not build image:" (:message result))
result)))
(:Id result))))
([image step evars] (let [resource (:needs_resource step)
working-dir (when resource (str "/root/" resource))
cmd (u/sh-tokenize! (:cmd step))
Expand All @@ -120,7 +120,7 @@
:WorkingDir working-dir}}})]
(if (contains? result :message)
(u/log-and-fail "Could not build image:" (:message result))
result))))
(:Id result)))))

(defn status-of
"Returns the status of a container by id."
Expand Down
4 changes: 2 additions & 2 deletions src/bob/pipeline/internals.clj
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@
step
pipeline)
result (next-step build-state step evars pipeline run-id)
id (update-pid (:Id (:id result)) run-id)
id (update-pid (:id result) run-id)
id (let [result (e/run id run-id)]
(when (f/failed? result)
(log/debugf "Removing failed container %s" id)
Expand Down Expand Up @@ -196,7 +196,7 @@
_ (mark-image-for-gc image run-id)
image (resourceful-step first-step pipeline image run-id)
_ (mark-image-for-gc image run-id)
id (:Id (e/build image first-step evars))
id (e/build image first-step evars)
id (update-pid id run-id)
id (let [result (e/run id run-id)]
(when (f/failed? result)
Expand Down
2 changes: 1 addition & 1 deletion src/bob/resource/internals.clj
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@
TarInputStream.
(prefix-dir-on-tar! resource-name))
_ (log/debug "Creating temp container for resource mount")
container-id (:Id (e/build image))
container-id (e/build image)
_ (log/debug "Copying resources to container")
_ (put-container-archive container-id archive "/root")
_ (-> archive File. .delete)
Expand Down

0 comments on commit f7eb578

Please sign in to comment.