← Back to team overview

openstack team mailing list archive

Re: [metering] resource metadata changes and billing

 

On Fri, Jun 29 2012, Doug Hellmann wrote:

> Thoughts?

Please correct me if I'm wrong.

What I understand is that you're saying that something like:

  GET v1/[SOURCES/<SOURCE>/]USERS/<USER_ID>/RESOURCES/<RESOURCE_ID>/<METER>/VOLUME

as defined in the current API draft, for a counter like instance CPU
time or RAM size has no sense because it can depends on other metadata
From the instance.

That sounds right in many case, especially instances.

The best way to fix this is to not return a sum, but a set of documents
describing the different changes.

E.g. for an (simplified) instance liked you described

GET v1/users/jd/instances/1234

{
  id: 1234,
  name: "foobar",
  …,
  memory: 1024,
  cpu_time: 393010,
  start: 2012-06-01 00:00:00,
  end: 2012-06-12 12:00:00,
}
{
  id: 1234,
  name: "foobar",
  …,
  memory: 2048,
  cpu_time: 1231294,
  start: 2012-06-12 12:00:01,
  end: 2012-06-26 13:24:43
}
{
  id: 1234,
  name: "foobar",
  …,
  memory: 1024,
  cpu_time: 4013510,
  start: 2012-06-26 13:24:44,
  end: 2012-06-30 23:59:00,
}


Doing this does not sounds like too much crazy. You just have to iterate
over each record concerning instance 1234. You create a first document
From the first record. Then if you encounter a meter that is:

- a delta (i.e. cpu_time), you sum up to the data you got from the
  latest record in your document
- an incremented counter, you replace the last one with this one
- an absolute counter (i.e. memory) you start a new document, keep the
  latest values from incremented counters (so you can substract the
  value and start from 0), and reset all delta counters to 0.

If none of the absolute counter (RAM, number of CPU, …) changes, you'll
end up with only one document for the whole period. If one change,
you'll get multiple document describing the resources consumed for each
span time.

WDYT?

-- 
           Julien

Attachment: pgpPVIvhYdB8D.pgp
Description: PGP signature


References