Skip to content

Commit

Permalink
fix: add delay before starting job if image changed
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaelgomesxyz committed May 2, 2024
1 parent 1ac86b3 commit 3cc5fbd
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions lib/command/run.rb
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,9 @@ class Run < Base # rubocop:disable Metrics/ClassLength
EX

attr_reader :interactive, :detached, :location, :original_workload, :runner_workload,
:container, :image_link, :job, :replica, :command
:container, :image_link, :image_changed, :job, :replica, :command

def call # rubocop:disable Metrics/MethodLength
def call # rubocop:disable Metrics/CyclomaticComplexity, Metrics/MethodLength, Metrics/PerceivedComplexity
@interactive = config.options[:interactive] || interactive_command?
@detached = config.options[:detached]

Expand All @@ -113,6 +113,11 @@ def call # rubocop:disable Metrics/MethodLength
update_runner_workload
wait_for_runner_workload_update

# NOTE: need to wait some time before starting the job,
# otherwise the image may not be updated yet
# TODO: need to figure out if there's a better way to do this
sleep 1 if image_changed

start_job
wait_for_replica_for_job

Expand Down Expand Up @@ -181,6 +186,7 @@ def update_runner_workload # rubocop:disable Metrics/MethodLength
else
@image_link = original_container_spec["image"]
end
@image_changed = container_spec["image"] != image_link
container_spec["image"] = image_link

# Container overrides
Expand Down

0 comments on commit 3cc5fbd

Please sign in to comment.