Add onerror_continue parameter to pretend onerror="continue" was set

With this change,

	pesi.set(onerror_continue, true);

can be used to restore behavior from before varnish-cache 7.3.

See pesi.set() documentation for details.

The test case is a modified version of the one by Geoff Simmons posted
in https://github.com/varnishcache/varnish-cache/issues/4053#issuecomment-1936000064
parent da4ad0f1
...@@ -2,10 +2,12 @@ ...@@ -2,10 +2,12 @@
/* vcl-controlled flags */ /* vcl-controlled flags */
#define PF_CFG_SERIAL (1U<<1) #define PF_CFG_SERIAL (1U<<1)
#define PF_CFG_THREAD (1U<<2) #define PF_CFG_THREAD (1U<<2)
#define PF_CFG_ONERROR_CONTINUE (1U<<3)
#define PF_CFG_DEFAULT PF_CFG_THREAD #define PF_CFG_DEFAULT PF_CFG_THREAD
#define PF_MASK_CFG \ #define PF_MASK_CFG \
( PF_CFG_SERIAL \ ( PF_CFG_SERIAL \
| PF_CFG_THREAD \ | PF_CFG_THREAD \
| PF_CFG_ONERROR_CONTINUE \
) )
VMODENUM(serial, PF_CFG_SERIAL) VMODENUM(serial, PF_CFG_SERIAL)
VMODENUM(thread, PF_CFG_THREAD) VMODENUM(thread, PF_CFG_THREAD)
VMODENUM(onerror_continue, PF_CFG_ONERROR_CONTINUE)
#undef VMODENUM #undef VMODENUM
varnishtest "Parent ESI fails despite setting ESP resp.status = 200"
server s1 {
rxreq
expect req.url == "/abort"
txresp -hdr {surrogate-control: content="ESI/1.0"} \
-body {before <esi:include src="/fail"/> after}
rxreq
expect req.url == "/fail"
txresp -hdr "content-length: 100" -nolen
delay 0.1
} -start
varnish v1 -cliok "param.set feature +esi_disable_xml_check"
## Doesn't matter whether this is turned on.
# varnish v1 -cliok "param.set feature +esi_include_onerror"
varnish v1 -vcl+backend {
import ${vmod_pesi};
import ${vmod_pesi_debug};
include "debug.inc.vcl";
sub vcl_backend_response {
# Prevent cache hits in the next tests.
set beresp.uncacheable = true;
set beresp.do_esi = beresp.http.surrogate-control ~ "ESI/1.0";
unset beresp.http.surrogate-control;
}
sub vcl_deliver {
pesi.activate();
pesi.set(onerror_continue, true);
}
} -start
client c1 {
txreq -url "/abort"
non_fatal
rxresp
expect resp.body == "before after"
} -run
server s1 -wait
server s1 -start
varnish v1 -vcl+backend {
import ${vmod_pesi};
import ${vmod_pesi_debug};
include "debug.inc.vcl";
sub vcl_backend_error {
set beresp.body = "GURU";
return (deliver);
}
sub vcl_backend_response {
# Prevent cache hits in the next tests.
set beresp.uncacheable = true;
set beresp.do_esi = beresp.http.surrogate-control ~ "ESI/1.0";
set beresp.do_stream = false;
}
sub vcl_deliver {
pesi.activate();
pesi.set(onerror_continue, true);
}
}
client c1 {
txreq -url "/abort"
non_fatal
rxresp
expect resp.body == "before GURU after"
} -run
server s1 -wait
...@@ -856,7 +856,7 @@ vdp_pesi_bytes(struct vdp_ctx *vdx, enum vdp_action act, void **priv, ...@@ -856,7 +856,7 @@ vdp_pesi_bytes(struct vdp_ctx *vdx, enum vdp_action act, void **priv,
struct nexus_gzip *parent_gzip = NULL; struct nexus_gzip *parent_gzip = NULL;
struct bytes_tree *tree; struct bytes_tree *tree;
struct node *node, *child = NULL; struct node *node, *child = NULL;
int incl_cont, retval = 0, parallel; int incl_cont, incl_cont_override, retval = 0, parallel;
CHECK_OBJ_NOTNULL(vdx, VDP_CTX_MAGIC); CHECK_OBJ_NOTNULL(vdx, VDP_CTX_MAGIC);
...@@ -899,6 +899,8 @@ vdp_pesi_bytes(struct vdp_ctx *vdx, enum vdp_action act, void **priv, ...@@ -899,6 +899,8 @@ vdp_pesi_bytes(struct vdp_ctx *vdx, enum vdp_action act, void **priv,
if (node->parent != NULL && node->parent->nexus.gzip.is) if (node->parent != NULL && node->parent->nexus.gzip.is)
parent_gzip = &node->parent->nexus.gzip; parent_gzip = &node->parent->nexus.gzip;
incl_cont_override = (pesi->flags & PF_CFG_ONERROR_CONTINUE) != 0;
pp = ptr; pp = ptr;
while (retval == 0 && tree->retval == 0) { while (retval == 0 && tree->retval == 0) {
incl_cont = 0; incl_cont = 0;
...@@ -991,6 +993,8 @@ vdp_pesi_bytes(struct vdp_ctx *vdx, enum vdp_action act, void **priv, ...@@ -991,6 +993,8 @@ vdp_pesi_bytes(struct vdp_ctx *vdx, enum vdp_action act, void **priv,
T_NEXUS, ST_PRIVATE); T_NEXUS, ST_PRIVATE);
CHECK_OBJ_NOTNULL(child, NODE_MAGIC); CHECK_OBJ_NOTNULL(child, NODE_MAGIC);
incl_cont |= incl_cont_override;
VSLdbgv(vdx, "vped_vdp: call vped_include " VSLdbgv(vdx, "vped_vdp: call vped_include "
"incl_cont=%d", incl_cont); "incl_cont=%d", incl_cont);
parallel = parallel =
......
...@@ -205,7 +205,7 @@ Example:: ...@@ -205,7 +205,7 @@ Example::
pesi.activate() pesi.activate()
} }
$Function VOID set(ENUM { serial, thread } parameter, [BOOL bool]) $Function VOID set(ENUM { serial, thread, onerror_continue } parameter, [BOOL bool])
Set a configuration parameter for the VDP, which holds for the current Set a configuration parameter for the VDP, which holds for the current
(sub)request, as documented below. The parameter to be set is (sub)request, as documented below. The parameter to be set is
...@@ -215,7 +215,8 @@ this function may allow for setting other data types). ...@@ -215,7 +215,8 @@ this function may allow for setting other data types).
$Restrict vcl_deliver $Restrict vcl_deliver
The parameters that can be set are currently ``serial`` and ``thread``: The parameters that can be set are currently ``serial``, ``thread``
and ``onerror_continue``.
``serial`` ``serial``
---------- ----------
...@@ -276,6 +277,27 @@ Whether we always request a new thread for includes, default is ...@@ -276,6 +277,27 @@ Whether we always request a new thread for includes, default is
See the detailled discussion in `THREADS`_ for details. See the detailled discussion in `THREADS`_ for details.
``onerror_continue``
--------------------
If set to ``true``, makes pESI processing behave as if the
``onerror="continue"`` attribute was set for all includes of the
current object. The default is ``false``.
.. _VC#4053: https://github.com/varnishcache/varnish-cache/issues/4053
Issue `VC#4053`_ documents a challenge caused by the changed behavior
with respect to (lack of) the ``onerror="continue"`` attribute, where
additional complications in VCL are required to restore the behavior
from before Varnish-Cache 7.3.
With this parameter set to ``true``, pESI behaves as if all includes
of the currently processed objects had the ``onerror="continue"``
attribute set.
This parameter should be considered transitional until a generic
solution is established for Varnish-Cache.
$Function VOID workspace_prealloc(BYTES min_free=4096, INT max_nodes=32) $Function VOID workspace_prealloc(BYTES min_free=4096, INT max_nodes=32)
Configure the maximum amount of workspace used for pesi internal data Configure the maximum amount of workspace used for pesi internal data
......
...@@ -196,8 +196,15 @@ Example:: ...@@ -196,8 +196,15 @@ Example::
.. _pesi.set(): .. _pesi.set():
VOID set(ENUM {serial, thread} parameter, [BOOL bool]) VOID set(ENUM parameter, [BOOL bool])
------------------------------------------------------ -------------------------------------
::
VOID set(
ENUM {serial, thread, onerror_continue} parameter,
[BOOL bool]
)
Set a configuration parameter for the VDP, which holds for the current Set a configuration parameter for the VDP, which holds for the current
(sub)request, as documented below. The parameter to be set is (sub)request, as documented below. The parameter to be set is
...@@ -207,7 +214,8 @@ this function may allow for setting other data types). ...@@ -207,7 +214,8 @@ this function may allow for setting other data types).
Restricted to: ``vcl_deliver``. Restricted to: ``vcl_deliver``.
The parameters that can be set are currently ``serial`` and ``thread``: The parameters that can be set are currently ``serial``, ``thread``
and ``onerror_continue``.
``serial`` ``serial``
---------- ----------
...@@ -268,6 +276,27 @@ Whether we always request a new thread for includes, default is ...@@ -268,6 +276,27 @@ Whether we always request a new thread for includes, default is
See the detailled discussion in `THREADS`_ for details. See the detailled discussion in `THREADS`_ for details.
``onerror_continue``
--------------------
If set to ``true``, makes pESI processing behave as if the
``onerror="continue"`` attribute was set for all includes of the
current object. The default is ``false``.
.. _VC#4053: https://github.com/varnishcache/varnish-cache/issues/4053
Issue `VC#4053`_ documents a challenge caused by the changed behavior
with respect to (lack of) the ``onerror="continue"`` attribute, where
additional complications in VCL are required to restore the behavior
from before Varnish-Cache 7.3.
With this parameter set to ``true``, pESI behaves as if all includes
of the currently processed objects had the ``onerror="continue"``
attribute set.
This parameter should be considered transitional until a generic
solution is established for Varnish-Cache.
.. _pesi.workspace_prealloc(): .. _pesi.workspace_prealloc():
VOID workspace_prealloc(BYTES min_free, INT max_nodes) VOID workspace_prealloc(BYTES min_free, INT max_nodes)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment