oxidecomputer / oxidecomputer/omicron

Store instance hostnames as validated strings in the DB

Open
#4,964 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

database nexus
Dominant language
Rust
Stars
572
Forks
97
Avg merge
2d 12h
Merged PRs (30d)
96

Description

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:

https://github.com/oxidecomputer/omicron/blob/8e26331a7502cbbeca4f5f871e24cb318aded382/nexus/db-model/src/instance.rs#L49-L54

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with nexus/db-model/src/instance.rs around the referenced hostname field, then trace the publicly returned instance view and the sled-agent API types. Compare the existing SQL wrapper types for unsigned integers and their ToSql/FromSql implementations. Done means the database model, returned view, and sled-agent paths all use the validated hostname newtype while existing invalid values remain handled.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust, sql
Domain
api, backend, databases
Issue type
Refactor
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.