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
579a1df9
Commit
579a1df9
authored
Apr 24, 2018
by
Poul-Henning Kamp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add a "list" method to directors, to participate in CLI::backend.list
Add a new -v flag, just because we can.
parent
47feebce
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
90 additions
and
63 deletions
+90
-63
cache_backend.c
bin/varnishd/cache/cache_backend.c
+18
-0
cache_backend.h
bin/varnishd/cache/cache_backend.h
+1
-1
cache_backend_probe.c
bin/varnishd/cache/cache_backend_probe.c
+29
-30
cache_director.c
bin/varnishd/cache/cache_director.c
+36
-30
cache_director.h
bin/varnishd/cache/cache_director.h
+4
-0
o00004.vtc
bin/varnishtest/tests/o00004.vtc
+2
-2
No files found.
bin/varnishd/cache/cache_backend.c
View file @
579a1df9
...
@@ -416,6 +416,23 @@ vbe_panic(const struct director *d, struct vsb *vsb)
...
@@ -416,6 +416,23 @@ vbe_panic(const struct director *d, struct vsb *vsb)
VSB_printf
(
vsb
,
"n_conn = %u,
\n
"
,
bp
->
n_conn
);
VSB_printf
(
vsb
,
"n_conn = %u,
\n
"
,
bp
->
n_conn
);
}
}
/*--------------------------------------------------------------------
*/
static
void
vbe_list
(
const
struct
director
*
d
,
struct
vsb
*
vsb
,
int
vflag
,
int
pflag
)
{
struct
backend
*
bp
;
CHECK_OBJ_NOTNULL
(
d
,
DIRECTOR_MAGIC
);
CAST_OBJ_NOTNULL
(
bp
,
d
->
priv
,
BACKEND_MAGIC
);
if
(
bp
->
probe
!=
NULL
)
VBP_Status
(
vsb
,
bp
,
vflag
|
pflag
);
else
VSB_printf
(
vsb
,
"%-10s"
,
d
->
health
?
"healthy"
:
"sick"
);
}
/*--------------------------------------------------------------------
/*--------------------------------------------------------------------
* Create a new static or dynamic director::backend instance.
* Create a new static or dynamic director::backend instance.
*/
*/
...
@@ -473,6 +490,7 @@ VRT_new_backend_clustered(VRT_CTX, struct vsmw_cluster *vc,
...
@@ -473,6 +490,7 @@ VRT_new_backend_clustered(VRT_CTX, struct vsmw_cluster *vc,
d
->
finish
=
vbe_dir_finish
;
d
->
finish
=
vbe_dir_finish
;
d
->
event
=
vbe_dir_event
;
d
->
event
=
vbe_dir_event
;
d
->
panic
=
vbe_panic
;
d
->
panic
=
vbe_panic
;
d
->
list
=
vbe_list
;
d
->
destroy
=
vbe_destroy
;
d
->
destroy
=
vbe_destroy
;
d
->
health
=
1
;
d
->
health
=
1
;
...
...
bin/varnishd/cache/cache_backend.h
View file @
579a1df9
...
@@ -81,4 +81,4 @@ void VBP_Insert(struct backend *b, struct vrt_backend_probe const *p,
...
@@ -81,4 +81,4 @@ void VBP_Insert(struct backend *b, struct vrt_backend_probe const *p,
struct
tcp_pool
*
);
struct
tcp_pool
*
);
void
VBP_Remove
(
struct
backend
*
b
);
void
VBP_Remove
(
struct
backend
*
b
);
void
VBP_Control
(
const
struct
backend
*
b
,
int
stop
);
void
VBP_Control
(
const
struct
backend
*
b
,
int
stop
);
void
VBP_Status
(
struct
cli
*
cli
,
const
struct
backend
*
,
int
details
);
void
VBP_Status
(
struct
vsb
*
,
const
struct
backend
*
,
int
details
);
bin/varnishd/cache/cache_backend_probe.c
View file @
579a1df9
...
@@ -168,9 +168,9 @@ vbp_update_backend(struct vbp_target *vt)
...
@@ -168,9 +168,9 @@ vbp_update_backend(struct vbp_target *vt)
assert
(
i
<
sizeof
bits
);
assert
(
i
<
sizeof
bits
);
if
(
vt
->
good
>=
vt
->
threshold
)
{
if
(
vt
->
good
>=
vt
->
threshold
)
{
if
(
vt
->
backend
->
director
->
health
)
if
(
vt
->
backend
->
director
->
health
)
{
logmsg
=
"Still healthy"
;
logmsg
=
"Still healthy"
;
else
{
}
else
{
logmsg
=
"Back healthy"
;
logmsg
=
"Back healthy"
;
vt
->
backend
->
director
->
health_changed
=
vt
->
backend
->
director
->
health_changed
=
VTIM_real
();
VTIM_real
();
...
@@ -181,8 +181,9 @@ vbp_update_backend(struct vbp_target *vt)
...
@@ -181,8 +181,9 @@ vbp_update_backend(struct vbp_target *vt)
logmsg
=
"Went sick"
;
logmsg
=
"Went sick"
;
vt
->
backend
->
director
->
health_changed
=
vt
->
backend
->
director
->
health_changed
=
VTIM_real
();
VTIM_real
();
}
else
}
else
{
logmsg
=
"Still sick"
;
logmsg
=
"Still sick"
;
}
vt
->
backend
->
director
->
health
=
0
;
vt
->
backend
->
director
->
health
=
0
;
}
}
VSL
(
SLT_Backend_health
,
0
,
"%s %s %s %u %u %u %.6f %.6f %s"
,
VSL
(
SLT_Backend_health
,
0
,
"%s %s %s %u %u %u %.6f %.6f %s"
,
...
@@ -458,58 +459,56 @@ vbp_thread(struct worker *wrk, void *priv)
...
@@ -458,58 +459,56 @@ vbp_thread(struct worker *wrk, void *priv)
*/
*/
static
void
static
void
vbp_bitmap
(
struct
cli
*
cli
,
char
c
,
uint64_t
map
,
const
char
*
lbl
)
vbp_bitmap
(
struct
vsb
*
vsb
,
char
c
,
uint64_t
map
,
const
char
*
lbl
)
{
{
int
i
;
int
i
;
uint64_t
u
=
(
1ULL
<<
63
);
uint64_t
u
=
(
1ULL
<<
63
);
V
CLI_Out
(
cli
,
" "
);
V
SB_printf
(
vsb
,
" "
);
for
(
i
=
0
;
i
<
64
;
i
++
)
{
for
(
i
=
0
;
i
<
64
;
i
++
)
{
if
(
map
&
u
)
if
(
map
&
u
)
V
CLI_Out
(
cli
,
"%c"
,
c
);
V
SB_putc
(
vsb
,
c
);
else
else
V
CLI_Out
(
cli
,
"-"
);
V
SB_putc
(
vsb
,
'-'
);
map
<<=
1
;
map
<<=
1
;
}
}
V
CLI_Out
(
cli
,
" %s
\n
"
,
lbl
);
V
SB_printf
(
vsb
,
" %s
\n
"
,
lbl
);
}
}
/*lint -e{506} constant value boolean */
/*lint -e{506} constant value boolean */
/*lint -e{774} constant value boolean */
/*lint -e{774} constant value boolean */
static
void
void
vbp_health_one
(
struct
cli
*
cli
,
const
struct
vbp_target
*
vt
)
VBP_Status
(
struct
vsb
*
vsb
,
const
struct
backend
*
be
,
int
details
)
{
{
struct
vbp_target
*
vt
;
char
buf
[
12
];
CHECK_OBJ_NOTNULL
(
be
,
BACKEND_MAGIC
);
vt
=
be
->
probe
;
CHECK_OBJ_NOTNULL
(
vt
,
VBP_TARGET_MAGIC
);
if
(
!
details
)
{
bprintf
(
buf
,
"%d/%d %s"
,
vt
->
good
,
vt
->
window
,
vt
->
backend
->
director
->
health
?
"good"
:
"bad"
);
VSB_printf
(
vsb
,
"%-10s"
,
buf
);
return
;
}
V
CLI_Out
(
cli
,
V
SB_printf
(
vsb
,
"
Current states good: %2u threshold: %2u window: %2u
\n
"
,
"
\n
Current states good: %2u threshold: %2u window: %2u
\n
"
,
vt
->
good
,
vt
->
threshold
,
vt
->
window
);
vt
->
good
,
vt
->
threshold
,
vt
->
window
);
V
CLI_Out
(
cli
,
V
SB_printf
(
vsb
,
" Average response time of good probes: %.6f
\n
"
,
vt
->
avg
);
" Average response time of good probes: %.6f
\n
"
,
vt
->
avg
);
V
CLI_Out
(
cli
,
V
SB_printf
(
vsb
,
" Oldest ======================"
" Oldest ======================"
"============================ Newest
\n
"
);
"============================ Newest
\n
"
);
#define BITMAP(n, c, t, b) \
#define BITMAP(n, c, t, b) \
if ((vt->n != 0) || (b)) \
if ((vt->n != 0) || (b)) \
vbp_bitmap(
cli
, (c), vt->n, (t));
vbp_bitmap(
vsb
, (c), vt->n, (t));
#include "tbl/backend_poll.h"
#include "tbl/backend_poll.h"
}
}
void
VBP_Status
(
struct
cli
*
cli
,
const
struct
backend
*
be
,
int
details
)
{
struct
vbp_target
*
vt
;
CHECK_OBJ_NOTNULL
(
be
,
BACKEND_MAGIC
);
vt
=
be
->
probe
;
CHECK_OBJ_NOTNULL
(
vt
,
VBP_TARGET_MAGIC
);
VCLI_Out
(
cli
,
"%d/%d"
,
vt
->
good
,
vt
->
window
);
if
(
details
)
{
VCLI_Out
(
cli
,
"
\n
"
);
vbp_health_one
(
cli
,
vt
);
}
}
/*--------------------------------------------------------------------
/*--------------------------------------------------------------------
* Build request from probe spec
* Build request from probe spec
*/
*/
...
...
bin/varnishd/cache/cache_director.c
View file @
579a1df9
...
@@ -38,7 +38,6 @@
...
@@ -38,7 +38,6 @@
#include "cache_varnishd.h"
#include "cache_varnishd.h"
#include "cache_director.h"
#include "cache_director.h"
#include "cache_backend.h"
#include "vcli_serve.h"
#include "vcli_serve.h"
#include "vtim.h"
#include "vtim.h"
...
@@ -279,62 +278,69 @@ VDI_Healthy(const struct director *d, double *changed)
...
@@ -279,62 +278,69 @@ VDI_Healthy(const struct director *d, double *changed)
/*---------------------------------------------------------------------*/
/*---------------------------------------------------------------------*/
struct
list_args
{
unsigned
magic
;
#define LIST_ARGS_MAGIC 0x7e7cefeb
int
p
;
int
v
;
};
static
int
v_matchproto_
(
vcl_be_func
)
static
int
v_matchproto_
(
vcl_be_func
)
do_list
(
struct
cli
*
cli
,
struct
director
*
d
,
void
*
priv
)
do_list
(
struct
cli
*
cli
,
struct
director
*
d
,
void
*
priv
)
{
{
int
*
probes
;
char
time_str
[
VTIM_FORMAT_SIZE
];
char
time_str
[
VTIM_FORMAT_SIZE
];
struct
backend
*
be
;
struct
list_args
*
la
;
AN
(
priv
);
CAST_OBJ_NOTNULL
(
la
,
priv
,
LIST_ARGS_MAGIC
);
probes
=
priv
;
CHECK_OBJ_NOTNULL
(
d
,
DIRECTOR_MAGIC
);
CHECK_OBJ_NOTNULL
(
d
,
DIRECTOR_MAGIC
);
CAST_OBJ_NOTNULL
(
be
,
d
->
priv
,
BACKEND_MAGIC
);
if
(
d
->
admin_health
==
VDI_AH_DELETED
)
if
(
d
->
admin_health
==
VDI_AH_DELETED
)
return
(
0
);
return
(
0
);
VCLI_Out
(
cli
,
"
\n
%-30s"
,
d
->
cli_name
);
VCLI_Out
(
cli
,
"
\n
%-30s %-7s "
,
d
->
cli_name
,
VDI_Ahealth
(
d
));
VCLI_Out
(
cli
,
" %-10s"
,
VDI_Ahealth
(
d
));
if
(
be
->
probe
==
NULL
)
if
(
d
->
list
!=
NULL
)
VCLI_Out
(
cli
,
" %-20s"
,
"Healthy (no probe)"
);
d
->
list
(
d
,
cli
->
sb
,
0
,
0
);
else
{
else
if
(
d
->
health
)
VCLI_Out
(
cli
,
"%-10s"
,
d
->
health
?
"healthy"
:
"sick"
);
VCLI_Out
(
cli
,
" %-20s"
,
"Healthy "
);
else
VCLI_Out
(
cli
,
" %-20s"
,
"Sick "
);
VBP_Status
(
cli
,
be
,
*
probes
);
}
VTIM_format
(
d
->
health_changed
,
time_str
);
VTIM_format
(
d
->
health_changed
,
time_str
);
VCLI_Out
(
cli
,
" %s"
,
time_str
);
VCLI_Out
(
cli
,
" %s"
,
time_str
);
if
(
la
->
p
||
la
->
v
)
d
->
list
(
d
,
cli
->
sb
,
la
->
p
,
la
->
v
);
return
(
0
);
return
(
0
);
}
}
static
void
v_matchproto_
(
cli_func_t
)
static
void
v_matchproto_
(
cli_func_t
)
cli_backend_list
(
struct
cli
*
cli
,
const
char
*
const
*
av
,
void
*
priv
)
cli_backend_list
(
struct
cli
*
cli
,
const
char
*
const
*
av
,
void
*
priv
)
{
{
int
probes
=
0
;
const
char
*
p
;
struct
list_args
la
[
1
];
(
void
)
priv
;
(
void
)
priv
;
ASSERT_CLI
();
ASSERT_CLI
();
if
(
av
[
2
]
!=
NULL
&&
!
strcmp
(
av
[
2
],
"-p"
))
{
INIT_OBJ
(
la
,
LIST_ARGS_MAGIC
);
while
(
av
[
2
]
!=
NULL
&&
av
[
2
][
0
]
==
'-'
)
{
for
(
p
=
av
[
2
]
+
1
;
*
p
;
p
++
)
{
switch
(
*
p
)
{
case
'p'
:
la
->
p
=
!
la
->
p
;
break
;
case
'v'
:
la
->
p
=
!
la
->
p
;
break
;
default:
VCLI_Out
(
cli
,
"Invalid flag %c"
,
*
p
);
VCLI_SetResult
(
cli
,
CLIS_PARAM
);
return
;
}
}
av
++
;
av
++
;
probes
=
1
;
}
}
else
if
(
av
[
2
]
!=
NULL
&&
av
[
2
][
0
]
==
'-'
)
{
if
(
av
[
3
]
!=
NULL
)
{
VCLI_Out
(
cli
,
"Invalid flags %s"
,
av
[
2
]);
VCLI_SetResult
(
cli
,
CLIS_PARAM
);
return
;
}
else
if
(
av
[
3
]
!=
NULL
)
{
VCLI_Out
(
cli
,
"Too many arguments"
);
VCLI_Out
(
cli
,
"Too many arguments"
);
VCLI_SetResult
(
cli
,
CLIS_PARAM
);
VCLI_SetResult
(
cli
,
CLIS_PARAM
);
return
;
return
;
}
}
VCLI_Out
(
cli
,
"%-30s %-
10s %-20s %s"
,
"Backend name"
,
"Admin
"
,
VCLI_Out
(
cli
,
"%-30s %-
7s %-10s %s
"
,
"
Probe"
,
"Last updated
"
);
"
Backend name"
,
"Admin"
,
"Probe"
,
"Last change
"
);
(
void
)
VCL_IterDirector
(
cli
,
av
[
2
],
do_list
,
&
probes
);
(
void
)
VCL_IterDirector
(
cli
,
av
[
2
],
do_list
,
la
);
}
}
/*---------------------------------------------------------------------*/
/*---------------------------------------------------------------------*/
...
...
bin/varnishd/cache/cache_director.h
View file @
579a1df9
...
@@ -60,6 +60,8 @@ typedef void vdi_destroy_f(const struct director *);
...
@@ -60,6 +60,8 @@ typedef void vdi_destroy_f(const struct director *);
typedef
void
vdi_panic_f
(
const
struct
director
*
,
struct
vsb
*
);
typedef
void
vdi_panic_f
(
const
struct
director
*
,
struct
vsb
*
);
typedef
void
vdi_list_f
(
const
struct
director
*
,
struct
vsb
*
,
int
,
int
);
struct
director
{
struct
director
{
unsigned
magic
;
unsigned
magic
;
#define DIRECTOR_MAGIC 0x3336351d
#define DIRECTOR_MAGIC 0x3336351d
...
@@ -75,6 +77,8 @@ struct director {
...
@@ -75,6 +77,8 @@ struct director {
vdi_event_f
*
event
;
vdi_event_f
*
event
;
vdi_destroy_f
*
destroy
;
vdi_destroy_f
*
destroy
;
vdi_panic_f
*
panic
;
vdi_panic_f
*
panic
;
vdi_list_f
*
list
;
void
*
priv
;
void
*
priv
;
const
void
*
priv2
;
const
void
*
priv2
;
...
...
bin/varnishtest/tests/o00004.vtc
View file @
579a1df9
...
@@ -49,5 +49,5 @@ varnish v2 -vcl {
...
@@ -49,5 +49,5 @@ varnish v2 -vcl {
server s1 -wait
server s1 -wait
delay 1
delay 1
varnish v2 -cliexpect "vcl1.bp1[ ]+probe[ ]+
Healthy[ ]+1/1
" backend.list
varnish v2 -cliexpect "vcl1.bp1[ ]+probe[ ]+
1/1[ ]+good
" backend.list
varnish v2 -cliexpect "vcl1.bp2[ ]+probe[ ]+
Healthy[ ]+1/1
" backend.list
varnish v2 -cliexpect "vcl1.bp2[ ]+probe[ ]+
1/1[ ]+good
" backend.list
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