Emit fedmsg with whatever result is being stored
ClosedPublic

Authored by mkrizek on Sep 8 2015, 2:37 PM.

Details

Summary

This patch allows sending fedmsg with whatever is sent from libtaskotron check as a result.

Test Plan

When deployed on dev/stg

Diff Detail

Repository
rRSDB resultsdb
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
mkrizek retitled this revision from to Emit fedmsg with whatever result is being stored.Sep 8 2015, 2:37 PM
mkrizek updated this object.
mkrizek edited the test plan for this revision. (Show Details)
mkrizek added reviewers: tflink, kparal, jskladan, ralph2.
jskladan requested changes to this revision.Sep 8 2015, 3:02 PM
jskladan added inline comments.
resultsdb/controllers/api_v1.py
627

It feels like passing just the result object would look/be better - you do it just one line lower in the get_fedmsg call anyway... Also, not all of the results stored in ResultsDB need to have the result_data[item] specified, so you might at least want to change it to args['results_data'].get('item', None)

643

Might be worth adding an explicit sort, just to make sure that the first is really the "newest". I'm not really sure what's the default way of sorting data for queries, but my guess would be primary_key - ascending, which would make the first actually the oldest, rather than newest.

649

Maybe rename to create_fedmsg or something like that? I don't really care that much, though.

656

I most probably missed the fedmsg structure discussion (so feel free to ignore the comment), but wouldn't it be better to fill check just with check['name'], and put the rest of the data - which at the moment, since you take it from result_data, is "everything the check developer decided to store", and accidentally also item, type and the likes - to a separate key?
I'm not sure what's the purpose of the check key, it just seems semantically off to have all the 'extra data' in there.

This revision now requires changes to proceed.Sep 8 2015, 3:02 PM
kparal added inline comments.Sep 9 2015, 11:50 AM
conf/settings.py.example
13–14

Please document the settings (I have no idea what "modname" is). Furthermore, you haven't added them to resultsdb/config.py. Doesn't that mean that the code will crash for users without conf/settings.py file (or with the values commented out)?

resultsdb/controllers/api_v1.py
627

Btw, None is the default fallback value for dict.get().

634

It would be nice to have a docstring describing what exactly is considered duplicate. It will give us better assurance in the future when we decide to modify the code, that it's still doing what was intended.

657

Why is this empty? Does it have to be there when it is empty?

660

Would it be a good idea to encode the timezone info as well, and not just suppose they'll assume it's UTC?

Just a few nits beyond what @kparal and @jskladan pointed out. Looks like a good start - looking forward to getting this into production

resultsdb.spec
25

it would be wise to start versioning our deps in resultsdb like we did in libtaskotron

resultsdb/controllers/api_v1.py
656

I must have missed this during the fedmsg structure discussion but this should probably be task instead of check since we'll be emitting results for more than just checks

mkrizek added inline comments.Sep 16 2015, 9:14 PM
resultsdb.spec
25

Created ticket for that so we don't have to deal with it in this review: T621.

mkrizek added inline comments.Sep 17 2015, 11:59 AM
resultsdb/controllers/api_v1.py
656

I most probably missed the fedmsg structure discussion (so feel free to ignore the comment), but wouldn't it be better to fill check just with check['name'], and put the rest of the data - which at the moment, since you take it from result_data, is "everything the check developer decided to store", and accidentally also item, type and the likes - to a separate key?
I'm not sure what's the purpose of the check key, it just seems semantically off to have all the 'extra data' in there.

In my mind, the check key (now task) is input for the task: its name and under what conditions the task was run. The result key then is output of the task. Does that make sense?

OTOH, you do have a point that result_data can be filled also with data other than input, like additional info about the result of the task that the task developer wants to store. In that case, would it make sense to store input parts of result_data into task and the rest of it into result? The thing I don't like about it, though, is that we'd need to do some hardcoding (item, type, ...).

Thoughts?

mkrizek updated this revision to Diff 1546.Sep 18 2015, 9:20 AM
  • Address issues from the review
tflink accepted this revision.Sep 18 2015, 2:08 PM

Are we stuck on waiting for more acks on this review or is there something else I'm missing?

In D564#11352, @tflink wrote:

Are we stuck on waiting for more acks on this review or is there something else I'm missing?

Waiting for more acks.

jskladan accepted this revision.Oct 2 2015, 10:09 AM

Looks good enough.

This revision is now accepted and ready to land.Oct 2 2015, 10:09 AM
kparal added inline comments.Oct 2 2015, 10:36 AM
resultsdb/controllers/api_v1.py
670

Can you please publish a real-world example for the whole fedmsg? If I read the code correctly, task should contain item, type, log_url (which would be duplicated with results) and any extra keyvals the task defined. Out of these, I think only item and type should be there. Unless we have a real use case right now, I'd avoid including all extra keyvals directly in the fedmsg. We want to keep the fedmsg small and we have no idea how large the extra keyvals might be (we have even placed no restriction on it in libtaskotron, not sure about resultsdb). Therefore I'd really hand-pick ("hardcode") a few items that we want to publish here, as mentioned in one of the previous comments.

675

Since the switch to ResultYAML, we have note instead of summary, so this should probably reflect that. I don't know whether the field name in database changed as well, or if it is still summary, @jskladan will know. But if we're trying to keep the fedmsgs small in size, I don't think we need to publish at all. It's an extra piece of data, but it doesn't have to be a part of the notification, if you need that, you'll probably need to query for the full result anyway. I'd leave it out.

mkrizek added inline comments.Oct 5 2015, 9:57 AM
resultsdb/controllers/api_v1.py
670
{'modname': 'taskotron',
 'msg': {'result': {'id': 481,
                    'job_url': u'http://localhost:5003/jobs/20151005_094935_437061',
                    'log_url': u'http://localhost/artifacts/all/20151005_094935_437061/task_output/openstack-cinder-7.0.0-0.1.0rc1.fc24.log',
                    'outcome': 'FAILED',
                    'submit_time': '2015-10-05 09:49:48 UTC',
                    'summary': u'rpmlint FAILED for openstack-cinder-7.0.0-0.1.0rc1.fc24'},
         'task': {u'item': u'openstack-cinder-7.0.0-0.1.0rc1.fc24',
                  'name': u'rpmlint',
                  u'type': u'koji_build'}},
 'topic': 'result.new'}

I am not sure why you think that log_url is in result_data. Anyway I agree with having only item and type from result_data in task. I'll update the patch shortly.

675

I think that name was changed only in CheckDetail in libtaskotron, wasn't it? Either way, I think we don't need to include that in fedmsgs, yeah.

mkrizek updated this revision to Diff 1589.Oct 5 2015, 10:08 AM
  • Include only item and type in the task key
kparal accepted this revision.Oct 5 2015, 12:53 PM

I think the current fedmsg structure looks both useful and concise. Thanks.

resultsdb/controllers/api_v1.py
670

Because there is no documentation, so I looked up that result_data is created from extra_data, and extra_data have this comment:

# fill extra_data with the query parameters 'other' than those defined in RP['get_results']

And RP['get_results'] doesn't define log_url, but we send it from resultsdb_directive. Phew. But it seems I made a mistake somewhere or the comment is not precise. That's why I asked for a real-world example :)

This revision was automatically updated to reflect the committed changes.