cf-abacus
cf-abacus copied to clipboard
Validating resource specific submissions
Though there is a schema defined for resource usage, currently there is no strict way to validate the measures in it. Some resources might need all measures to be submitted all times, but some doesn't.
For example linux-container always needs all the four measures to be submitted at all times
- current_instance_memory
- current_running_instances
- previous_instance_memory
- previous_running_instances
However object-storage can have any or all of the three measures submitted
- storage
- light_api_calls
- heavy_api_calls
If the metering definition can include an optional field called required as a part of each measure, so that the measures in the submitted usage can be validated.
measures: [
{
name: 'current_instance_memory',
unit: 'GIGABYTE',
required: true
},
...],
We have created an issue in Pivotal Tracker to manage this. You can view the current status of your issue at: https://www.pivotaltracker.com/story/show/118704481.
I feel like what you mean is to introduce "bundle" of measure for a metric.
Consider a resource definition where you have 3 measures and 2 metrics: measures:
- measure A
- measure B
- measure C metrics:
- metric X
- metric Y
Metric X's meter function requires 2 measures: measure A and measure B.
Metric Y only need measure C.
Require field in measure A and measure B would means we cannot submit measure C without submitting measure A and measure B. So what we need is to bundle measure A and measure B.
AFAIK your meter functions are passed all the measures, so the simple solution here is to just check the presence of the required measures in your meter function and report an error if they're missing. That'll also be consistent with the other errors you'll need to report if for example a particular measure is present but missing some of information required to compute the metric.
We should do minimal validation: at least one of the measures in the plan should be present.
Broker creates sample plans that users have to edit. If they forgot to do that Abacus should provide meaningful error. ATM we simply return 201 without business error.
We have created an issue in Pivotal Tracker to manage this:
https://www.pivotaltracker.com/story/show/151755339
The labels on this github issue will be updated when the story is started.