Skip to content

Validate disk size against image size on disk create form #1773

Open

Description

@david-crespo

On instance create, we validate the size of the boot disk against the size of the chosen image, and when you change the image, we update the size to be big enough for it if necessary.

// Imitate API logic: only require that the disk is big enough to fit the image
validate={(diskSizeGiB) => {
if (!image) return true
if (diskSizeGiB < image.size / GiB) {
const minSize = Math.ceil(image.size / GiB)
return `Must be as large as selected image (min. ${minSize} GiB)`
}
if (diskSizeGiB > MAX_DISK_SIZE_GiB) {
return `Can be at most ${MAX_DISK_SIZE_GiB} GiB`
}
}}

On the standalone disk create form, we don't do that, and we should.

<DiskSizeField name="size" control={form.control} />

Activity

  1. david-crespo commented on Nov 30, 2023

    @david-crespo
    CollaboratorAuthor

    This could be worth picking up @charliepark if you become an expert on this while working on #1823.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions