Skip to content

Improve API for the site metadata - #46

Open
ieQu1 wants to merge 10 commits into
masterfrom
dev/site-metadata
Open

Improve API for the site metadata#46
ieQu1 wants to merge 10 commits into
masterfrom
dev/site-metadata

Conversation

@ieQu1

@ieQu1 ieQu1 commented Aug 5, 2026

Copy link
Copy Markdown
Member
  1. Unify and clarify API for various types of site metadata.
  2. "Cluster" metadata is no longer cleaned when cluster changes, it just becomes invisible. User can clean it if needed.
  3. Allow to specify minimum run level required to run vote actions.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves the site metadata API by separating cluster-replicated metadata from site-private metadata, and updates the codebase/tests to use the new API surface. It also refactors some cluster/site identity helpers and moves the restart-counter API into classy_node.

Changes:

  • Introduces classy_site_metadata split API (c_* for cluster metadata, s_* for site-private metadata) including atomic batch operations.
  • Adds classy:the_site_err/0 and classy:the_cluster_err/0 for maybe-friendly error tuples and updates some callers.
  • Moves n_restarts/0 and restart counter incrementing from classy_liveness into classy_node, updating dependent modules/tests.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
test/classy_SUITE.erl Updates tests to use new classy_site_metadata API and extends coverage for atomic operations and leave semantics.
src/classy.erl Updates docs/exports, removes old site-prop wrappers, and adds *_err/0 helpers used in maybe flows.
src/classy_uid.erl Switches restart counter source from classy_liveness to classy_node.
src/classy_site_metadata.erl Implements the new c_*/s_* metadata APIs, namespacing, persistence, and propagation.
src/classy_node.erl Introduces per-node persistent table keying, adds restart counter API, and initializes/terminates site metadata table.
src/classy_liveness.erl Removes exported restart counter API and delegates restart counting to classy_node.
src/classy_internal.hrl Removes shared ?globals/?n_restarts macros (now owned by specific modules).
src/classy_hook.erl Removes the on_leave hook that previously triggered metadata cleanup.
Suppressed comments (1)

test/classy_SUITE.erl:936

  • These comments still refer to "globals" even though the testcase now exercises site-private metadata (s_* APIs). Updating them will make the test intent clearer.
       %% First, all globals are empty:
       ?assertEqual(#{}, ?ON(S1, classy_site_metadata:s_get_all())),
       %% Set a global:
       ?assertMatch(ok, ?ON(S1, classy_site_metadata:s_set(foo, foo))),
       ?assertMatch(ok, ?ON(S2, classy_site_metadata:s_set(bar, bar))),

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/classy.erl Outdated
Comment thread src/classy_site_metadata.erl
Comment thread src/classy_site_metadata.erl Outdated
Comment thread test/classy_SUITE.erl Outdated
Comment thread test/classy_SUITE.erl Outdated

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.

Suppressed comments (1)

src/classy_site_metadata.erl:92

  • Spelling typo in the s_set/2 docstring: "Persistentley" should be "Persistently".
-doc """
Persistentley set a site property.

These properties survive all cluster changes,
they don't get cleaned automatically.

Comment thread src/classy_site_metadata.erl

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated no new comments.

Suppressed comments (2)

src/classy_site_metadata.erl:89

  • Typo in moduledoc: "Persistentley" should be "Persistently".
-doc """
Persistentley set a site property.

src/classy_site_metadata.erl:159

  • In c_atomically/2, propagate(Cluster) is called but its result is ignored, so the function can return {ok, Effects} even when propagation to classy_membership fails. This can leave peers with stale metadata while callers believe the operation fully succeeded.
    {ok, Effects} ?= classy_table:atomically(?tab, Ops),
    propagate(Cluster),
    {ok, Effects}

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 15 out of 15 changed files in this pull request and generated no new comments.

Suppressed comments (2)

src/classy_site_metadata.erl:88

  • Typo in docstring: “Persistentley” should be “Persistently” (also matches spelling used elsewhere in docs).
Persistentley set a site property.

src/classy_vote.erl:511

  • Typo in comment: “relevent” should be “relevant”.
  %% aren't relevent for tests:

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 17 out of 17 changed files in this pull request and generated 3 comments.

Suppressed comments (3)

src/classy_site_metadata.erl:269

  • propagate/1 currently returns the result of classy_membership:set_info/3 (now {ok, Clock}), which means c_set/3 and c_delete/2 will return {ok, Clock} despite their specs stating ok | {error, _}. This is an API behavior change and is likely to break callers matching on ok.
propagate(Cluster) ->
  maybe
    {ok, Site} ?= classy:the_site_err(),
    classy_membership:set_info(
      Cluster,

src/classy_site_metadata.erl:159

  • c_atomically/2 calls propagate/1 but does not check its result. If propagation fails, the function will still return {ok, Effects}, leaving local state updated but gossip/membership info stale.

This issue also appears on line 265 of the same file.

    {ok, Effects} ?= classy_table:atomically(?tab, Ops),
    propagate(Cluster),
    {ok, Effects}

src/test/classy_test_fuzzer.erl:552

  • The numeric literal 20_0 is equivalent to 200, but it’s an unusual separator placement and easy to misread as a typo. Using 200 would be clearer and consistent with the previous value.
wait_clusters_converge(S) ->
  ?retry(100, 20_0,
         maps:foreach(

Comment thread src/classy_vote_participant.erl
Comment thread src/classy_vote_coordinator.erl
Comment thread src/classy_node.erl Outdated
@ieQu1
ieQu1 force-pushed the dev/site-metadata branch from fd98ff3 to c14626c Compare August 5, 2026 21:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants