~jcsackett/charmworld/bac-tag-constraints

« back to all changes in this revision

Viewing changes to charmworld/jobs/ingest.py

  • Committer: Tarmac
  • Author(s): Brad Crittenden
  • Date: 2014-04-14 20:07:28 UTC
  • mfrom: (500.1.9 es-missing-data)
  • Revision ID: tarmac-20140414200728-ew38mtkdrsuprcff
Do not index charm annotations in bundles.

Charms in bundles have "annotations" which include information relating to the
widget layout when placed in the GUI ('gui-x' and 'gui-y').  This information
is ancilliary to the actual bundle and should not be searchable.

The presence of such data has also caused operational problems.  In
production, some bundles are not being indexed due to parsing errors of the x
and y coordinates.

An example failure is shown here:
2014-04-11 19:12:30,096 DEBUG [pyelasticsearch][MainThread] got response {u'items': [{u'index': {u'_type': u'bundle', u'_id': u'~charmers/muletrain/wiki', u'error': u'MapperParsingException[failed to parse [data.data.services.mediawiki.annotations.gui-y]]; nested: NumberFormatException[For input string: "-117.5"]; ', u'_index': u'charms-78512'}}], u'took': 4}

Unfortunately, this ingestion failure cannot be reproduced on staging or
locally.  Further, it appears pyelasticsearch is not returning an error in
this situation but is instead silently failing to index the bundle.

To QA the branch, in one window run 'make run'.  In another, ingest some
bundles:

% bin/ingest-queued --prefix="~charmers/charms/bundles"

Afterwards, go to 'localhost:2464' in your browser.  Search for 'bundles' and
see the ones that got ingested.  Next search for 'gui-x' and see no results.

https://codereview.appspot.com/87710043/

R=jcsackett.

Approved by Juju Gui Bot.

Show diffs side-by-side

added added

removed removed

Lines of Context:
113
113
 
114
114
    name = 'default'
115
115
 
116
 
    def __init__(self):
 
116
    def __init__(self, debug=False):
117
117
        self.log = logging.getLogger("charm.%s" % self.name)
 
118
        if debug:
 
119
            self.log.setLevel(logging.DEBUG)
118
120
 
119
121
    def setup(self):
120
122
        pass
247
249
    charm_data['error'] = charm_error
248
250
 
249
251
 
250
 
def run_job(job, charm_data, needs_setup=True, db=None):
 
252
def run_job(job, data, needs_setup=True, db=None):
251
253
    if needs_setup:
252
254
        if db is not None:
253
255
            job.setup(db=db)
254
256
        else:
255
257
            job.setup()
256
 
    stage = job.name
257
258
    try:
258
 
        job.run(charm_data)
 
259
        job.run(data)
259
260
    except IngestError as e:
260
 
        log(stage, logging.INFO, e, charm_data)
 
261
        log(job.name, logging.INFO, e, data)
261
262
        return False
262
263
    except SearchServiceNotAvailable:
263
264
        raise
264
265
    except Exception as e:
265
266
        tb = traceback.format_exc()
266
 
        log(stage, logging.ERROR, e, charm_data, tb)
 
267
        log(job.name, logging.ERROR, e, data, tb)
267
268
        return False
268
269
    return True
269
270
 
375
376
 
376
377
    def run(self, payload):
377
378
        charm_id = construct_charm_id(payload)
 
379
        self.log.info("Updating charm {}".format(charm_id))
378
380
        charm_data = self.db.charms.find_one(charm_id)
379
381
        if charm_data is None:
380
382
            charm_in_db = False
403
405
 
404
406
    name = 'update-bundle'
405
407
 
406
 
    def __init__(self, working_dir=None):
 
408
    def __init__(self, debug=False, working_dir=None):
407
409
        if working_dir is None:
408
410
            working_dir = CHARM_DIR
409
411
        self.working_dir = working_dir
410
 
        super(UpdateBundleJob, self).__init__()
 
412
        super(UpdateBundleJob, self).__init__(debug)
411
413
 
412
414
    def store_bundles(self, deployer_config, owner, basket_id, first_change,
413
415
                      last_change, changes, branch_spec, services_info,
725
727
            log.info('Invalid revision %s', rev_raw)
726
728
        metadata['revision'] = rev_id
727
729
    elif not 'revision' in metadata:
728
 
        log.info('Invalid revision %s', charm_data['branch_spec'])
 
730
        log.info('No revision file for %s', charm_data['branch_spec'])
729
731
        metadata['revision'] = 0
730
732
 
731
733
    hooks = []