Page MenuHomePhabricator

Add a generic key-value mapping table to Harbormaster
AbandonedPublic

Authored by epriestley on Oct 15 2015, 1:54 AM.

Details

Summary

Ref T9456. When we tell CircleCI to build something, it's going to give us back a build ID, like "123".

Later, it will make a call to us saying "I finished the build for build 123, here it is: ...".

We need to be able to go figure out what "build 123" is. There's no real way to do this right now. We can store it on a target, but we can't efficiently figure out which target it is on without loading every target and then looking at all of them, which would be really slow.

Add a basic indexed key-value table so we can write something like <circleci.build#123, PHID-HMBT-abcdeffe23f2> and figure out which target the build is talking about.

Test Plan

Clean bin/storage upgrade? This will get used properly in the next diff or two and I'll fix it if anything doesn't work.

Diff Detail

Repository
rP Phabricator
Branch
circle2
Lint
Lint OK
Unit
Unit Tests OK
Build Status
Buildable 8295
Build 9504: Run Core Tests
Build 9503: arc lint + arc unit

Event Timeline

epriestley updated this revision to Diff 34483.Oct 15 2015, 1:54 AM
epriestley retitled this revision from to Add a generic key-value mapping table to Harbormaster.
epriestley updated this object.
epriestley edited the test plan for this revision. (Show Details)
epriestley added a reviewer: chad.

There's a fairly good chance that this will be "circle CI build number storage table" forever, but it's only like 80 lines even if that's true.

chad accepted this revision.Oct 15 2015, 2:43 AM
chad edited edge metadata.
This revision is now accepted and ready to land.Oct 15 2015, 2:43 AM

This appears to be working OK in the next diff, although I'm not reading it yet:

mysql> select * from harbormaster_keyvaluepair;
+----+--------------------------------+--------------+-------------------+------------------------------------------------------+-------------+--------------+
| id | objectPHID                     | pairIndex    | pairKey           | pairValue                                            | dateCreated | dateModified |
+----+--------------------------------+--------------+-------------------+------------------------------------------------------+-------------+--------------+
|  1 | PHID-HMBT-kud3bm7apbays2lmw7so | qyy6SlT5RxYW | circleci.build(2) | {"buildTargetPHID":"PHID-HMBT-kud3bm7apbays2lmw7so"} |  1444879444 |   1444879444 |
|  2 | PHID-HMBT-v6eychoop5ofpxh5tpt5 | lo6ftFSlkC6G | circleci.build(3) | {"buildTargetPHID":"PHID-HMBT-v6eychoop5ofpxh5tpt5"} |  1444879496 |   1444879496 |
|  3 | PHID-HMBT-k4suf5k76icw7kdzght3 | yPBSScDO5s1t | circleci.build(4) | {"buildTargetPHID":"PHID-HMBT-k4suf5k76icw7kdzght3"} |  1444879790 |   1444879790 |
+----+--------------------------------+--------------+-------------------+------------------------------------------------------+-------------+--------------+
3 rows in set (0.00 sec)
epriestley abandoned this revision.Oct 15 2015, 3:45 PM

We can actually figure out which target it is from the callback, since we get all the parameters we passed back. This is good: simpler, and no race window.