Merge branch 'pr294': split control/log to new Tubs

closes tahoe-lafs#294
This commit is contained in:
Brian Warner 2016-07-06 21:09:47 -07:00
commit 6a35cf2752
3 changed files with 50 additions and 5 deletions

View File

@ -416,7 +416,7 @@ class Client(node.Node, pollmixin.PollMixin):
def init_control(self):
c = ControlServer()
c.setServiceParent(self)
control_url = self.tub.registerReference(c)
control_url = self.control_tub.registerReference(c)
self.write_private_config("control.furl", control_url + "\n")
def init_helper(self):

View File

@ -84,6 +84,8 @@ class Node(service.MultiService):
self.init_tempdir()
self.create_tub()
self.create_control_tub()
self.create_log_tub()
self.logSource="Node"
self.setup_logging()
@ -233,6 +235,33 @@ class Node(service.MultiService):
# the Tub is now ready for tub.registerReference()
self.tub.setServiceParent(self)
def create_control_tub(self):
# the control port uses a localhost-only ephemeral Tub, with no
# control over the listening port or location
self.control_tub = Tub()
portnum = iputil.allocate_tcp_port()
port = "tcp:%d:interface=127.0.0.1" % portnum
location = "tcp:127.0.0.1:%d" % portnum
self.control_tub.listenOn(port)
self.control_tub.setLocation(location)
self.log("Control Tub location set to %s" % (location,))
self.control_tub.setServiceParent(self)
def create_log_tub(self):
# The logport uses a localhost-only ephemeral Tub, with no control
# over the listening port or location. This might change if we
# discover a compelling reason for it in the future (e.g. being able
# to use "flogtool tail" against a remote server), but for now I
# think we can live without it.
self.log_tub = Tub()
portnum = iputil.allocate_tcp_port()
port = "tcp:%d:interface=127.0.0.1" % portnum
location = "tcp:127.0.0.1:%d" % portnum
self.log_tub.listenOn(port)
self.log_tub.setLocation(location)
self.log("Log Tub location set to %s" % (location,))
self.log_tub.setServiceParent(self)
def get_app_versions(self):
# TODO: merge this with allmydata.get_package_versions
return dict(app_versions.versions)
@ -352,13 +381,15 @@ class Node(service.MultiService):
# TODO: twisted >2.5.0 offers maxRotatedFiles=50
lgfurl_file = os.path.join(self.basedir, "private", "logport.furl").encode(get_filesystem_encoding())
self.tub.setOption("logport-furlfile", lgfurl_file)
if os.path.exists(lgfurl_file):
os.remove(lgfurl_file)
self.log_tub.setOption("logport-furlfile", lgfurl_file)
lgfurl = self.get_config("node", "log_gatherer.furl", "")
if lgfurl:
# this is in addition to the contents of log-gatherer-furlfile
self.tub.setOption("log-gatherer-furl", lgfurl)
self.tub.setOption("log-gatherer-furlfile",
os.path.join(self.basedir, "log_gatherer.furl"))
self.log_tub.setOption("log-gatherer-furl", lgfurl)
self.log_tub.setOption("log-gatherer-furlfile",
os.path.join(self.basedir, "log_gatherer.furl"))
incident_dir = os.path.join(self.basedir, "logs", "incidents")
foolscap.logging.log.setLogDir(incident_dir.encode(get_filesystem_encoding()))

14
topfiles/2794.change Normal file
View File

@ -0,0 +1,14 @@
The little-used "control port" now uses a separate (ephemeral) Tub. This
means the FURL changes each time the node is restarted, and it only listens
on the loopback (127.0.0.1) interface, on a random port. As the control port
is only used by some automated tests (check_memory, check_speed), this
shouldn't affect anyone.
The slightly-more-used "log port" now also uses a separate (ephemeral) Tub,
with the same consequences. The lack of a stable (and externally-reachable)
logport.furl means it is no longer possible to use `flogtool tail FURL`
against a distant Tahoe server, however `flogtool tail
.../nodedir/private/logport.furl` still works just fine (and is the more
common use case anyways). We might bring back the ability to configure the
port and location of the logport in the future, if there is sufficient
demand, but for now it seems better to avoid the complexity.