Skip to content

Store instance hostnames as validated strings in the DB #4964

Open
@bnaecker

Description

@bnaecker

As part of #4938, we converted the InstanceCreate type to use a validated hostname. This ensures that all new instances have valid hostnames. However, to handle any existing instances which might have had invalid hostnames, we kept the hostname in the DB model type as a generic string:

// TODO-cleanup: We use a validated wrapper type in the API, but not in
// between the database. This is to handle existing names that do not pass
// the new validation. We should swap this for a SQL-serializable validated
// type.
#[diesel(column_name = hostname)]
pub hostname: String,

It's also a string in the publicly returned instance view type, as well as in the sled-agent's API. This issue tracks converting all those code paths to use a validated hostname newtype, so that we only ever work with valid hostnames for this field. This will require a small SQL wrapper type like we have for the various unsigned integers, that impls {To,From}Sql.

Metadata

Metadata

Assignees

No one assigned

    Labels

    databaseRelated to database accessnexusRelated to nexus

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions