Skip to content

Conversation

charliepark
Copy link
Contributor

@charliepark charliepark commented Sep 12, 2024

This adds a column for Transit IPs to the Instance NIC table …
Screenshot 2024-09-12 at 1 07 11 PM

… and an update to the NIC edit form:
Screenshot 2024-09-17 at 8 49 56 AM

It is worth noting that it is currently the case with the API that transitIps can be added to an existing InstanceNetworkingInterface — https://github.com/oxidecomputer/console/blob/main/app/api/__generated__/Api.ts#L1902-L1918 — but not passed in when creating a new one — https://github.com/oxidecomputer/console/blob/main/app/api/__generated__/Api.ts#L1801-L1813. We might change this in a future PR once we get clarity about the intent of that feature, but I want to keep this PR scoped to the existing API.

Closes #2381

Copy link

vercel bot commented Sep 12, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
console ✅ Ready (Inspect) Visit Preview Sep 19, 2024 10:41pm

@charliepark
Copy link
Contributor Author

charliepark commented Sep 13, 2024

Current state of this UI:

Screenshot 2024-09-13 at 4 15 07 PM

Not sure what I think about that new tab link icon inlined there. Maybe fine.

@charliepark
Copy link
Contributor Author

I passed the Vercel preview link to Angela for review, and she said the new column and updated form look good.

@charliepark charliepark marked this pull request as ready for review September 17, 2024 15:39
@charliepark
Copy link
Contributor Author

For posterity, here's the current state of the UI:

Screenshot 2024-09-17 at 9 48 25 AM

@david-crespo
Copy link
Collaborator

david-crespo commented Sep 17, 2024

Looks great! Hm, what do you think about collapsing it under an Advanced thing like we do on some other forms? The argument against would be that the main reason anyone would want to use this form ever is to make a NIC with some transit IPs. The other argument against is that it's much less obtrusive than in that screenshot when you haven't actually added any.

@charliepark
Copy link
Contributor Author

I'm inclined to not tuck it into a collapsible Advanced section. The form is such a simple one (name, description), I don't think including the Transit IPs section overwhelms the user. I think it makes sense on something like Instance Create because the form has so much going on.

@david-crespo
Copy link
Collaborator

david-crespo commented Sep 19, 2024

I think we might have to do some client-side validation of the IPs to get a decent experience around malformed transit IPs. The alternative would be to catch the server's validation error and turn it into something more usable, but I think client-side validation preventing the whole error in the first place would be both easier and more maintainable.

This is what I get pointing local dev at dogfood:

2024-09-19-bad-transit-ip-validation.mp4

We do have a validateIp function that uses rather elaborate regexes, but I don't think they handle CIDR blocks, so I guess we'll want to add that somehow.

console/app/util/str.ts

Lines 57 to 67 in 1625d02

const IPV4_REGEX =
/^(?:(?:[1-9]|1\d|2[0-4])?\d|25[0-5])(?:\.(?:(?:[1-9]|1\d|2[0-4])?\d|25[0-5])){3}$/u
const IPV6_REGEX =
/^(?:(?:[\da-f]{1,4}:){7}[\da-f]{1,4}|(?:[\da-f]{1,4}:){1,7}:|(?:[\da-f]{1,4}:){1,6}:[\da-f]{1,4}|(?:[\da-f]{1,4}:){1,5}(?::[\da-f]{1,4}){1,2}|(?:[\da-f]{1,4}:){1,4}(?::[\da-f]{1,4}){1,3}|(?:[\da-f]{1,4}:){1,3}(?::[\da-f]{1,4}){1,4}|(?:[\da-f]{1,4}:){1,2}(?::[\da-f]{1,4}){1,5}|[\da-f]{1,4}:(?::[\da-f]{1,4}){1,6}|:(?:(?::[\da-f]{1,4}){1,7}|:)|fe80:(?::[\da-f]{0,4}){0,4}%[\da-z]+|::(?:f{4}(?::0{1,4})?:)?(?:(?:25[0-5]|(?:2[0-4]|1?\d)?\d)\.){3}(?:25[0-5]|(?:2[0-4]|1?\d)?\d)|(?:[\da-f]{1,4}:){1,4}:(?:(?:25[0-5]|(?:2[0-4]|1?\d)?\d)\.){3}(?:25[0-5]|(?:2[0-4]|1?\d)?\d))$/iu
export const validateIp = (ip: string) => {
const isv4 = IPV4_REGEX.test(ip)
const isv6 = !isv4 && IPV6_REGEX.test(ip)
return { isv4, isv6, valid: isv4 || isv6 }
}

We're already using the impressive and robust-seeming ip-num library in the mock server

import { IPv4, IPv6 } from 'ip-num/IPNumber.js'

...but we're not yet using it anywhere in the app code. I wonder if we could replace our IPv4 and IPv6 regexes with calls to this library, as well as using it to validate IP networks.

// TODO: if we were really cool we could check first <= last but it would add
// 6k gzipped to the bundle with ip-num

