Skip to content

Adopt larger unit sizes for data fields #518

@lgfa29

Description

@lgfa29

Overview

The Oxide API receives data fields as bytes, but this creates a bad user experience for Terraform where users are forced to type and manage long numbers that are hard to read and easy to mistype.

Instead of receiving byte values, the provider should follow the Oxide dashboard and operate at the gigabyte resolution, since disks and instance memory sizes are often of this order of magnitude.

It can also automatically adjust values when converting them to byte to ensure they meet specific API constraints, such as disk sizes being required to be a multiple of the disk block size.

Implementation details

The migration path needs to be handled with care to ensure that updating the provider does not trigger a diff and potential destructive actions.

One approach could be to deprecate the existing fields and use a new unit suffixed attribute (like memory_gb), but it should also be possible to keep the existing attribute and infer its unit based on size.

A 10GiB disk would be written as 126080778240 bytes, which is far too big to be interpreted as gigabytes. So if a number is larger than a given threshold (for example, 1048576) it's safe to assume the user intended to specify it as bytes and not gigabytes (petabyte disks and VMs are not currently supported).

When a byte value is detected, the provider should warn the user to update their configuration.

Anything else you would like to add?

No response

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