All,By default (safe=False), MongoDB's adheres to Eventual Consistency behaviour. This means that (insert|update|delete) operations return before they are committed in the DB. As a result, an inserted object may not be returned by a fetch that immediately follows. In a live system such as pulp, this latency exhibits itself as non-deterministic behaviour in the API which can have very undesirable effects. For example, A web page (using the API) that creates and object and then refreshes a table which may, or may not, include the created object. Or, an external system creates & synchronizes a repo. But, even though the packages have been inserted (or so it seems), they don't show up in the next API call to list the packages.
This latency was showing up and breaking the web services unit tests. Not sure why running the API unit tests though the WS layer was exacerbating this, but it was.
Anyway, I added a BaseApi.insert() and retrofitted the API classes. This call, like the existing update() and delete() passes the (safe=True) flag to ensure immediate consistency.
If you add/update API classes, please use: self.insert() self.update() self.delete() instead of: self.objectdb.insert() self.objectdb.save() self.objectdb.remove()Also, the BaseApi.delete(id) was expecting the primary key for all model objects to be (id). This works for many cases but not for all. For example: Package has 'packageid' instead of 'id'. And, PackageVersion has 'packageid, epoch, version, release, arch' instead of 'id'. So, I updated delete to be BaseApi.delete(**kwargs) to support any natural (including compound) keys. And, retrofitted calls to delete to pass keyword args such as:
> > rapi.delete(id) > to: > > rapi.delete(id=id) > and > > papi.delete(id) > which is broken to: > > papi.delete(packageid=id). >
Description: S/MIME Cryptographic Signature