[master] 82d8153af use 0/0 healthy for "no probe" in the probe field

Nils Goroll nils.goroll at uplex.de
Tue Mar 5 11:09:03 UTC 2019


commit 82d8153afb50928ba54f4152fd095f6fa3051c64
Author: Nils Goroll <nils.goroll at uplex.de>
Date:   Mon Mar 4 18:18:23 2019 +0100

    use 0/0 healthy for "no probe" in the probe field
    
    Add another column for the probe result
    
    Ref #2896

diff --git a/bin/varnishd/cache/cache_backend.c b/bin/varnishd/cache/cache_backend.c
index d553d0317..2ba8e0a89 100644
--- a/bin/varnishd/cache/cache_backend.c
+++ b/bin/varnishd/cache/cache_backend.c
@@ -461,12 +461,11 @@ vbe_list(VRT_CTX, const struct director *d, struct vsb *vsb, int pflag,
 	else if (jflag && pflag)
 		VSB_printf(vsb, "{},\n");
 	else if (jflag)
-		VSB_printf(vsb, "\"%s\"", bp->sick ? "sick" : "healthy");
+		VSB_printf(vsb, "[0, 0, \"healthy\"]");
 	else if (pflag)
 		return;
 	else
-		VSB_printf(vsb, "%s",
-		    bp->sick ? "sick" : "healthy");
+		VSB_cat(vsb, "0/0\thealthy");
 }
 
 /*--------------------------------------------------------------------
diff --git a/bin/varnishd/cache/cache_backend_probe.c b/bin/varnishd/cache/cache_backend_probe.c
index ba8316162..94757a6b3 100644
--- a/bin/varnishd/cache/cache_backend_probe.c
+++ b/bin/varnishd/cache/cache_backend_probe.c
@@ -519,7 +519,7 @@ VBP_Status(struct vsb *vsb, const struct backend *be, int details, int json)
 			    vt->good, vt->window,
 			    vt->backend->sick ? "sick" : "healthy");
 		else
-			VSB_printf(vsb, "%u/%u %s", vt->good, vt->window,
+			VSB_printf(vsb, "%u/%u\t%s", vt->good, vt->window,
 			    vt->backend->sick ? "sick" : "healthy");
 		return;
 	}
diff --git a/bin/varnishd/cache/cache_director.c b/bin/varnishd/cache/cache_director.c
index 345402798..423eb0550 100644
--- a/bin/varnishd/cache/cache_director.c
+++ b/bin/varnishd/cache/cache_director.c
@@ -327,13 +327,14 @@ do_list(struct cli *cli, struct director *d, void *priv)
 
 	ctx = VCL_Get_CliCtx(0);
 
-	// XXX admin health "probe" for the no-probe case is confusing
 	VSB_printf(la->vsb, "%s\t%s\t", d->vdir->cli_name, VDI_Ahealth(d));
 
 	if (d->vdir->methods->list != NULL)
 		d->vdir->methods->list(ctx, d, la->vsb, 0, 0);
+	else if (d->vdir->methods->healthy != NULL)
+		VSB_printf(la->vsb, "0/0\t%s", cli_health(ctx, d));
 	else
-		VSB_printf(la->vsb, "%s", cli_health(ctx, d));
+		VSB_cat(la->vsb, "0/0\thealthy");
 
 	VTIM_format(d->vdir->health_changed, time_str);
 	VSB_printf(la->vsb, "\t%s", time_str);
@@ -372,8 +373,11 @@ do_list_json(struct cli *cli, struct director *d, void *priv)
 	VCLI_Out(cli, "\"probe_message\": ");
 	if (d->vdir->methods->list != NULL)
 		d->vdir->methods->list(ctx, d, cli->sb, 0, 1);
+	else if (d->vdir->methods->healthy != NULL)
+		VCLI_Out(cli, "[0, 0, \"%s\"]", cli_health(ctx, d));
 	else
-		VCLI_Out(cli, "\"%s\"", cli_health(ctx, d));
+		VCLI_Out(cli, "[0, 0, \"healthy\"]");
+
 	VCLI_Out(cli, ",\n");
 
 	if (la->p && d->vdir->methods->list != NULL) {
@@ -431,8 +435,8 @@ cli_backend_list(struct cli *cli, const char * const *av, void *priv)
 	} else {
 		la->vsb = VSB_new_auto();
 		AN(la->vsb);
-		VSB_printf(la->vsb, "%s\t%s\t%s\t%s\n",
-		    "Backend name", "Admin", "Probe", "Last change");
+		VSB_printf(la->vsb, "%s\t%s\t%s\t%s\t%s\n",
+		    "Backend name", "Admin", "Probe", "Health", "Last change");
 		(void)VCL_IterDirector(cli, av[i], do_list, la);
 		VCLI_VTE(cli, &la->vsb, 80);
 	}
diff --git a/lib/libvmod_directors/vdir.c b/lib/libvmod_directors/vdir.c
index 58b8b8dcc..323b155f3 100644
--- a/lib/libvmod_directors/vdir.c
+++ b/lib/libvmod_directors/vdir.c
@@ -259,7 +259,7 @@ vdir_list(VRT_CTX, struct vdir *vd, struct vsb *vsb, int pflag, int jflag)
 		VSB_printf(vsb, "[%u, %u, \"%s\"]", nh, u,
 		    nh ? "healthy" : "sick");
 	else
-		VSB_printf(vsb, "%u/%u %s", nh, u, nh ? "healthy" : "sick");
+		VSB_printf(vsb, "%u/%u\t%s", nh, u, nh ? "healthy" : "sick");
 }
 
 static unsigned


More information about the varnish-commit mailing list