Packit-service: 'GET /api/copr-builds' yields nothing in prod

Created on 26 May 2020  ·  9Comments  ·  Source: packit/packit-service

tt at hops ~ curl -s 'https://prod.packit.dev/api/copr-builds?page=1&per_page=50'
tt at hops ~ curl -s 'https://prod.packit.dev/api/copr-builds'
tt at hops ~   

is there a bug in the API code?

API bug

Most helpful comment

Could this be achieved with a 'grouped by' in CoprBuildModel? Such a thing seems to me to have a better place in the database layer than in the API.

👍 I'll work on this while modifying the API.

All 9 comments

Looking at the logs, it seems that the process (or thread) crashed and then is restarted whenever the I call this endpoint.

The OpenShift monitoring graphs show a peak in CPU whenever this happens.

Are resources enough?

Maybe we shouldn't load all 22000+ copr builds into memory at once and have something like CoprBuildModel.get(first, last) instead?

So instead of doing pagination provided by Flask RestX, which loads everything into memory and then serves info about 10 or 20 builds at a time, we should fetch those 10 or 20 from the DB ?

That seems way more efficient but one (minor) issue with doing that is that we don't know how many builds to fetch from the DB to get a fixed number (say 10 or 20) of builds in the API after merging chroots.

So instead of doing pagination provided by Flask RestX, which loads everything into memory and then serves info about 10 or 20 builds at a time, we should fetch those 10 or 20 from the DB ?

Yes. Afaik, the data loaded is not cached between API calls, so what is happening now, is that the whole data is loaded in memory, but only a very small part of it is used.

That seems way more efficient but one (minor) issue with doing that is that we don't know how many builds to fetch from the DB to get a fixed number (say 10 or 20) of builds in the API after merging chroots.

Could this be achieved with a 'grouped by' in CoprBuildModel? Such a thing seems to me to have a better place in the database layer than in the API.

Could this be achieved with a 'grouped by' in CoprBuildModel? Such a thing seems to me to have a better place in the database layer than in the API.

👍 I'll work on this while modifying the API.

@IceWreck finished this and it's merged, but let's wait until this reaches prod and close after that.

This works now. :tada:

nice! big ♥ to @IceWreck, and @csomh, obviously :D

Was this page helpful?
0 / 5 - 0 ratings