Skip to content

Improve autocluster#19

Merged
ieQu1 merged 8 commits into
masterfrom
dev/improve-autocluster
Jun 17, 2026
Merged

Improve autocluster#19
ieQu1 merged 8 commits into
masterfrom
dev/improve-autocluster

Conversation

@ieQu1

@ieQu1 ieQu1 commented Jun 17, 2026

Copy link
Copy Markdown
Member

No description provided.

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 refactors autocluster discovery strategy selection to be hook-driven, updates vote (2PC) callbacks/tracing to include the vote ID, and aligns tests/docs with these API changes.

Changes:

  • Introduce classy_discovery_strategy:hook/2-based discovery method registration and add hook/0 to built-in strategies (static/dns/k8s/etcd).
  • Extend vote callbacks so prepare/commit/rollback/post_vote receive the vote ID; add participant “recv_outcome” tracing and update properties/docs accordingly.
  • Simplify discovery test suites by removing now-irrelevant lock/register tests and adjust a membership test to wait for joins.

Reviewed changes

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

Show a summary per file
File Description
test/classy_SUITE.erl Updates membership test and vote test callbacks to accept vote ID.
test/classy_discovery_static_SUITE.erl Removes lock/unlock/register/unregister testcases for static strategy.
test/classy_discovery_k8s_SUITE.erl Removes lock/unlock/register/unregister testcases (not applicable anymore).
test/classy_discovery_dns_SUITE.erl Removes lock/unlock/register/unregister testcases for DNS strategy.
src/discovery/classy_discovery_static.erl Adds hook/0 registration; removes optional callbacks.
src/discovery/classy_discovery_k8s.erl Adds hook/0 registration; removes optional callbacks.
src/discovery/classy_discovery_etcd.erl Adds hook/0 registration for etcd discovery.
src/discovery/classy_discovery_dns.erl Adds hook/0 registration; removes optional callbacks.
src/classy_vote.erl Adds detailed moduledoc; adjusts MFA verification for extra vote-id args; updates trace property.
src/classy_vote_participant.erl Prepends vote ID to commit/rollback actions; emits outcome trace with site/id.
src/classy_vote_coordinator.erl Prepends vote ID to post_vote callback invocation.
src/classy_internal.hrl Adds trace kind macro for participant recv_outcome.
src/classy_hook.erl Registers built-in discovery strategies during hook initialization.
src/classy_discovery_strategy.erl Adds hook/2, resolves configured method via hooks, makes lock/register callbacks optional.
src/classy_builtin_hooks.erl Consolidates peer-connection change logging and varies log level based on locality.
src/classy_autocluster.erl Switches to resolved {Module, Options} strategy selection (no manual module name construction).
doc/classy.texi Updates documentation for discovery strategy configuration and hook-based extensibility.

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

Comment thread src/classy_autocluster.erl
Comment thread src/classy_discovery_strategy.erl
Comment thread src/classy_vote.erl Outdated
Comment thread src/classy_vote.erl Outdated
Comment thread test/classy_SUITE.erl
Comment thread src/classy_discovery_strategy.erl Outdated
@ieQu1 ieQu1 force-pushed the dev/improve-autocluster branch from 6b50c5d to 091f84c Compare June 17, 2026 13:01
@ieQu1 ieQu1 requested a review from Copilot June 17, 2026 13:02

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 18 out of 18 changed files in this pull request and generated 3 comments.

Comments suppressed due to low confidence (1)

src/classy_vote.erl:203

  • options() currently types post_vote and on_fail as single mfargs(), but with_defaults/1 normalizes both to lists ([PostVote] / [OnFail]) and the coordinator expects lists. Consider widening the type to accept both forms to match actual usage.
-type options() ::
        #{ tag       := tag()
         , actions   := #{classy:site() => actions()}
         , post_vote => classy_lib:mfargs()
         , strategy  => strategy()
         , on_fail   => classy_lib:mfargs()
         }.

Comment thread src/classy_vote.erl
Comment thread src/classy_vote.erl Outdated
Comment on lines 55 to +80
-doc """
Read value of @ref{discovery_strategy} environment variable (with default).
Register a discovery strategy.

Callbacks registered here match on the @ref{discovery_strategy} configuration
and return callback module implementing @code{classy_discovery_strategy} behavior.

The first hook that returns @code{@{ok, Module@}} wins
and handles all the callbacks for the next discovery cycle.
""".
-spec hook(fun(({atom(), options()}) -> {ok, module()} | undefined), classy_hook:prio()) -> classy_hook:hook().
hook(Fun, Prio) when is_function(Fun, 1), is_number(Prio) ->
classy_hook:insert(?hook, Fun, Prio).

-doc """
Read @ref{discovery_strategy} environment variable and decide which strategy to use.
""".
-spec get() -> t() | undefined.
get() ->
application:get_env(classy, discovery_strategy, {manual, []}).
Conf = application:get_env(classy, discovery_strategy, {manual, []}),
case classy_hook:first_match(?hook, [Conf]) of
{ok, Module} ->
{_Method, Options} = Conf,
{Module, Options};
undefined ->
undefined
end.
@ieQu1 ieQu1 marked this pull request as ready for review June 17, 2026 13:52
@ieQu1 ieQu1 merged commit 4dea67e into master Jun 17, 2026
4 checks passed
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