Skip to content

Commit

Permalink
Merge branch 'release/v1.0.5'
Browse files Browse the repository at this point in the history
  • Loading branch information
zacksiri committed Jul 4, 2024
2 parents c301018 + 35108c4 commit 8a266e4
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 12 deletions.
4 changes: 2 additions & 2 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,14 @@ runs:
uses: actions/cache@v4
with:
path: ~/.mix
key: ${{ runner.arch }}-icepak-1.0.4
key: ${{ runner.arch }}-icepak-1.0.5

- name: Install Pakman
if: steps.cache-icepak.outputs.cache-hit != 'true'
run: |
mix local.rebar --force
mix local.hex --force
mix escript.install hex icepak 1.0.4 --force
mix escript.install hex icepak 1.0.5 --force
shell: alpine.sh {0}
env:
MIX_ENV: prod
2 changes: 0 additions & 2 deletions lib/icepak/checks.ex
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,6 @@ defmodule Icepak.Checks do
"[Checks] ❌ Deactivating #{product["id"]} #{version["serial"]} some checks failed"
)

@polar.transition_version(polar_client, version, %{"name" => "deactivate"})

raise Icepak.Checks.Setup.CheckFailError,
"Some checks have failed, please retry or fix the issue."
end
Expand Down
19 changes: 16 additions & 3 deletions lib/icepak/checks/setup.ex
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,13 @@ defmodule Icepak.Checks.Setup do
"virtual-machine" => "vm"
}

@wait_time %{
@default_wait_time %{
"container" => 2_000,
"vm" => 10_000
}

@increment_wait_time 500

require Logger

def prepare(
Expand Down Expand Up @@ -114,7 +116,8 @@ defmodule Icepak.Checks.Setup do
timeout: 300_000
)

run_attempt = System.get_env("GITHUB_RUN_ATTEMPT")
run_attempt = System.get_env("GITHUB_RUN_ATTEMPT") || "0"
increment_wait_time = @increment_wait_time * String.to_integer(run_attempt)

with {:ok, project_name} <- Testing.get_or_create_project(client),
{:ok, %{body: create_operation}} <-
Expand All @@ -126,7 +129,17 @@ defmodule Icepak.Checks.Setup do
{:ok, _wait_start_result} <-
@lexdee.wait_for_operation(client, start_operation["id"], query: [timeout: 300]) do
if Application.get_env(:icepak, :env) != :test do
wait_time = Map.fetch!(@wait_time, instance_type) * String.to_integer(run_attempt)
instance_wait_time =
Enum.find(cluster.instance_wait_times, fn iwt ->
iwt["type"] == instance_type
end)

wait_time =
if instance_wait_time do
instance_wait_time["duration"]
else
Map.fetch!(@default_wait_time, instance_type) + increment_wait_time
end

Logger.info(
"[#{check_name}] Waiting #{wait_time} ms for #{instance_type} #{instance_name}"
Expand Down
19 changes: 15 additions & 4 deletions lib/icepak/polar/cluster.ex
Original file line number Diff line number Diff line change
@@ -1,13 +1,23 @@
defmodule Icepak.Polar.Cluster do
@derive {Inspect, only: [:id, :type, :arch, :current_state]}
defstruct [:id, :type, :arch, :current_state, :endpoint, :private_key, :certificate]
@derive {Inspect, only: [:id, :type, :arch, :current_state, :instance_wait_times]}
defstruct [
:id,
:type,
:arch,
:current_state,
:endpoint,
:private_key,
:certificate,
:instance_wait_times
]

def new(%{
"id" => id,
"type" => type,
"arch" => arch,
"current_state" => current_state,
"credential" => credential
"credential" => credential,
"instance_wait_times" => instance_wait_times
}) do
%__MODULE__{
id: id,
Expand All @@ -16,7 +26,8 @@ defmodule Icepak.Polar.Cluster do
current_state: current_state,
endpoint: credential["endpoint"],
private_key: credential["private_key"],
certificate: credential["certificate"]
certificate: credential["certificate"],
instance_wait_times: instance_wait_times
}
end
end
2 changes: 1 addition & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ defmodule Icepak.MixProject do
def project do
[
app: :icepak,
version: "1.0.4",
version: "1.0.5",
elixir: "~> 1.14",
elixirc_paths: elixirc_paths(Mix.env()),
start_permanent: Mix.env() == :prod,
Expand Down

0 comments on commit 8a266e4

Please sign in to comment.