diff --git a/lib/command/run.rb b/lib/command/run.rb index f0af3ad9..59fd8470 100644 --- a/lib/command/run.rb +++ b/lib/command/run.rb @@ -207,7 +207,7 @@ def update_runner_workload # rubocop:disable Metrics/CyclomaticComplexity, Metri original_env_str = original_container_spec["env"]&.sort_by { |env| env["name"] }.to_s env_str = container_spec["env"]&.sort_by { |env| env["name"] }.to_s if original_env_str != env_str - container_spec["env"] = original_container_spec["env"] + container_spec["env"] = original_container_spec["env"] || [] should_update = true end diff --git a/spec/command/run_spec.rb b/spec/command/run_spec.rb index 3d2d4be9..72724489 100644 --- a/spec/command/run_spec.rb +++ b/spec/command/run_spec.rb @@ -252,5 +252,27 @@ expect(result[:stderr]).to include("Gemfile") end end + + context "when runner workload has ENV but original workload does not" do + let!(:app) { dummy_test_app } + + before do + run_cpflow_command!("apply-template", "app", "rails", "rails-runner-with-different-env", "-a", app) + run_cpflow_command!("build-image", "-a", app) + run_cpflow_command!("deploy-image", "-a", app) + end + + after do + run_cpflow_command!("delete", "-a", app, "--yes") + end + + it "updates runner workload", :slow do + result = run_cpflow_command("run", "-a", app, "--entrypoint", "none", "--", "ls") + + expect(result[:status]).to eq(0) + expect(result[:stderr]).to include("Updating runner workload") + expect(result[:stderr]).to include("Gemfile") + end + end end end