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
31cecd8a
Commit
31cecd8a
authored
Feb 20, 2019
by
Nils Goroll
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add a switch to always go to the real backend
This is useful for VCL simplification
parent
eb36c34f
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
98 additions
and
1 deletion
+98
-1
Makefile.am
src/Makefile.am
+1
-0
vmod_cluster.c
src/vmod_cluster.c
+16
-1
vmod_cluster.vcc
src/vmod_cluster.vcc
+15
-0
direct.vtc
src/vtc/direct.vtc
+66
-0
No files found.
src/Makefile.am
View file @
31cecd8a
...
...
@@ -30,6 +30,7 @@ TESTS = \
vtc/cfg.vtc
\
vtc/deep.vtc
\
vtc/deep_stk.vtc
\
vtc/direct.vtc
\
vtc/shallow.vtc
\
vtc/lazy.vtc
\
vtc/lazy_shard.vtc
...
...
src/vmod_cluster.c
View file @
31cecd8a
...
...
@@ -83,6 +83,7 @@ struct vmod_cluster_cluster_param {
unsigned
magic
;
#define VMOD_CLUSTER_CLUSTER_PARAM_MAGIC 0x3ba2a0d5
VCL_BOOL
uncacheable_direct
;
VCL_BOOL
direct
;
VCL_BACKEND
cluster
;
VCL_BACKEND
real
;
int
nblack
;
...
...
@@ -439,6 +440,19 @@ vmod_cluster_get_uncacheable_direct(VRT_CTX, struct vmod_cluster_cluster *vc)
CLUSTER_R
(
ctx
,
vc
,
uncacheable_direct
,
0
);
}
VCL_VOID
vmod_cluster_set_direct
(
VRT_CTX
,
struct
vmod_cluster_cluster
*
vc
,
VCL_BOOL
bool
)
{
CLUSTER_L
(
ctx
,
vc
,
direct
,
bool
);
}
VCL_BOOL
vmod_cluster_get_direct
(
VRT_CTX
,
struct
vmod_cluster_cluster
*
vc
)
{
CLUSTER_R
(
ctx
,
vc
,
direct
,
0
);
}
static
inline
VCL_BACKEND
by_resolve
(
VRT_CTX
,
VCL_BACKEND
r
,
enum
resolve_e
resolve
)
{
...
...
@@ -458,7 +472,8 @@ cluster_resolve(VRT_CTX,
{
VCL_BACKEND
r
;
if
(
pr
->
uncacheable_direct
&&
ctx
->
bo
&&
if
(
pr
->
direct
||
pr
->
uncacheable_direct
&&
ctx
->
bo
&&
(
ctx
->
bo
->
do_pass
||
ctx
->
bo
->
uncacheable
))
return
(
by_resolve
(
ctx
,
pr
->
real
,
resolve
));
...
...
src/vmod_cluster.vcc
View file @
31cecd8a
...
...
@@ -172,6 +172,21 @@ Return the currently configured behaviour.
See :ref:`meth_ctx` for limitations.
$Method VOID .set_direct(BOOL)
A ``true`` argument instructs the director to select a `real` backend
always.
A ``false`` argument restores the original behavior.
See :ref:`meth_ctx` for limitations.
$Method BOOL .get_direct()
Return the current `direct` value as set with :ref:`func_cluster.get_direct`.
See :ref:`meth_ctx` for limitations.
$Method BACKEND .backend(ENUM {LAZY, SHALLOW, DEEP, NOW} resolve=LAZY,
[ BACKEND deny ], [ BACKEND real ],
[ BOOL uncacheable_direct ])
...
...
src/vtc/direct.vtc
0 → 100644
View file @
31cecd8a
varnishtest "vmod_cluster test shard director layering and backend.list"
server s1 {
} -start
server s2 {
}
server s3 -repeat 2 -keepalive {
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);
cl.set_uncacheable_direct(false);
}
sub vcl_recv {
return (pass);
}
sub vcl_backend_fetch {
set bereq.http.shard = shard.backend();
set bereq.http.unc = cl.get_uncacheable_direct();
set bereq.http.dir1 = cl.get_direct();
cl.set_direct(bereq.http.shard != "s2");
set bereq.backend = cl.backend();
set bereq.http.dir2 = cl.get_direct();
}
sub vcl_backend_response {
set beresp.http.shard = bereq.http.shard;
set beresp.http.unc = bereq.http.unc;
set beresp.http.backend = beresp.backend;
set beresp.http.dir1 = bereq.http.dir1;
set beresp.http.dir2 = bereq.http.dir2;
}
} -start
varnish v1 -cliexpect "shard.*healthy" "backend.list"
varnish v1 -cliexpect "cl.*healthy" "backend.list"
client c1 {
txreq
rxresp
expect resp.status == 200
expect resp.http.unc == "false"
expect resp.http.shard == "s2"
expect resp.http.backend == "s3"
expect resp.http.dir1 == "false"
expect resp.http.dir2 == "false"
txreq -url "/foo"
rxresp
expect resp.status == 200
expect resp.http.unc == "false"
expect resp.http.shard == "s1"
expect resp.http.backend == "s3"
expect resp.http.dir1 == "false"
expect resp.http.dir2 == "true"
} -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