[master] c6e4b2807 Add an event for directors going sick

Nils Goroll nils.goroll at uplex.de
Mon Sep 30 14:06:05 UTC 2024


commit c6e4b2807afae3ef8d4f62d8ca83c082b61eef4a
Author: Nils Goroll <nils.goroll at uplex.de>
Date:   Mon Sep 23 19:19:10 2024 +0200

    Add an event for directors going sick
    
    Pondering solutions for #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.

diff --git a/bin/varnishd/cache/cache_backend.c b/bin/varnishd/cache/cache_backend.c
index 922a4bb13..99d10ed70 100644
--- a/bin/varnishd/cache/cache_backend.c
+++ b/bin/varnishd/cache/cache_backend.c
@@ -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);
 	}
 }
 
@@ -677,7 +682,6 @@ vbe_healthy(VRT_CTX, VCL_BACKEND d, VCL_TIME *t)
 	return (!bp->sick);
 }
 
-
 /*--------------------------------------------------------------------
  */
 
diff --git a/include/vrt.h b/include/vrt.h
index 144a7e2ed..13c93be12 100644
--- a/include/vrt.h
+++ b/include/vrt.h
@@ -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.
@@ -58,6 +58,8 @@
  * binary/load-time compatible, increment MAJOR version
  *
  * NEXT (2024-03-15)
+ * 20.1
+ *	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
@@ -494,7 +496,7 @@ struct vmod_data {
 };
 
 /***********************************************************************
- * VCL events sent to VMODs
+ * VCL events sent to VMODs and directors
  */
 
 enum vcl_event_e {
@@ -502,6 +504,8 @@ enum vcl_event_e {
 	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);


More information about the varnish-commit mailing list