[6.0] e8e4d4890 no implicit warmup for manual temperature control

Dridi Boukelmoune dridi.boukelmoune at gmail.com
Thu Dec 19 18:25:07 UTC 2019


commit e8e4d48906aac5ec8c8394d07f3e0ad2b2952aa6
Author: Nils Goroll <nils.goroll at uplex.de>
Date:   Mon Nov 19 14:45:26 2018 +0100

    no implicit warmup for manual temperature control
    
    As discussed during bugwash, we should be consistent about the manual
    temperature controls and not transition cold->warm, but rather fail.

diff --git a/bin/varnishd/mgt/mgt_vcl.c b/bin/varnishd/mgt/mgt_vcl.c
index de8513c55..049cee5af 100644
--- a/bin/varnishd/mgt/mgt_vcl.c
+++ b/bin/varnishd/mgt/mgt_vcl.c
@@ -463,6 +463,18 @@ mgt_vcl_settemp(struct cli *cli, struct vclprog *vp, unsigned warm)
 	return (i);
 }
 
+static int
+mgt_vcl_requirewarm(struct cli *cli, struct vclprog *vp)
+{
+	if (vp->state == VCL_STATE_COLD) {
+		VCLI_SetResult(cli, CLIS_CANT);
+		VCLI_Out(cli, "VCL '%s' is cold - set to auto or warm first",
+		    vp->name);
+		return (1);
+	}
+	return (mgt_vcl_settemp(cli, vp, 1));
+}
+
 static int
 mgt_vcl_tellchild(struct cli *cli, struct vclprog *vp, unsigned warm)
 {
@@ -764,7 +776,7 @@ mcf_vcl_use(struct cli *cli, const char * const *av, void *priv)
 	if (vp == active_vcl)
 		return;
 
-	if (mgt_vcl_settemp(cli, vp, 1))
+	if (mgt_vcl_requirewarm(cli, vp))
 		return;
 
 	if (MCH_Running() &&
@@ -975,10 +987,13 @@ mcf_vcl_label(struct cli *cli, const char * const *av, void *priv)
 		}
 	}
 
-	if (mgt_vcl_settemp(cli, vpt, 1))
+	if (mgt_vcl_requirewarm(cli, vpt))
 		return;
 
 	if (vpl != NULL) {
+		/* potentially fail before we delete the dependency */
+		if (mgt_vcl_requirewarm(cli, vpl))
+			return;
 		mgt_vcl_dep_del(VTAILQ_FIRST(&vpl->dfrom));
 		AN(VTAILQ_EMPTY(&vpl->dfrom));
 	} else {
@@ -986,7 +1001,7 @@ mcf_vcl_label(struct cli *cli, const char * const *av, void *priv)
 	}
 
 	AN(vpl);
-	if (mgt_vcl_settemp(cli, vpl, 1))
+	if (mgt_vcl_requirewarm(cli, vpl))
 		return;
 	mgt_vcl_dep_add(vpl, vpt);
 
diff --git a/bin/varnishtest/tests/v00003.vtc b/bin/varnishtest/tests/v00003.vtc
index 2dcd423e6..a1ac35fc9 100644
--- a/bin/varnishtest/tests/v00003.vtc
+++ b/bin/varnishtest/tests/v00003.vtc
@@ -48,7 +48,10 @@ varnish v1 -cliexpect "available *cold/cold *[0-9]+ *vcl1\\s+active *auto/warm *
 delay .4
 varnish v1 -expect !VBE.vcl1.default.happy
 
-# Use it, and it should come warm (but not auto)
+# Manual temperature control needs to be explicit before use
+varnish v1 -clierr 300 "vcl.use vcl1"
+
+varnish v1 -cliok "vcl.state vcl1 warm"
 varnish v1 -cliok "vcl.use vcl1"
 varnish v1 -cliexpect "active *warm/warm *[0-9]+ *vcl1\\s+available *auto/warm *[0-9]+ *vcl2" "vcl.list"
 delay .4


More information about the varnish-commit mailing list