Ticket #253 (closed enhancement: fixed)

Opened 5 years ago

Last modified 3 years ago

buildbot.tac is not relocatable because it remembers its basedir

Reported by: zooko Owned by:
Priority: major Milestone: 0.8.0
Version: 0.7.6 Keywords:
Cc:

Description

buildbot.tac has a "basedir" setting inside it, so if you mv a directory which (transitively) contains a buildbot.tac, then next time you try to start that buildslave, it will say:

2008/04/24 17:35 -0600 [-] assert os.path.isdir(self.basedir)

Or some other error. Or, I suppose if you or someone else has moved a *different* buildslave into the location where this one used to live, then that one might get started, possibly with some of this one's settings.

Why is this basedir setting needed? Would replacing it be as simple as os.path.abspath(os.getcwd())?

Change History

comment:1 Changed 5 years ago by warner

basedir is needed to locate master.cfg, as well as all the persisted status information.

We can either os.chdir ourselves to an explicitly-specified basedir (the current approach) or rely upon whatever starts twistd to do it for us. twistd doesn't do this by itself, unfortunately, so we'd have to put the code into the 'buildbot start' command (this is what tahoe and foolscap's daemon-like tools do, and so far we've been happy with how they're working out).

The tac file can't tell us were it lives.. python has no __FILE__ macro like C compilers usually provide. I suppose it might be possible to do some really weird stack introspection from BuildMaster.__init__ to find out where the constructor is being called from and then switch to that directory, but I'd be nervous about its reliability.

I'd be willing to see this changed to match the way we do it in tahoe: 'buildbot start' is responsible for the chdir, and the .tac file asserts that 'buildbot.tac' exists in the current directory.

comment:2 Changed 4 years ago by dustin

  • Milestone changed from undecided to 1.0.+

comment:3 Changed 4 years ago by dustin

  • Status changed from new to closed
  • Resolution set to duplicate

dup'd in #647

comment:4 Changed 3 years ago by dustin

  • Status changed from closed to reopened
  • Resolution duplicate deleted
  • Milestone changed from 1.0.+ to 0.8.0

Ah, not a dupe. We should be able to create "relocatable" buildbot.tac files. The problem is, some ways of invoking a buildmaster do not set a current directory (related to bug #647), so we should probably have a warning when this is done.

I suspect the easiest way to do this is just to add an option to buildbot create-master, or special case ".".

comment:5 Changed 3 years ago by dalore

warner, python does provide __file__

Here is some sample code I put into my buildout.tac to make it relocatable:

import os.path
basedir = os.path.abspath(os.path.dirname(__file__))

I tried renaming the slave directory and it worked.

comment:6 Changed 3 years ago by dustin

  • Status changed from reopened to closed
  • Resolution set to fixed

fixed in 1400c91b276d5f71a7f58975e0be6c999a4231b7

Note: See TracTickets for help on using tickets.