Skip to content

Commit e8bba5a

Browse files
ausimianclaude
andcommitted
docs: name the emulator directory by its ERTS version
remove/1's doc said the command deletes erts-<vsn>, using the same vsn as its release-version argument. do_remove_release/4 reads erts_vsn out of the release record and removes erts-<EVsn> only when no remaining release refers to that emulator - and the two numbers are unrelated, normally different ones: a release at 0.1.1 may be carrying erts-16.2. So the doc named a directory that generally does not exist. The same placeholder was reused in five other places where it sits beside lib/<app>-<vsn> and so reads as the same version, including the ERTS guard's own refusal message, which ships. All now say erts-<erts_vsn>. The synthetic release fixture's erts-<vsn>/bin is left alone: there is no adjacent lib/<app>-<vsn> and the version genuinely is the emulator's. The whole-message assertion in erts_guard_test failed on the reword, which is what it is for - the message has been wrong three times about what it can claim, so changing it deliberately means editing that test deliberately. Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 9e152ef commit e8bba5a

6 files changed

Lines changed: 16 additions & 9 deletions

File tree

AGENTS.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ Castle's job is configuration and release management on a running node.
315315
library directories *relatively*`filename:join("lib", LibName)`, so the file
316316
stays relocatable — so every `lib/<app>-<vsn>` the handler reads, writes or
317317
deletes resolves there, as does the `extract_tar(Root, Tar)` an unpack goes
318-
through and the `erts-<vsn>` a removal deletes. So a Castle that wrote to
318+
through and the `erts-<erts_vsn>` a removal deletes. So a Castle that wrote to
319319
`$RELEASE_ROOT` would put the configuration where the handler never looks, and
320320
an upgrade would go on using applications under the installation — a silent
321321
divergence in place of a loud failure. Do not "fix" the guard that way.

RELEASE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@
363363
the reason, rather than quietly managing the Erlang installation it happens to
364364
be running on. Such a release ships no emulator, so it runs the system one, and
365365
`code:root_dir()` — the directory `:release_handler` extracts applications
366-
into, resolves every `lib/<app>-<vsn>` against, and deletes `erts-<vsn>` from —
366+
into, resolves every `lib/<app>-<vsn>` against, and deletes `erts-<erts_vsn>` from —
367367
is then the shared Erlang installation rather than the deployment. Left to itself, `make_releases/0` created that installation's
368368
`releases/RELEASES`, which usually fails for want of permission and, where it
369369
succeeds, puts the release records of unrelated deployments in one file;

lib/castle.ex

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -579,8 +579,15 @@ defmodule Castle do
579579
Removes `vsn` from the system, and deletes what nothing else is using.
580580
581581
`bin/castle remove <vsn>`. It takes away the version's own release directory,
582-
every library directory no remaining release refers to, and the `erts-<vsn>`
583-
if that version of the emulator is now unreferenced.
582+
every library directory no remaining release refers to, and the
583+
`erts-<erts_vsn>` of the emulator that release was built against, if no
584+
remaining release still refers to it.
585+
586+
Note that the emulator directory is named for the *ERTS* version and not for
587+
`vsn` — `do_remove_release/4` reads `erts_vsn` out of the release record and
588+
compares it against the releases that are left. The two are unrelated numbers,
589+
and normally different ones: a release at `0.1.1` may well be carrying
590+
`erts-16.2`.
584591
585592
It deletes rather than merely forgets, which is the point of having it: a
586593
deployment that never removes a superseded version only grows. Raises

lib/castle/commands.ex

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ defmodule Castle.Commands do
165165
# not Castle's choice of one - `Castle.Deployment.root_dir/0` sets out what it
166166
# anchors and what it does not, and is the only place that should. The half
167167
# this rests on is the applications: extraction, every `lib/<app>-<vsn>` the
168-
# handler resolves, and the `erts-<vsn>` a removal deletes. Those cannot be
168+
# handler resolves, and the `erts-<erts_vsn>` a removal deletes. Those cannot be
169169
# relocated, which is why relocating the *records* - the half that can be, with
170170
# `RELDIR` or `{sasl, releases_dir}` - is not a way out of this refusal.
171171
#
@@ -239,7 +239,7 @@ defmodule Castle.Commands do
239239
"#{refusal}: the deployment and the emulator's root are different " <>
240240
"directories - the deployment is #{release_root} and the emulator runs " <>
241241
"in #{root_dir}. That is where :release_handler extracts applications, " <>
242-
"resolves every lib/<app>-<vsn> it reads, and deletes erts-<vsn> from, " <>
242+
"resolves every lib/<app>-<vsn> it reads, and deletes erts-<erts_vsn> from, " <>
243243
"because those paths are anchored to the emulator's root rather than to " <>
244244
"the deployment. Pointing Castle at the deployment instead would only " <>
245245
"move the release records away from the applications they describe. " <>
@@ -1450,7 +1450,7 @@ defmodule Castle.Commands do
14501450
Refuses a release that did not bring its own ERTS - see `ensure_own_erts/2` -
14511451
and of everything gated this is the operation with the most to lose by not
14521452
being: `remove_release/1` *deletes*, and the library directories and
1453-
`erts-<vsn>` it takes away are resolved against `code:root_dir()` - the anchor
1453+
`erts-<erts_vsn>` it takes away are resolved against `code:root_dir()` - the anchor
14541454
nothing can relocate - so on such a deployment it is the Erlang installation
14551455
it would be asked to delete out of.
14561456
"""

lib/castle/deployment.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ defmodule Castle.Deployment do
3636
applications: the `extract_tar(Root, Tar)` an unpack goes through, every
3737
`lib/<app>-<vsn>` the handler resolves — stored relatively by
3838
`create_RELEASES/3` precisely so the file can be moved — and the
39-
`erts-<vsn>` a removal deletes.
39+
`erts-<erts_vsn>` a removal deletes.
4040
4141
**The release records are not.** `init/1` takes its releases directory from
4242
`{sasl, releases_dir}`, then `RELDIR`, and only then `init:get_argument(root)`.

test/castle/erts_guard_test.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ defmodule Castle.ErtsGuardTest do
9090
"and the emulator's root are different directories - the deployment is " <>
9191
"#{deployment} and the emulator runs in #{root_dir}. That is where " <>
9292
":release_handler extracts applications, resolves every lib/<app>-<vsn> " <>
93-
"it reads, and deletes erts-<vsn> from, because those paths are anchored " <>
93+
"it reads, and deletes erts-<erts_vsn> from, because those paths are anchored " <>
9494
"to the emulator's root rather than to the deployment. Pointing Castle at " <>
9595
"the deployment instead would only move the release records away from the " <>
9696
"applications they describe. Relocating the records with RELDIR or the " <>

0 commit comments

Comments
 (0)