[5.2] fb779c9 Add VSM_NOPID environment variable to disable pid-based tests
PÃ¥l Hermunn Johansen
hermunn at varnish-software.com
Fri Sep 15 11:17:14 UTC 2017
commit fb779c9cf3ff04ee87de30027d33fdfce08dcbf2
Author: Nils Goroll <nils.goroll at uplex.de>
Date: Fri Sep 8 17:09:48 2017 +0200
Add VSM_NOPID environment variable to disable pid-based tests
varnishd writes its pids to vsm segments for vsm clients to
determine if varnishd processes are alive.
When running varnishd and vsm clients in different containers, the
pid information has no relevance and may even be ambiguous across
name spaces.
Setting the environment variable VSM_NOPID for vsm clients disables
use of pid information.
Patch by phk
diff --git a/doc/sphinx/reference/vsm.rst b/doc/sphinx/reference/vsm.rst
index fbea284..a6a0713 100644
--- a/doc/sphinx/reference/vsm.rst
+++ b/doc/sphinx/reference/vsm.rst
@@ -102,3 +102,22 @@ a chance to discover the deallocation.
The include file <vapi/vsm.h> provides the supported API for accessing
VSM files.
+
+VSM and Containers
+------------------
+
+The varnish way works great with single purpose containers. By sharing
+the varnish working directory read-only, vsm clients can be run in
+containers separate from those running varnishd instances on the same
+host.
+
+When running varnishd and vsm clients in the same process namespace,
+pid information can be used by vsm clients to determine if varnishd
+processes are alive.
+
+But, when running varnishd and vsm clients in different containers,
+the pid information has no relevance and may even be ambiguous across
+name spaces.
+
+Thus, with such setups, the environment variable VSM_NOPID needs to be
+set for vsm clients to disable use of pid information.
diff --git a/lib/libvarnishapi/vsm.c b/lib/libvarnishapi/vsm.c
index e7cc519..9d3ed85 100644
--- a/lib/libvarnishapi/vsm.c
+++ b/lib/libvarnishapi/vsm.c
@@ -191,6 +191,8 @@ VSM_New(void)
vd->child = vsm_newset(VSM_CHILD_DIRNAME);
vd->dfd = -1;
vd->patience = 5;
+ if (getenv("VSM_NOPID") != NULL)
+ vd->couldkill = -1;
return (vd);
}
@@ -350,7 +352,7 @@ vsm_refresh_set2(struct vsm *vd, struct vsm_set *vs, struct vsb *vsb)
}
if (vs->fd >= 0) {
- if (!vd->couldkill || !kill(vs->id1, 0))
+ if (vd->couldkill < 1 || !kill(vs->id1, 0))
retval |= VSM_MGT_RUNNING;
return (retval);
}
@@ -385,9 +387,9 @@ vsm_refresh_set2(struct vsm *vd, struct vsm_set *vs, struct vsb *vsb)
retval |= VSM_MGT_RESTARTED | VSM_MGT_CHANGED;
return (retval);
}
- if (!kill(id1, 0)) {
+ if (vd->couldkill >= 0 && !kill(id1, 0)) {
vd->couldkill = 1;
- } else if (vd->couldkill && errno == ESRCH) {
+ } else if (vd->couldkill > 0 && errno == ESRCH) {
retval |= VSM_MGT_RESTARTED | VSM_MGT_CHANGED;
return (retval);
}
More information about the varnish-commit
mailing list