Fake51

Fake51

Readiness/liveness issues

I have a catch-22 issue that I’m struggling somewhat with and could use some input/experiences from others.

I’m developing a stocklevel tracking service that uses mnesia and which gets deployed to a kubernetes cluster. My issue is that new nodes starting up will not get connected to the already connected nodes if I use the kubernetes readiness property - however, as part of starting up I want a node to get a copy of the mnesia tables, ram copy only. I’m not marking it ready until it has connected to the clustered nodes and received it’s copy.

Does anyone have experience using either libcluster or peerage (which is what I’m using currently) and connecting nodes before kubernetes sees the new node as ready?

Marked As Solved

Fake51

Fake51

I found a solution to my issue, it seems. it’s documented but poorly.

My setup is using a headless service in kubernetes - that handles the DNS, so the pods get IPs of each other by looking up their own hostnames. That’s bog standard and easy. However, the headless service doesn’t publish the IP of pods that don’t show as ready, unless you specifically add publishNotReadyAddresses to the service config. Set that to true and it works.

Thanks for the help, benwilson512!

Also Liked

benwilson512

benwilson512

Author of Craft GraphQL APIs in Elixir with Absinthe

Hey @Fake51, here’s what I do.

Here is my health controller:

defmodule Sensetra.Web.HealthController do
  use Phoenix.Controller, log: false

  def alive(conn, _params) do
    json(conn, %{alive: true})
  end

  def ready(conn, _params) do
    if Application.get_env(:sensetra, :ready) do
      json(conn, %{ready: true})
    else
      send_resp(conn, 503, "")
    end
  end
end

Notice how the alive endpoint always returns true, but the ready endpoint is conditional on an application environment setting. In my config, that value defaults to false. Then, I just have a tiny genserver as the very last entry in my supervision tree that sets the value to true. This ensures that the application doesn’t indicate that it is ready until the entire supervision tree has booted.

Where Next?

Popular in Questions Top

LegitStack
I’m hoping you guys can give me some general advice and perhaps code examples if you’re feeling up to it. I’m very interested in Elixir,...
New
ycv005
I have followed this StackOverflow post to install the specific version of Erlang. And When I am running mix ecto.setup then getting fol...
New
fireproofsocks
I’m working on defining a simple Ecto schema for a table (in PostGres), but I don’t see where I can define a column as NOT NULL. Conside...
New
minhajuddin
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New
fayddelight
I tried installing elixir 1.11.2 erlang 23.3.4 via asdf in my zsh shell. Enabled the versions locally and globally. When I list them ...
New
johnnyicon
Hi all, I've just started learning Elixir and Phoenix Framework, so please pardon my n00bness at this stage. I'm trying to use Postg...
New
kostonstyle
Hi all I want to have a unix time, from the current time plus 1 hour. DateTime.now + 1 hour How to get it in elixir? Thanks
New
Codball
Mix format works fine if run from the cmd. I’ve followed this to facilitate the implementation into VSC which involves downloading an ext...
New
jc00ke
Expanding on this topic: https://forum.elixirforum.net/t/map-typespec-question/19217 Let’s say I have a map with required and optional k...
New
vrod
I am using the Starship cross-shell prompt – it seems pretty nice, but I get some errors: [WARN] - (starship::utils): Executing command ...
New

Other popular topics Top

_russellb
I want to try my hand at web scraping. What tools/libraries do I need to use. I’m hoping to turn this into something professional so don’...
New
SoCreat
i’m a new one to elixir which editor can i use vs code? or atom? Thanks! :smiley:
New
myronmarston
The Elixir Typespec docs show the following syntax for keyword lists in typespecs: # ... | [key: type] # keyword lis...
New
chensan
I have a User schema with a :from_id field set to type :string: defmodule TweetBot.Repo.Migrations.CreateUsers do use Ecto.Migration ...
New
stefanluptak
Hello everybody, usually, I use a 29" ultra-wide monitor for VSCode which can easily accomodate explorer (files panel) + file with code ...
New
electic
Hi, I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
New
baxterw3b
Hi guys, i’m new in the Elixir world, and i have to say, that i love it! i’m having some problem to understand anonymous functions with ...
New
chrisalley
ExUnit now has describe blocks which is a welcome addition coming from RSpec. In the docs, it states that nested hierarchies of describe ...
New
joeerl
Hello again - after a longish gap I’ve decided I really must dig into Elixir and see what’s been happening here - so I have a few questio...
New
magnetic
Hey :wave:t3: Elixir community, I’ve been learning Elixir, and working on some side projects. My editor of choice is VSCode, and althoug...
New

We're in Beta

About us Mission Statement