Skip to content

feat(reporting): add OEM/platform distribution breakdown (backend) - #1590

Open
shouryapratap132006 wants to merge 1 commit into
flatcar:mainfrom
shouryapratap132006:feat/oem-distribution-breakdown
Open

feat(reporting): add OEM/platform distribution breakdown (backend)#1590
shouryapratap132006 wants to merge 1 commit into
flatcar:mainfrom
shouryapratap132006:feat/oem-distribution-breakdown

Conversation

@shouryapratap132006

@shouryapratap132006 shouryapratap132006 commented Aug 15, 2026

Copy link
Copy Markdown

Summary

Adds an end-to-end backend implementation of an OEM/platform distribution
breakdown for groups — surfacing which hardware/cloud platform (AWS, Azure,
VMware, GCP, etc.) each instance in a group is running on. This is data
Nebraska already collects (the oem column on instance, added in
migration 0021_add_instance_oem.sql) but never aggregates or exposes.

This follows the exact pattern of the existing GetGroupVersionBreakdown
feature, reusing its query shape, handler structure, and test style.

Related to #2239 (Nebraska reporting and metrics uplift).

Changes

  • DB query: GetGroupOEMBreakdown in
    backend/pkg/api/internal/dbreads/groups.go — joins instance_application
    with instance (since oem lives on instance while group filtering
    and check-in window live on instance_application), grouped by oem,
    with instance count and percentage.
  • Types: OEMBreakdownEntry in backend/pkg/api/types/group.go.
  • API route: GET /api/apps/{appIDorProductID}/groups/{groupID}/oem_breakdown
    added to backend/api/spec.yaml, with oemBreakdownEntry and
    groupOEMBreakdown schemas.
  • Handler: GetGroupOEMBreakdown in backend/pkg/handler/groups.go,
    mirroring GetGroupVersionBreakdown's handler (including the
    empty-array-not-null JSON quirk).
  • Tests: TestOEMBreakDown and TestOEMBreakDownEmpty in
    backend/pkg/api/groups_test.go, covering populated and empty-group cases,
    and confirming fake/test instances are excluded.

Note on codegen

I didn't have oapi-codegen/the Go toolchain available to run make codegen
in my dev environment, so the generated files (backend/pkg/codegen/server.gen.go
and types.gen.go) were hand-edited to match what oapi-codegen would
normally produce from the updated spec.yaml. This should be verified by
regenerating properly via make codegen
— flagging this explicitly since
hand-edited generated code is the riskiest part of this PR and I'd want a
maintainer to confirm it before this is considered mergeable as-is.

Status

Opening as a draft — this covers the backend slice only (query, API,
tests). Not yet included: the frontend chart component and the Prometheus
metric, which I'd propose as natural follow-ups once the backend shape is
confirmed as correct.

Testing

  • TestOEMBreakDown and TestOEMBreakDownEmpty added and run locally.
  • Have not yet been able to run the full make check-backend-with-container
    suite in this environment — will confirm and update before requesting
    full review.

Related work

#1481 adds a Prometheus gauge (nebraska_application_instances_by_oem)
for the same underlying OEM data — that's the metrics layer of the distribution
reporting work described in flatcar/Flatcar#2239. This PR is complementary: it
adds the DB query, REST API endpoint, and OpenAPI schema needed to serve OEM
breakdown data to the dashboard/API consumers, which #1481 doesn't cover.
Together they'd close out three of the four layers mentioned in #2239
(DB, API, metric) — the dashboard chart component remains open.

Feedback very welcome, especially on the codegen approach and whether the
join strategy in the aggregation query matches Nebraska's conventions
elsewhere in the codebase.****

@shouryapratap132006
shouryapratap132006 requested a review from a team as a code owner August 15, 2026 09:56
Implements the DB aggregation query, OpenAPI route, handler, and
unit tests for OEM/platform distribution — part of the Nebraska
Reporting & Metrics Uplift effort.

Note: codegen files were manually updated since oapi-codegen wasn't
available locally; should be regenerated via 'make codegen' for
correctness.

Signed-off-by: Shourya Pratap <shouryapuja130406@gmail.com>
@shouryapratap132006
shouryapratap132006 force-pushed the feat/oem-distribution-breakdown branch from fc9685b to 7d2de13 Compare August 15, 2026 09:59
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.

1 participant