-
Notifications
You must be signed in to change notification settings - Fork 0
fix: address all review findings — wire memory strategy, fix dead code, add tests #34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
7af9643
5e348d0
43fc5f0
7a89db1
bebd8b0
459565f
72c2b2b
7240e44
29e0fd2
18656ed
0c2fdd1
c0003d2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -119,6 +119,15 @@ defmodule Nopea.Deploy do | |
| strategy | ||
| end | ||
|
|
||
| defp select_strategy(%Spec{strategy: nil}, %{known: true, failure_patterns: patterns}) | ||
| when is_list(patterns) do | ||
| threshold = Application.get_env(:nopea, :canary_threshold, 0.15) | ||
|
|
||
| if Enum.any?(patterns, fn p -> p.confidence > threshold end), | ||
| do: :canary, | ||
| else: :direct | ||
| end | ||
|
|
||
| defp select_strategy(%Spec{strategy: nil}, _context), do: :direct | ||
|
|
||
| defp select_strategy(%Spec{strategy: other}, _context) do | ||
|
|
@@ -151,21 +160,12 @@ defmodule Nopea.Deploy do | |
|
|
||
| defp verify_deploy(spec, applied) when is_list(applied) do | ||
| Enum.all?(applied, fn manifest -> | ||
| case Nopea.Drift.verify_manifest(spec.service, manifest) do | ||
| case Nopea.Drift.verify_manifest(spec.service, manifest, k8s_module: k8s_module()) do | ||
| :no_drift -> true | ||
| :new_resource -> true | ||
| _ -> false | ||
| end | ||
| end) | ||
| rescue | ||
| error -> | ||
| Logger.warning("Post-deploy verification failed", | ||
| service: spec.service, | ||
| error: inspect(error), | ||
| stacktrace: __STACKTRACE__ |> Exception.format_stacktrace() | ||
| ) | ||
|
|
||
| false | ||
| end | ||
|
|
||
| defp verify_deploy(_spec, _applied), do: false | ||
|
|
@@ -178,7 +178,7 @@ defmodule Nopea.Deploy do | |
| status: result.status, | ||
| error: result.error, | ||
| duration_ms: result.duration_ms, | ||
| concurrent_deploys: [] | ||
| concurrent_deploys: get_concurrent_services(result.service) | ||
| }) | ||
| end | ||
|
|
||
|
|
@@ -408,6 +408,30 @@ defmodule Nopea.Deploy do | |
|
|
||
| defp emitter_running?, do: Process.whereis(Nopea.Events.Emitter) != nil | ||
|
|
||
| defp get_concurrent_services(current_service) do | ||
| if Process.whereis(Nopea.Registry) do | ||
| Registry.select(Nopea.Registry, [ | ||
| {{:"$1", :"$2", :_}, [], [{{:"$1", :"$2"}}]} | ||
| ]) | ||
| |> Enum.flat_map(fn | ||
| {{:service, name}, pid} when name != current_service -> | ||
| try do | ||
| case GenServer.call(pid, :status, 1_000) do | ||
| %{status: :deploying} -> [name] | ||
| _ -> [] | ||
| end | ||
| catch | ||
| :exit, _ -> [] | ||
| end | ||
|
|
||
| _ -> | ||
| [] | ||
| end) | ||
| else | ||
|
Comment on lines
+411
to
+430
|
||
| [] | ||
| end | ||
| end | ||
|
|
||
| defp duration_ms(start_time) do | ||
| System.convert_time_unit(System.monotonic_time() - start_time, :native, :millisecond) | ||
| end | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
serve/1sets:enable_api, but the application supervision tree gates the HTTP server on:enable_router(seeNopea.Application.add_router_child/1). As written,nopea servemay never startNopea.API.Routerunlessenable_routeris already true in config. Use the same config key here (or update the application to read:enable_apiconsistently).