Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
varnish-cache
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
varnishcache
varnish-cache
Commits
f9b7f181
Commit
f9b7f181
authored
Dec 26, 2019
by
Dridi Boukelmoune
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add coverage for backend creation in a cold VCL
Refs #3176
parent
a4539949
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
58 additions
and
7 deletions
+58
-7
v00063.vtc
bin/varnishtest/tests/v00063.vtc
+20
-0
vmod.vcc
lib/libvmod_debug/vmod.vcc
+6
-2
vmod_debug.c
lib/libvmod_debug/vmod_debug.c
+32
-5
No files found.
bin/varnishtest/tests/v00063.vtc
0 → 100644
View file @
f9b7f181
varnishtest "Create a backend after a COLD event"
server s1 -start
varnish v1 -cliok "param.set feature +no_coredump"
varnish v1 -expectexit 0x20
varnish v1 -vcl+backend {
import debug;
sub vcl_init {
debug.cold_backend();
}
} -start
# load and use a new VCL
varnish v1 -vcl+backend {}
# expect a panic during the COLD event
varnish v1 -clierr 400 "vcl.state vcl1 cold"
varnish v1 -cliexpect "Dynamic Backends can only be added to warm VCLs" panic.show
varnish v1 -cliok panic.clear
lib/libvmod_debug/vmod.vcc
View file @
f9b7f181
...
...
@@ -247,11 +247,15 @@ should now only be used for diagnostic purposes.
$Function VOID vcl_prevent_cold(PRIV_VCL)
Prevent VCL from going cold
Prevent VCL from going cold
.
$Function VOID vcl_allow_cold(PRIV_VCL)
Allow VCL to go cold
Allow VCL to go cold.
$Function VOID cold_backend(PRIV_VCL)
Schedule a backend creation attempt when the VCL cools down, panic guaranteed.
$Function VOID sndbuf(BYTES sndbuf)
...
...
lib/libvmod_debug/vmod_debug.c
View file @
f9b7f181
...
...
@@ -51,6 +51,7 @@ struct priv_vcl {
struct
vclref
*
vclref_cold
;
VCL_DURATION
vcl_discard_delay
;
VCL_BACKEND
be
;
unsigned
cold_be
;
};
...
...
@@ -385,6 +386,8 @@ xyzzy_vcl_prevent_cold(VRT_CTX, struct vmod_priv *priv)
struct
priv_vcl
*
priv_vcl
;
char
buf
[
32
];
CHECK_OBJ_NOTNULL
(
ctx
,
VRT_CTX_MAGIC
);
AN
(
priv
);
CAST_OBJ_NOTNULL
(
priv_vcl
,
priv
->
priv
,
PRIV_VCL_MAGIC
);
AZ
(
priv_vcl
->
vclref_cold
);
...
...
@@ -397,13 +400,24 @@ xyzzy_vcl_allow_cold(VRT_CTX, struct vmod_priv *priv)
{
struct
priv_vcl
*
priv_vcl
;
(
void
)
ctx
;
CHECK_OBJ_NOTNULL
(
ctx
,
VRT_CTX_MAGIC
)
;
AN
(
priv
);
CAST_OBJ_NOTNULL
(
priv_vcl
,
priv
->
priv
,
PRIV_VCL_MAGIC
);
AN
(
priv_vcl
->
vclref_cold
);
VRT_VCL_Allow_Cold
(
&
priv_vcl
->
vclref_cold
);
}
VCL_VOID
xyzzy_cold_backend
(
VRT_CTX
,
struct
vmod_priv
*
priv
)
{
struct
priv_vcl
*
priv_vcl
;
CHECK_OBJ_NOTNULL
(
ctx
,
VRT_CTX_MAGIC
);
AN
(
priv
);
CAST_OBJ_NOTNULL
(
priv_vcl
,
priv
->
priv
,
PRIV_VCL_MAGIC
);
priv_vcl
->
cold_be
=
1
;
}
static
const
struct
vdi_methods
empty_methods
[
1
]
=
{{
.
magic
=
VDI_METHODS_MAGIC
,
.
type
=
"debug.dummy"
...
...
@@ -426,8 +440,11 @@ event_warm(VRT_CTX, const struct vmod_priv *priv)
CAST_OBJ_NOTNULL
(
priv_vcl
,
priv
->
priv
,
PRIV_VCL_MAGIC
);
AZ
(
priv_vcl
->
vclref_discard
);
bprintf
(
buf
,
"vmod-debug ref on %s"
,
VCL_Name
(
ctx
->
vcl
));
priv_vcl
->
vclref_discard
=
VRT_VCL_Prevent_Discard
(
ctx
,
buf
);
if
(
!
priv_vcl
->
cold_be
)
{
/* NB: set up a COOLING step unless we want a COLD backend. */
bprintf
(
buf
,
"vmod-debug ref on %s"
,
VCL_Name
(
ctx
->
vcl
));
priv_vcl
->
vclref_discard
=
VRT_VCL_Prevent_Discard
(
ctx
,
buf
);
}
AZ
(
priv_vcl
->
be
);
priv_vcl
->
be
=
VRT_AddDirector
(
ctx
,
empty_methods
,
...
...
@@ -454,15 +471,25 @@ event_cold(VRT_CTX, const struct vmod_priv *priv)
{
pthread_t
thread
;
struct
priv_vcl
*
priv_vcl
;
struct
vrt_backend
be
[
1
];
CAST_OBJ_NOTNULL
(
priv_vcl
,
priv
->
priv
,
PRIV_VCL_MAGIC
);
AN
(
priv_vcl
->
vclref_discard
);
VSL
(
SLT_Debug
,
0
,
"%s: VCL_EVENT_COLD"
,
VCL_Name
(
ctx
->
vcl
));
VRT_DelDirector
(
&
priv_vcl
->
be
);
if
(
priv_vcl
->
cold_be
)
{
AZ
(
priv_vcl
->
vclref_discard
);
INIT_OBJ
(
be
,
VRT_BACKEND_MAGIC
);
be
->
path
=
"/"
;
be
->
vcl_name
=
"doomed"
;
priv_vcl
->
be
=
VRT_new_backend
(
ctx
,
be
);
WRONG
(
"unreachable"
);
}
if
(
priv_vcl
->
vcl_discard_delay
==
0
.
0
)
{
AN
(
priv_vcl
->
vclref_discard
);
VRT_VCL_Allow_Discard
(
&
priv_vcl
->
vclref_discard
);
return
(
0
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment