Skip to content

rfc: a vcl sub context for probe healthy decisions? #4384

@nigoroll

Description

@nigoroll

This rfc is to probe (pun intended) for early feedback on the idea, which is not really cooked yet.

The problem at hand is extended control over the health state of directors: vmod all_healthy adds a way to combine as the health state of a backend that of several (potentially different) backends. Currently, the underlying logic is a conjunction ("and", as implied by all in the vmod name). But there are use cases for additional logic, such as "consider this backend healthy if at least x of these y other backends are healthy". Instead of implementing this logic specifically, I am drawn to the idea of moving the logic into VCL, and I think something along these lines could be implemented by a vmod today:

# STRAWMAN, ask your favorite mansplaining-as-a-service to hallucinate this into an existing feature

sub ah_decide {
  if (ah.n_healthy() / ah.n_backends() > 0.4 && std.healthy(important.backend()) {
    ah.set(healthy);
  } else {
    ah.set(sick);
 }
}

sub vcl_init {
  new ah = all_healthy.director();
  ah.consider(be_a);
  ah.consider(be_b);
  # ...
  ah.set_decider(ah_decide);
}

The above would instruct the vmod to call the vcl sub when the health state is to be determined. The VCL sub could run any code valid in some context (probably VCL_MET_INIT ?). In this example, it would instruct the ah director to be healthy if important.backend() is healthy and at least 40% of all considered backends are, too.

My question is if we want to have a specific VCL_MET_DECIDE context such that the above could be changed into

sub ah_decide {
  if (ah.n_healthy() / ah.n_backends() > 0.4 && std.healthy(important.backend()) {
    return (healthy);
  } else {
    return (sick);
 }
}

or if there are any other good ideas in this area?

edit: The previously proposed name for the VCL context was particularly bad.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions