Skip to content

Support registering multiple health checks. #59

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

Merged
merged 3 commits into from
May 14, 2025

Conversation

giladwolff
Copy link
Contributor

What problem are we solving?

Today, the RegisterEntityPayload offers the legacy registration interface that allowed registering a single Check. Consul supports registering multiple health checks starting in 2015 (commit 674be58e55f). For backward compatibility they maintain support for passing a single Check. Here is the relevant excerpt from agent/consul/catalog_endpoint.go:

// Move the old format single check into the slice, and fixup IDs.
if args.Check != nil {
        args.Checks = append(args.Checks, args.Check)
        args.Check = nil
}

How are we solving the problem?

Let's switch from offering a single 'Check' to running multiple 'Checks'. This breaks backwards compatibility and drops support to consuls servers from 10 years ago.

Checks

Please check these off before promoting the pull request to non-draft status.

  • All CI checks are green.
  • I have reviewed the proposed changes myself.

Copy link

CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes.

@@ -312,9 +312,8 @@ pub struct RegisterEntityPayload {
/// Optional service to register.
#[serde(skip_serializing_if = "Option::is_none")]
pub Service: Option<RegisterEntityService>,
/// Optional check to register
#[serde(skip_serializing_if = "Option::is_none")]
pub Check: Option<RegisterEntityCheck>,
Copy link
Contributor

Choose a reason for hiding this comment

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

Hey.
In the official API docs, Check is not marked as deprecated or as legacy.
I think someone reading the docs will naturally use Check, so it's better to keep it and document that Checks is preferred instead.

Copy link
Contributor

Choose a reason for hiding this comment

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

Hi @x0rw, we discussed this.
The official documentation states that
Multiple checks can be provided by replacing Check with Checks and sending an array of Check objects.
When we examined the server code for consul however, it accepts both as well and appends Check to Checks.

This behavior is confusing/surprising. We're opting to expose just one field instead, which can be empty to represent the original None state.

Copy link
Contributor Author

@giladwolff giladwolff May 14, 2025

Choose a reason for hiding this comment

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

@kushudai kushudai requested a review from x0rw May 14, 2025 01:51
@giladwolff giladwolff requested a review from kushudai May 14, 2025 03:30
@giladwolff giladwolff marked this pull request as ready for review May 14, 2025 03:31
@kushudai kushudai merged commit 6890dc8 into main May 14, 2025
5 checks passed
@kushudai kushudai deleted the support-multiple-checks-registration branch May 14, 2025 03:32
@github-actions github-actions bot locked and limited conversation to collaborators May 14, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants