Skip to content

fix(gcp): preserve string MEMORY amounts during recommendation conversion #164

Description

@cristim

The Compute Engine recommendation converter silently drops a MEMORY amount represented as a decimal string. Follow-up to #80 / #163; this is separate from #60's commitment-type extraction.

At commit 4c298ec7bfcbec4d41fa37922e6d0591a7fbfb7f, memoryMBFromOperationGroups accepts only structpb.Value_NumberValue. The Compute API resource schema documents resources[].amount as string (int64). Explicit VCPU amounts support this representation after #163; memory does not.

Local reproduction in package computeengine, using the existing synthetic commitmentOnlyCUDRecommendation() fixture:

input := commitmentOnlyCUDRecommendation()
input.Content.OperationGroups[0].Operations[1].GetValue().Kind = structpb.NewStringValue("6144").Kind
rec, err := (&Client{}).convertGCPRecommendation(context.Background(), input, common.RecommendationParams{})
amount, memoryErr := memoryMBFromDetails(*rec)

Observed: conversion returns no error, Count=4, amount=0, and memoryErr says the MEMORY resource amount is absent. The otherwise identical numeric 6144 control returns amount=6144 with no error. The recommendation loses supplied memory; a consumer requiring explicit memory rejects it.

Evidence scope: executed locally against the exact commit using a Go test overlay. The fixture is generic-contract data, not a captured service response. It also lacks a machine type and is already unpurchasable for that independent reason. No purchase or live service incompatibility was demonstrated.

Acceptance: preserve valid string/int64 MEMORY amounts and existing supported numeric values; reject malformed or unsafe values explicitly; exercise conversion through the public SDK/provider path with a numeric control. Keep resource identity handling in a separate change.

Dedup checked #60, #61, #71, #105, #52 and all-state memory/amount searches. Triage: medium severity, limited demonstrated impact, this quarter, small effort, P2. Current service emission frequency remains unknown.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions