Repository navigation
[release] feat(lib-cloudinfo): model cloudinfo storage facts and /storage prices (2.1.0) - #131
Conversation
…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.
pditommaso
left a comment
There was a problem hiding this comment.
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
Booleanflags can throw a NullPointerException when unboxed - the null-
volumesdefault gives an unmodifiable list and is missing whenStoragePricesis 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); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
pditommaso
left a comment
There was a problem hiding this comment.
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: 404returns empty now. On cloudinfomasterthe/storagehandler'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/storagewith a plain-text404 page not found, which now throws as documented. - Boolean flags: I round-tripped all four through Jackson. They keep their wire names, an explicit
nulldecodes tofalse, andequalsholds 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
statusfield, 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 checkingtitle/typewould close it. cloudinfo sendsapplication/json, notapplication/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.
…storage 404 as no prices
|
@pditommaso follow-ups from your notes: |
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
/storageendpoint 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 addsgetStoragePrices, 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).ebs*bandwidth, throughput and IOPS,instanceStoreGB,gpuMemoryMiB.supportedEphemeralOSDiskPlacements,premiumIOandmaxDataDiskCount.acceleratorType,localSsdGiB,attachableLocalSsdCounts,bootDiskTypes,isSharedCpu, and so on.booleans and an absent flag reads asfalse.CloudInfoClient.getStoragePrices(provider, region): returnsOptional<StoragePrices>.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 problemdetail.StoragePrices.getVolumes()is never null.StoragePrices,VolumePriceandVolumeTier. A price component that isn't billed, or can't be reduced to one rate (e.g. io2 IOPS), staysnull, not0.Tests
/storagepayloads for AWS, Azure and GCP, plus a pre-0.25.0 product with none of the new fields.types.go. The asserted values come from cloudinfo's own live-captured test data.Unblocks
lib-cloudinfo:2.1.0and bump thecloudinfo-cache-v4cache key. Until cloudinfo 0.25.0 is deployed,getStoragePricesthrows (a plain 404), so sched must catchCloudInfoExceptionand fall back to its own prices.🤖 Generated with Claude Code