Changeset 154424


Ignore:
Timestamp:
Oct 29, 2016, 1:25:46 AM (2 years ago)
Author:
larryv@…
Message:

buildbot: Improve configuration override

  • Trim config.json.sample by removing keys that are unlikely to be changed. They just duplicate the defaults from master.cfg.
  • Replace hardcoded settings with config defaults to allow overriding them from the config file.
  • Organize defaults a bit since there are so many of them now.
  • Catch IOError when reading the config file instead of checking for existence.
Location:
contrib/buildbot-test
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • contrib/buildbot-test/config.json.sample

    r154112 r154424  
    22    "production":   false,
    33    "privkey":      "/var/keys/macports-privkey.pem",
    4     "slaveport":    9989,
    5     "httpport":     8010,
    6     "buildboturl":  "http://localhost:8010/",
    7     "htpasswdfile": "htpasswd",
    8     "mpbbsvnurl":   "https://svn.macports.org/repository/macports/contrib/mp-buildbot",
    9     "svnurl":       "https://svn.macports.org/repository/macports/trunk",
    10     "archivesite":  "https://packages.macports.org",
     4    "buildboturl":  "http://domain.tld:8010/",
    115    "slaveprefix":  "/opt/local",
    126    "toolsprefix":  "/opt/mports",
  • contrib/buildbot-test/master.cfg

    r154420 r154424  
    4646c = BuildmasterConfig = {}
    4747
    48 # Master variable to toggle config between testing on your personal system
    49 # (where /opt/local shouldn't be messed with) and the production server (where
    50 # it has to be)
    51 
    5248config = {
     49    # Production or development
    5350    'production': False,
    54     'privkey': '',
     51
     52    # Connections
    5553    'slaveport': 9989,
    5654    'httpport': 8010,
    57     'buildboturl': 'http://localhost:8010/',
    58     'htpasswdfile': 'htpasswd',
     55
     56    # External configuration. Use absolute paths when overriding these.
     57    'configfile': _path('config.json'),
     58    'workersfile': _path('slaves.json'),
     59    'htpasswdfile': _path('htpasswd'),
     60
     61    # Sources
    5962    'mpbbsvnurl': 'https://svn.macports.org/repository/macports/contrib/mp-buildbot',
    6063    'svnurl': 'https://svn.macports.org/repository/macports/trunk',
    61     'archivesite': 'https://packages.macports.org',
     64
     65    # Tooling
    6266    'slaveprefix': '/opt/local',
    6367    'toolsprefix': '/opt/mports',
    64     'deploy': {}
     68
     69    # Deployment
     70    'archivesite': 'https://packages.macports.org',
     71    'privkey': '',
     72    'deploy': {},
     73
     74    # Site definitions
     75    # (http://docs.buildbot.net/0.8.12/manual/cfg-global.html#site-definitions)
     76    'title': 'MacPorts',
     77    'titleurl': 'https://www.macports.org/',
     78    'buildboturl': 'http://localhost:8010/',
     79
     80    # Database
     81    # (http://docs.buildbot.net/0.8.12/manual/cfg-global.html#database-specification)
     82    'db': {'db_url': 'sqlite:///state.sqlite'},
     83
     84    # Data lifetime
     85    # (http://docs.buildbot.net/0.8.12/manual/cfg-global.html#data-lifetime)
     86    'buildcachesize': 600,
     87    'buildhorizon': 10000,
     88    'eventhorizon': 2000,
     89    'loghorizon': 5000
    6590    }
    6691
    67 if os.path.exists(_path('config.json')):
    68     with open(_path('config.json')) as f:
    69         configdata = json.load(f)
    70     config.update(configdata)
     92# Override defaults with external settings.
     93try:
     94    with open(config['configfile']) as f:
     95        extconfig = json.load(f)
     96except IOError:
     97    extconfig = {}
     98config.update(extconfig)
    7199
    72100path_base = '/usr/bin:/bin:/usr/sbin:/sbin'
     
    84112# slave name and password must be configured on the slave.
    85113
    86 with open(_path('slaves.json')) as f:
     114with open(config['workersfile']) as f:
    87115    slavedata = json.load(f)
    88116
     
    775803# 'titleURL') and is embedded in the title of the waterfall HTML page.
    776804
    777 c['title'] = 'MacPorts'
    778 c['titleURL'] = 'https://www.macports.org/'
    779 
     805c['title'] = config['title']
     806c['titleURL'] = config['titleurl']
    780807c['buildbotURL'] = config['buildboturl']
    781808c['status'].append(WebStatus(
     
    792819# This specifies what database buildbot uses to store its state. You can
    793820# leave this at its default for all but the largest installations.
    794 c['db'] = {'db_url': 'sqlite:///state.sqlite'}
     821c['db'] = config['db']
    795822
    796823
    797824####### DATA LIFETIME #######
    798 c['buildHorizon'] = 10000
    799 c['logHorizon'] = 5000
    800 c['eventHorizon'] = 2000
    801 c['buildCacheSize'] = 600
     825c['buildHorizon'] = config['buildhorizon']
     826c['logHorizon'] = config['loghorizon']
     827c['eventHorizon'] = config['eventhorizon']
     828c['buildCacheSize'] = config['buildcachesize']
Note: See TracChangeset for help on using the changeset viewer.