Closed SamanthaYu closed 6 years ago
I think -- please correct me -- the current state is that this is waiting for an update from rachel to overwrite the DB in a single transaction. With that change (and with the drop-database call restored in test_housekeeping.js) this should be good to go.
I added a check within the function reportEbsUsage(rowData)
that does nothing if rowData
is an empty array, but I wanted to confirm if everyone thinks this makes sense. The alternative would be to assume that the empty list is correct, so just clear the table and insert nothing.
I think if there's no row data then we're provisioning in 0 regions, which doesn't seem right. So I think it's fine as it is.
Store the EBS totals in Postgres
We decided to store the EBS totals in Postgres. In the table
ebsusage
, the columns areregion
,volumetype
,state
,totalcount
,totalgb
, andtouched
with the primary key a combination ofregion
,volumetype
, andstate
. WhenreportEbsUsage()
gets called, it inserts the totals into their respective columns. If there's already an existing record with that primary key, then that record'stotalcount
andtotalgb
gets replaced with the reportedtotalcount
andtotalgb
respectively, andtouched
is set to the current timestamp.Fetch these totals in an API call
The internal API call,
ebsUsage()
, returns the entireebsusage
table. In other words, it returns a list of objects in the form:Updated documentation for AMI API call
Because the API calls for EBS usage and AMI usage are similar, I updated the AMI API call's for consistency with the EBS API call and for clarity of what values get returned:
@rafvasq and @auni53 What do you think? Is this comment accurate?
Other comments
@rstiyer and I decided to combine our two parts into this PR. Since @rstiyer worked on the database side and I worked on the EBS API call, the tests for each of our parts would rely on each other so it would be hard to separate them completely.
@djmitche and @imbstack Can you review this PR when you get the chance?