Skip to content

Commit

Permalink
wait for timeline on setup_docker_stack
Browse files Browse the repository at this point in the history
  • Loading branch information
var77 committed May 5, 2024
1 parent f95ff61 commit c7436fe
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 5 deletions.
4 changes: 1 addition & 3 deletions model/lantern/lantern_server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,7 @@ def configure_hash
end

def update_walg_creds
# fetching again to be sure it is the updated data
lantern_timeline = LanternTimeline[timeline.id]
walg_config = lantern_timeline.generate_walg_config
walg_config = timeline.generate_walg_config
vm.sshable.cmd("sudo lantern/bin/update_env", stdin: JSON.generate([
["WALG_GS_PREFIX", walg_config[:walg_gs_prefix]],
["GOOGLE_APPLICATION_CREDENTIALS_WALG_B64", walg_config[:gcp_creds_b64]],
Expand Down
3 changes: 3 additions & 0 deletions prog/lantern/lantern_server_nexus.rb
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,9 @@ def before_run
raise "GCP_CREDS_GCR_B64 is required to setup docker stack for Lantern"
end

# wait for service account to be created
nap 10 if lantern_server.timeline.strand.label != "wait_leader"

case vm.sshable.cmd("common/bin/daemonizer --check configure_lantern")
when "Succeeded"
vm.sshable.cmd("common/bin/daemonizer --clean configure_lantern")
Expand Down
2 changes: 0 additions & 2 deletions spec/model/lantern/lantern_server_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -448,9 +448,7 @@
it "calls update_env on vm" do
timeline = instance_double(LanternTimeline)
expect(timeline).to receive(:generate_walg_config).and_return({gcp_creds_b64: "test-creds-push", walg_gs_prefix: "test-bucket-push"}).at_least(:once)
expect(timeline).to receive(:id).and_return("test").at_least(:once)
expect(lantern_server).to receive(:timeline).and_return(timeline).at_least(:once)
expect(LanternTimeline).to receive(:[]).and_return(timeline).at_least(:once)
walg_config = timeline.generate_walg_config
expect(vm.sshable).to receive(:cmd).with("sudo lantern/bin/update_env", stdin: JSON.generate([
["WALG_GS_PREFIX", walg_config[:walg_gs_prefix]],
Expand Down
10 changes: 10 additions & 0 deletions spec/prog/lantern/lantern_server_nexus_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,16 @@
end

describe "#setup_docker_stack" do
before do
allow(lantern_server.timeline).to receive(:strand).and_return(instance_double(Strand, label: "wait_leader"))
end

it "naps if timeline is not ready" do
expect(lantern_server.timeline).to receive(:strand).and_return(instance_double(Strand, label: "start"))
expect(Config).to receive(:gcp_creds_gcr_b64).and_return("test-creds")
expect { nx.setup_docker_stack }.to nap(10)
end

it "raises if gcr credentials are not provided" do
expect(Config).to receive(:gcp_creds_gcr_b64).and_return(nil)
expect { nx.setup_docker_stack }.to raise_error "GCP_CREDS_GCR_B64 is required to setup docker stack for Lantern"
Expand Down

0 comments on commit c7436fe

Please sign in to comment.