Skip to content

Commit

Permalink
Add an event for directors going sick
Browse files Browse the repository at this point in the history
Pondering solutions for varnishcache#4183 it became apparent that we need a way to notify
directors of changes to the admin_health without crossing the VDI/VBE layering.

Besides adding another director callback, one option is to add an event to the
existing event facility, which so far was only used for VCL-related events. We
now add VDI_EVENT_SICK as a director-specific event, which is cheap and also
helps us maintain clean layering.
  • Loading branch information
nigoroll authored and walid-git committed Nov 4, 2024
1 parent 2378f20 commit 60dd259
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
6 changes: 5 additions & 1 deletion bin/varnishd/cache/cache_backend.c
Original file line number Diff line number Diff line change
Expand Up @@ -561,6 +561,11 @@ vbe_dir_event(const struct director *d, enum vcl_event_e ev)
VRT_VSC_Hide(bp->vsc_seg);
} else if (ev == VCL_EVENT_DISCARD) {
VRT_DelDirector(&bp->director);
} else if (ev == VDI_EVENT_SICK) {
const struct vdi_ahealth *ah = d->vdir->admin_health;

if (ah == VDI_AH_SICK || (ah == VDI_AH_AUTO && bp->sick))
VBE_connwait_signal_all(bp);
}
}

Expand Down Expand Up @@ -661,7 +666,6 @@ vbe_healthy(VRT_CTX, VCL_BACKEND d, VCL_TIME *t)
return (!bp->sick);
}


/*--------------------------------------------------------------------
*/

Expand Down
8 changes: 6 additions & 2 deletions include/vrt.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@

#define VRT_MAJOR_VERSION 20U

#define VRT_MINOR_VERSION 0U
#define VRT_MINOR_VERSION 1U

/***********************************************************************
* Major and minor VRT API versions.
Expand All @@ -57,6 +57,8 @@
* Whenever something is deleted or changed in a way which is not
* binary/load-time compatible, increment MAJOR version
*
* 20.1 (2024-11-08)
* VDI_EVENT_SICK added to enum vcl_event_e
* 20.0 (2024-09-13)
* struct vrt_backend.backend_wait_timeout added
* struct vrt_backend.backend_wait_limit added
Expand Down Expand Up @@ -493,14 +495,16 @@ struct vmod_data {
};

/***********************************************************************
* VCL events sent to VMODs
* VCL events sent to VMODs and directors
*/

enum vcl_event_e {
VCL_EVENT_LOAD,
VCL_EVENT_WARM,
VCL_EVENT_COLD,
VCL_EVENT_DISCARD,
// Only for directors
VDI_EVENT_SICK,
};

typedef int vmod_event_f(VRT_CTX, struct vmod_priv *, enum vcl_event_e);
Expand Down

0 comments on commit 60dd259

Please sign in to comment.