Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
libvmod-cluster
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
uplex-varnish
libvmod-cluster
Commits
7791a8ad
Commit
7791a8ad
authored
Feb 06, 2019
by
Nils Goroll
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
the healthy callback should not resolve in cli context
parent
ec231cbb
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
85 additions
and
5 deletions
+85
-5
Makefile.am
src/Makefile.am
+5
-4
vmod_cluster.c
src/vmod_cluster.c
+20
-1
lazy_shard.vtc
src/vtc/lazy_shard.vtc
+60
-0
No files found.
src/Makefile.am
View file @
7791a8ad
...
...
@@ -30,7 +30,8 @@ TESTS = \
vtc/deep.vtc
\
vtc/deep_stk.vtc
\
vtc/shallow.vtc
\
vtc/lazy.vtc
vtc/lazy.vtc
\
vtc/lazy_shard.vtc
# Documentation
...
...
src/vmod_cluster.c
View file @
7791a8ad
...
...
@@ -539,9 +539,28 @@ vmod_cluster_backend(VRT_CTX,
return
(
cluster_resolve
(
ctx
,
pr
,
resolve
));
}
/*
* layered directors may not be prepared to resolve outside a VCL task, so when
* called from the cli (no method, no vcl), just return health of the real
* backend
*/
static
VCL_BOOL
vmod_cluster_healthy
(
VRT_CTX
,
VCL_BACKEND
be
,
VCL_TIME
*
c
)
{
const
struct
vmod_cluster_cluster
*
vc
;
const
struct
vmod_cluster_cluster_param
*
p
;
if
(
ctx
->
vcl
&&
ctx
->
method
)
{
be
=
vmod_cluster_resolve
(
ctx
,
be
);
}
else
{
CAST_OBJ_NOTNULL
(
vc
,
be
->
priv
,
VMOD_CLUSTER_CLUSTER_MAGIC
);
p
=
vc
->
param
;
CHECK_OBJ_NOTNULL
(
p
,
VMOD_CLUSTER_CLUSTER_PARAM_MAGIC
);
be
=
p
->
real
;
}
return
VRT_Healthy
(
ctx
,
be
,
c
);
}
src/vtc/lazy_shard.vtc
0 → 100644
View file @
7791a8ad
varnishtest "vmod_cluster toy example with round-robin - lazy resolution"
server s1 {
rxreq
txresp
} -start
server s2 {
}
server s3 {
rxreq
txresp
} -start
varnish v1 -vcl+backend {
import cluster;
import directors;
sub vcl_init {
new shard = directors.shard();
shard.add_backend(s1);
shard.add_backend(s2);
shard.reconfigure();
new cl = cluster.cluster(shard.backend(), deny=s2, real=s3);
}
sub vcl_recv {
return (pass);
}
sub vcl_backend_fetch {
set bereq.http.shard = shard.backend();
set bereq.http.unc1 = cl.get_uncacheable_direct();
set bereq.backend = cl.backend(uncacheable_direct=false);
set bereq.http.unc2 = cl.get_uncacheable_direct();
}
sub vcl_backend_response {
set beresp.http.shard = bereq.http.shard;
set beresp.http.unc1 = bereq.http.unc1;
set beresp.http.backend = beresp.backend;
set beresp.http.unc2 = bereq.http.unc2;
}
} -start
varnish v1 -cliexpect "shard.*healthy" "backend.list"
client c1 {
txreq
rxresp
expect resp.status == 200
expect resp.http.unc1 == "true"
expect resp.http.shard == "s2"
expect resp.http.backend == "s3"
expect resp.http.unc2 == "false"
txreq -url "/foo"
rxresp
expect resp.status == 200
expect resp.http.unc1 == "true"
expect resp.http.backend == "s1"
expect resp.http.unc2 == "false"
} -run
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