Skip to content

[release] feat(lib-cloudinfo): model cloudinfo storage facts and /storage prices (2.1.0) - #131

Merged
jordeu merged 4 commits into
masterfrom
task/lib-cloudinfo-2-1-0-model-cloudinfo-stor-596
Sep 29, 2026
Merged

jordeu merged 4 commits into
masterfrom
task/lib-cloudinfo-2-1-0-model-cloudinfo-stor-596

Conversation

@jordeu

@jordeu jordeu commented Sep 28, 2026 •

Copy link
Copy Markdown
Member

Abstract

cloudinfo 0.25.0 (seqeralabs/cloudinfo#95) serves two new things. Each instance type now carries disk and GPU facts (AWS EBS limits, Azure SKU disk capabilities, GCP local SSD and boot disk types), and a new /storage endpoint serves per-region disk prices. lib-cloudinfo 2.0.0 ignores unknown fields, so sched can't read any of this yet. This PR models the new fields and adds getStoragePrices, so sched can stop calling cloud APIs at launch and drop its hand-kept price tables. The change is additive, so it ships as 2.1.0.

Changes

  • CloudProduct: 30 new fields, under cloudinfo's own per-cloud names, null when not reported (except the flags below).
    • AWS: ebs* bandwidth, throughput and IOPS, instanceStoreGB, gpuMemoryMiB.
    • Azure: SKU capabilities such as supportedEphemeralOSDiskPlacements, premiumIO and maxDataDiskCount.
    • GCP: acceleratorType, localSsdGiB, attachableLocalSsdCounts, bootDiskTypes, isSharedCpu, and so on.
    • Flags: cloudinfo omits them when false, so they are primitive booleans and an absent flag reads as false.
  • CloudInfoClient.getStoragePrices(provider, region): returns Optional<StoragePrices>.
    • It is empty only on cloudinfo's RFC 7807 404 problem, returned for enabled providers without storage pricing and for known regions not scraped yet.
    • Any other 404 throws CloudInfoException: a backend older than 0.25.0, a wrong endpoint or a proxy. So does an unknown provider or region (400), and any other failure. Error messages include the server's problem detail.
    • StoragePrices.getVolumes() is never null.
  • New models: StoragePrices, VolumePrice and VolumeTier. A price component that isn't billed, or can't be reduced to one rate (e.g. io2 IOPS), stays null, not 0.
  • Release: VERSION bumped to 2.1.0, with a changelog entry and README docs.

Tests

  • Decoding: new tests decode products and /storage payloads for AWS, Azure and GCP, plus a pre-0.25.0 product with none of the new fields.
  • Client: mock tests for the storage URL, the problem 404 → empty, non-problem 404s → exception, and 400 with detail.
  • Fixture caveat: cloudinfo 0.25.0 isn't deployed yet, so the fixtures were built by hand from cloudinfo's types.go. The asserted values come from cloudinfo's own live-captured test data.

Unblocks

  • seqeralabs/sched#1318, #1414, #1411 and #1406.
  • A sched follow-up is still needed: bump to lib-cloudinfo:2.1.0 and bump the cloudinfo-cache-v4 cache key. Until cloudinfo 0.25.0 is deployed, getStoragePrices throws (a plain 404), so sched must catch CloudInfoException and fall back to its own prices.

🤖 Generated with Claude Code

…s (2.1.0)

Add the per-instance-type disk and GPU fields that cloudinfo 0.25.0
(seqeralabs/cloudinfo#95) serves on products, under each cloud's own
names, and CloudInfoClient.getStoragePrices(provider, region) for the
new /storage endpoint with the StoragePrices, VolumePrice and
VolumeTier models. A 404 (provider or region without storage prices)
returns Optional.empty() so callers can fall back to their own prices.
@jordeu
jordeu marked this pull request as ready for review September 28, 2026 05:01
@jordeu
jordeu requested a review from pditommaso September 28, 2026 05:01

@pditommaso pditommaso left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for this. I checked the new CloudProduct fields and the StoragePrices / VolumePrice / VolumeTier models against cloudinfo master, and the JSON names and value types all match. The route path and the 404/400 behaviour match the handler too.

Three items to fix before merge (marked Requested change):

  • a 404 from anything other than "no prices" is hidden as an empty result
  • the nullable Boolean flags can throw a NullPointerException when unboxed
  • the null-volumes default gives an unmodifiable list and is missing when StoragePrices is decoded outside the client

The others are marked Nice to have and are fine to do as follow-ups.

* @throws CloudInfoException if the request fails with any status other than 200 or 404
*/
public Optional<StoragePrices> getStoragePrices(String provider, String region) {
String path = String.format("/api/v1/providers/%s/services/compute/regions/%s/storage", provider, region);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nice to have: provider and region go into the URL path unescaped.

A region containing ? or # (e.g. us-east-1?x) makes URI.create parse the rest as a query or fragment, so a different URL is requested and the 404 comes back as Optional.empty(). A space throws IllegalArgumentException, which gets wrapped without a status. The other methods have the same issue, but only here does it end in a silent "no prices" result.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Agreed. It affects all methods, so I'll do it in a follow-up.

* @return the region's storage prices, or empty when CloudInfo has none
* @throws CloudInfoException if the request fails with any status other than 200 or 404
*/
public Optional<StoragePrices> getStoragePrices(String provider, String region) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nice to have: this is a fourth near-copy of the same request code (build, send, check status, decode, wrap exception) already in getRegions, getProducts and getFamilies.

Any change to timeouts, headers, logging or error wrapping now has to be made in four places, and they already differ (only familiesError parses the body). A private helper such as HttpResponse<String> get(String url, Duration timeout, String what) would remove the duplication. This could be a follow-up.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Agreed. It affects all methods, so I'll do it in a follow-up.

…d volumes

- getStoragePrices returns empty only on cloudinfo's RFC 7807 404 problem;
  any other 404 (old backend, wrong endpoint, proxy) throws.
- Error messages for /storage and /families carry the server's error or
  problem detail (ErrorResponse gains status and detail).
- The four omitempty flags on CloudProduct are primitive booleans.
- StoragePrices.getVolumes() is never null and always mutable.
@jordeu
jordeu requested a review from pditommaso September 28, 2026 05:47

@pditommaso pditommaso left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks, all three requested changes are addressed. I checked 07b1f9e against cloudinfo master and ran :lib-cloudinfo:test locally: all green.

  • 404 handling: only a problem body with status: 404 returns empty now. On cloudinfo master the /storage handler's only error is "storage prices not yet cached", and there is no custom catch-all 404 route. Prod is still on 0.23.0 and answers /storage with a plain-text 404 page not found, which now throws as documented.
  • Boolean flags: I round-tripped all four through Jackson. They keep their wire names, an explicit null decodes to false, and equals holds after the round-trip.
  • volumes: a null or absent list decodes to an empty, mutable list, including outside the client.

Two minor notes, not blocking:

  • 404 check: it looks only at the body's status field, so a proxy that sends a JSON 404 carrying "status":404 (Spring Boot's default error body does) would still read as "no prices". This can't happen with the current ingress. Also checking title/type would close it. cloudinfo sends application/json, not application/problem+json, so the content type can't be used.
  • Follow-ups: please open an issue for the URL-escaping and shared-request-helper follow-ups so they don't get lost.

@jordeu

jordeu commented Sep 29, 2026

Copy link
Copy Markdown
Member Author

@pditommaso follow-ups from your notes: 9690958 also requires "title":"Not Found" before a 404 counts as no prices (a Spring Boot-style JSON 404 now throws), and #136 tracks path escaping and the shared request helper.

@jordeu
jordeu merged commit cc4f44e into master Sep 29, 2026
3 checks passed
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.

2 participants