@david-crespo
Copy link
Collaborator

As discussed in chat, I'm working on some IP network validation utilities. I think we should merge this without validation and add it as a followup.

@david-crespo david-crespo mentioned this pull request Sep 20, 2024
9 tasks
Copy link
Collaborator

@david-crespo david-crespo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! We will follow up with IP address and network validation.

@david-crespo david-crespo merged commit e0d52ef into main Sep 20, 2024
8 checks passed
@david-crespo david-crespo deleted the add-transit-ips-column branch September 20, 2024 20:31
david-crespo added a commit to oxidecomputer/omicron that referenced this pull request Oct 3, 2024
oxidecomputer/console@5561f28...073471c

* [073471c4](oxidecomputer/console@073471c4) mock api: disks are created straight into detached state
* [612ec90c](oxidecomputer/console@612ec90c) oxidecomputer/console#2485
* [614f1bb5](oxidecomputer/console@614f1bb5) oxidecomputer/console#2466
* [df2dc14c](oxidecomputer/console@df2dc14c) bump vite related deps for a weird vuln
* [a030b9e0](oxidecomputer/console@a030b9e0) oxidecomputer/console#2464
* [dec48497](oxidecomputer/console@dec48497) oxidecomputer/console#2461
* [e46216aa](oxidecomputer/console@e46216aa) oxidecomputer/console#2482
* [0d897efe](oxidecomputer/console@0d897efe) oxidecomputer/console#2479
* [f88790db](oxidecomputer/console@f88790db) oxidecomputer/console#2478
* [d634c8f0](oxidecomputer/console@d634c8f0) oxidecomputer/console#2477
* [eeaa14c3](oxidecomputer/console@eeaa14c3) oxidecomputer/console#2475
* [5ece6e18](oxidecomputer/console@5ece6e18) oxidecomputer/console#2467
* [4b699e01](oxidecomputer/console@4b699e01) oxidecomputer/console#2448
* [9c9dc149](oxidecomputer/console@9c9dc149) oxidecomputer/console#2465
* [1aa0fc9b](oxidecomputer/console@1aa0fc9b) oxidecomputer/console#2463
* [57db4054](oxidecomputer/console@57db4054) oxidecomputer/console#2462
* [da7fe328](oxidecomputer/console@da7fe328) oxidecomputer/console#2460
* [e0d52efd](oxidecomputer/console@e0d52efd) oxidecomputer/console#2437
* [1625d02a](oxidecomputer/console@1625d02a) oxidecomputer/console#2458
* [fd82458e](oxidecomputer/console@fd82458e) oxidecomputer/console#2457
* [7daaa337](oxidecomputer/console@7daaa337) oxidecomputer/console#2453
david-crespo added a commit to oxidecomputer/omicron that referenced this pull request Oct 3, 2024
oxidecomputer/console@5561f28...073471c

* [073471c4](oxidecomputer/console@073471c4)
mock api: disks are created straight into detached state
* [612ec90c](oxidecomputer/console@612ec90c)
oxidecomputer/console#2485
* [614f1bb5](oxidecomputer/console@614f1bb5)
oxidecomputer/console#2466
* [df2dc14c](oxidecomputer/console@df2dc14c)
bump vite related deps for a weird vuln
* [a030b9e0](oxidecomputer/console@a030b9e0)
oxidecomputer/console#2464
* [dec48497](oxidecomputer/console@dec48497)
oxidecomputer/console#2461
* [e46216aa](oxidecomputer/console@e46216aa)
oxidecomputer/console#2482
* [0d897efe](oxidecomputer/console@0d897efe)
oxidecomputer/console#2479
* [f88790db](oxidecomputer/console@f88790db)
oxidecomputer/console#2478
* [d634c8f0](oxidecomputer/console@d634c8f0)
oxidecomputer/console#2477
* [eeaa14c3](oxidecomputer/console@eeaa14c3)
oxidecomputer/console#2475
* [5ece6e18](oxidecomputer/console@5ece6e18)
oxidecomputer/console#2467
* [4b699e01](oxidecomputer/console@4b699e01)
oxidecomputer/console#2448
* [9c9dc149](oxidecomputer/console@9c9dc149)
oxidecomputer/console#2465
* [1aa0fc9b](oxidecomputer/console@1aa0fc9b)
oxidecomputer/console#2463
* [57db4054](oxidecomputer/console@57db4054)
oxidecomputer/console#2462
* [da7fe328](oxidecomputer/console@da7fe328)
oxidecomputer/console#2460
* [e0d52efd](oxidecomputer/console@e0d52efd)
oxidecomputer/console#2437
* [1625d02a](oxidecomputer/console@1625d02a)
oxidecomputer/console#2458
* [fd82458e](oxidecomputer/console@fd82458e)
oxidecomputer/console#2457
* [7daaa337](oxidecomputer/console@7daaa337)
oxidecomputer/console#2453
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Instance networking tab to support add/remove transit IPs
2 participants