Skip to content

Add cost service type to service type definitions#60

Open
pgarciaq wants to merge 1 commit into
dcm-project:mainfrom
pgarciaq:cost-service-type
Open

Add cost service type to service type definitions#60
pgarciaq wants to merge 1 commit into
dcm-project:mainfrom
pgarciaq:cost-service-type

Conversation

@pgarciaq

Copy link
Copy Markdown

Summary

Adds the cost service type as a fifth DCM service type alongside vm, container, database, and cluster.

Unlike the four compute-oriented types, cost provisions visibility (metering, overhead distribution, financial tracking) rather than infrastructure.

Changes

  • Adds cost to the service type enum and lists
  • Defines the CostSpec schema with:
    • target (resource_id, resource_type)
    • cost_model (rates, markup, distribution)
    • currency
  • Documents the three-tier model (basic metering → distribution → full cost)

Context

This service type is used by the Cost Management Service Provider enhancement, which was asked to define its service type in a separate PR to the service-type-definitions document (consistent with how other SPs reference existing type definitions rather than defining them inline).

The initial implementation is backed by Red Hat Lightspeed Cost Management (Project Koku).

Test plan

  • Schema fields are consistent with the CostSpec in the cost-sp enhancement
  • Service type enum includes all five types
  • Schema follows the same pattern as vm/container/database/cluster

Made with Cursor

Introduces the `cost` service type as a fifth DCM service type alongside
vm, container, database, and cluster. Unlike the four compute-oriented
types, cost provisions visibility (metering, overhead distribution,
financial tracking) rather than infrastructure.

Includes the CostSpec schema with target, cost_model (rates, markup,
distribution), and currency fields. Supports three tiers: basic metering,
distribution, and full cost.

See the Cost Management Service Provider enhancement for the full SP
proposal.

Signed-off-by: Pau Garcia Quiles <pgarciaq@redhat.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
croadfeldt added a commit to croadfeldt/udlm that referenced this pull request Jun 18, 2026
…st type

End-to-end proof that the dcm-project/enhancements#60 'cost' serviceType
maps onto UDLM, and the first use of the Process entityType in the registry.

- family=Resource, entityType=Process (a long-running observational process
  realized by a cost provider, e.g. Koku) — not infrastructure, not Knowledge
- target = a typed `references` relationship to the compute types; the
  resource id is resolved on the instance, not baked into the type spec
- costModel (rates/markup/distribution) + currency = declarative spec data
- three-tier model = a real JSON-Schema presence-conditional (E3): tier-3
  (rates present) requires currency; tier-1 basic metering passes. Verified
  with Draft202012Validator.
- metered/computed figures = typed Realized outputs (E2: meteredUsage,
  computedCost, costBreakdown, period...)
- 'cost = metering x rate' is prose in computedCost's description only —
  never an embedded expression (G2); the computation is the provider's act
- README + design-notes §4a cross-reference the worked type

validate.py: all 7 types + instance valid (0 invalid).

Signed-off-by: Chris Roadfeldt <chris@roadfeldt.com>
@croadfeldt

Copy link
Copy Markdown
Collaborator

Why: vendor-agnosticism is a core DCM/UDLM requirement — a service type should be implementable by any provider, not just one. This cost definition is at the right layer (a service-type definition, consumed by an SP), so the only ask here is about the data shape.

Rather than define a bespoke cost vocabulary (Koku's 40+ dimensions, Infrastructure/Supplementary), consider conforming the consumable cost data to FOCUS (the FinOps Open Cost & Usage Specification — current 1.4, FinOps Foundation; AWS/Azure/GCP and Koku all emit it) and OpenCost (CNCF) for Kubernetes cost allocation. Express the rate dimensions in FOCUS terms, and map the direct-vs-allocated intent onto FOCUS allocation columns. The rate-card authoring can stay a thin provider offering — rate cards are inherently finance-policy.

Net: any FOCUS-emitting cost provider — not just Koku — can implement the same cost type, and consumers query cost identically regardless of which provider backs it.

The underlying principle: adopt the external standard by reference rather than re-model it, which keeps the contract vendor-neutral and avoids reinventing a spec the ecosystem already maintains.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

| Field | Required | Type | Description |
| :------------ | :------- | :----- | :--------------------------------------------------- |
| resource_id | Yes | string | DCM instance ID of the resource to track costs for |
| resource_type | No | string | Type of the target resource (default: _cluster_) |

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why resource_type is not mandatory and why defaulting to cluster? IIUC, this SP will monitor the a resource created by DCM and provide cost related data to the user (and DCM?)
So how is resource_type influencing this? I see nothing about that too

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So how is resource_type influencing this? I see nothing about that too

maybe this is out of the scope of this document and it will be for each SP enhancement (eg: #57 ) to define how this field's influence

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The possible values (cluster, vm, container) for resource_type is the same as service_type for the instance, no?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that is my guess yes as the cost manager for DCM will look into resources created by DCM but it needs to be explicitly written here IMO

and as #57 is focused on cluster only, I really believe we should remove the default cluster value to avoid any confusiuon

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'm thinking the field names might be confusing and since the cost resource itself targets other resources, maybe target_id and target_type might be better here? And definitely agree, these should be required. And all default values are set in the catalog item and not on the service type level so the doc should give examples instead.

Comment on lines +389 to +393
The initial implementation is backed by
[Red Hat Lightspeed Cost Management](https://github.com/project-koku/koku)
(Project Koku). See the
[Cost Management Service Provider enhancement](https://github.com/dcm-project/enhancements/blob/main/enhancements/cost-sp/cost-sp.md)
for the full proposal.

@jenniferubah jenniferubah Jun 19, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any need to mention this? This cost type is generic and can be implemented by any cost SP/product

| :--------- | :------- | :----------------------------------- | :--------------------------------------------------- |
| target | Yes | [Target](#cost-target-object) | The resource to track costs for |
| cost_model | No | [CostModel](#cost-costmodel-object) | Rate configuration (absent = basic metering only) |
| currency | No | string | Currency code (default: _USD_) |

@jenniferubah jenniferubah Jun 19, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
| currency | No | string | Currency code (default: _USD_) |
| currency | No | string | Currency code (e.g: _USD_, _GBP_) |

Examples can be given here because default values are set on the catalog item by the catalog author.

| :----------- | :------- | :-------------------------------------- | :----------------------------------------------- |
| rates | No | array[[Rate](#cost-rate-object)] | Tiered rate definitions (absent = distribution only) |
| markup | No | [Markup](#cost-markup-object) | Markup percentage |
| distribution | No | string | Distribution method: _cpu_ or _memory_ (default: _cpu_) |

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
| distribution | No | string | Distribution method: _cpu_ or _memory_ (default: _cpu_) |
| distribution | No | string | Distribution method: _cpu_ or _memory_ (e.g: _cpu_) |

| :-------- | :------- | :----- | :------------------------------------------------------------- |
| metric | Yes | string | Rate metric (e.g., _cpu\_core\_usage\_per\_hour_, _node\_cost\_per\_month_) |
| cost_type | No | string | _Infrastructure_ or _Supplementary_ (default: _Infrastructure_) |
| value | Yes | number | Rate value (≥ 0) |

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for consistency across the document, this should be integer?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants