[master] adf18f4df no implicit warmup for manual temperature control
Poul-Henning Kamp
phk at FreeBSD.org
Fri May 3 06:48:08 UTC 2019
commit adf18f4df2aaae0701ab2ddc04ca518e71c68a55
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 f54a9beff..ca45018a0 100644
--- a/bin/varnishd/mgt/mgt_vcl.c
+++ b/bin/varnishd/mgt/mgt_vcl.c
@@ -468,6 +468,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)
{
@@ -783,7 +795,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() &&
@@ -999,10 +1011,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 {
@@ -1010,7 +1025,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 449356791..4a8d15898 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