Skip to content

Simplify IpPoolSelector and call sites#3032

Merged
david-crespo merged 4 commits intoipv6_migrationfrom
simplify-ip-selector
Feb 4, 2026
Merged

Simplify IpPoolSelector and call sites#3032
david-crespo merged 4 commits intoipv6_migrationfrom
simplify-ip-selector

Conversation

@david-crespo
Copy link
Collaborator

@david-crespo david-crespo commented Feb 4, 2026

IpPoolSelector is used on instance create, floating IP create, and ephemeral IP attach, but most of the logic inside only applied to instance create. Here I:

  • Move logic that syncs the selected pool with the selected IP stack on the network interface of out IpPoolSelector and into instance create (the only call site that cares)
    • The IpPoolSelector props are simpler — removed ipVersionFieldName, currentPool, and setValue
  • Move default pool logic out of useEffects and into useForm defaultValues
    • In order to do this, floating IP create now prefetches pools via loader instead of fetching lazily with useQuery
  • Floating IP create no longer hides the pool selector behind the "Advanced" accordion — it's now always visible
  • Derive ipVersion at submit time instead of keeping track of it in the form state

I don't think any actual behavior should change here.

@vercel
Copy link

vercel bot commented Feb 4, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
console Ready Ready Preview Feb 4, 2026 9:56pm

Request Review

setValue(ipVersionFieldName, selectedPool.ipVersion)
}
}
}, [currentPool, sortedPools, ipVersionFieldName, setValue])
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

this is not necessary at all if you derive it at submit time

ipVersionFieldName,
setValue,
autoSelectDefault,
])
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think this is only really necessary for instance create because that's the only one where the stack can change. We calculate it for ephemeral IP modal but we can do it once up front because it's in the context of an instance where the stack is fixed.

type: 'auto',
// v4 fallback here should maybe be an error instead because
// it probably won't work on the API side
ipVersion: hasV4Default ? 'v4' : hasV6Default ? 'v6' : 'v4',
Copy link
Collaborator Author

@david-crespo david-crespo Feb 4, 2026

Choose a reason for hiding this comment

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

Note v4 fallback where when there are no defaults doesn't really make sense because auto will fail in that case. What we should do is make the user pick. The simplest thing would be to always make the user pick and just not use the auto side here.

Copy link
Contributor

Choose a reason for hiding this comment

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

I believe this is now how you have it, where the form is disabled with the No default compatible pool available; select a pool to continue message, so I don't know that anyone is going to end up hitting this.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ah, that's right. Insight applied here for more cleanup 72b671a

Copy link
Contributor

@charliepark charliepark left a comment

Choose a reason for hiding this comment

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

So clean

@david-crespo david-crespo merged commit 40eddff into ipv6_migration Feb 4, 2026
7 checks passed
@david-crespo david-crespo deleted the simplify-ip-selector branch February 4, 2026 23:01
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.

2 participants