-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support in-place instance ephemeral and floating IP changes #378
Comments
@askfongjojo I think there is an issue with the detach ephemeral IP endpoint. The attach one takes the name or ID of the IP pool to take the IP from, but the detach endpoint doesn't. Does it just detach everything? Is this the expected behaviour? If not, then I think that would block this issue for now. |
Closes #378. This patch updates the `oxide_instance` resource to support in-place modifications to its `external_ips` attribute. That is, the instance will no longer be destroyed and recreated when `external_ips` is modified. Instead, the instance will be stopped, external IPs will be detachd and/or attached, and the instance will be started. This patch also updates the `Read` method to refresh the external IPs attached to the instance. Previously, since the external IPs required a resource replacement there was no need to refresh them. There are 2 types of external IPs, ephemeral and floating. There can be at most 1 ephemeral external IP attached to an instance and any number of floating external IPs. That means in order to modify ephemeral external IPs the external IPs must be detached first and then attached. This patch needs the following work before it can be merged. - [ ] Add tests for the new `external_ips` modification logic. - [ ] Add validation logic to `external_ips` to enforce at most 1 ephemeral external IP. This was previously "validated" during instance creation but is not updated during instance update. Here's the error that's returned when an instance is created with more than 1 ephemeral external IP. ``` oxide_instance.foo: Creating... ╷ │ Error: Error creating instance │ │ with oxide_instance.foo, │ on main.tf line 24, in resource "oxide_instance" "foo": │ 24: resource "oxide_instance" "foo" { │ │ API error: POST https://oxide.example.com/v1/instances?project=5476ccc9-464d-4dc4-bfc0-5154de1c986f │ ----------- RESPONSE ----------- │ Status: 400 InvalidRequest │ Message: An instance may not have more than 1 ephemeral IP address │ RequestID: fc6144e5-fa76-4583-a024-2e49ce17140e │ ------- RESPONSE HEADERS ------- │ Content-Type: [application/json] │ X-Request-Id: [fc6144e5-fa76-4583-a024-2e49ce17140e] │ Date: [Thu, 09 Jan 2025 03:28:48 GMT] │ Content-Length: [166] │ ╵ ```
I didn't see this comment until after I already started working on this issue in #381. An instance can only have 1 ephemeral external IP attached at a time. That means the API will have the following behavior.
|
Closes #378. This patch updates the `oxide_instance` resource to support in-place modifications to its `external_ips` attribute. That is, the instance will no longer be destroyed and recreated when `external_ips` is modified. Instead, the instance will be stopped, external IPs will be detachd and/or attached, and the instance will be started. This patch also updates the `Read` method to refresh the external IPs attached to the instance. Previously, since the external IPs required a resource replacement there was no need to refresh them. There are 2 types of external IPs, ephemeral and floating. There can be at most 1 ephemeral external IP attached to an instance and any number of floating external IPs. That means in order to modify ephemeral external IPs the external IPs must be detached first and then attached. This patch needs the following work before it can be merged. - [ ] Add tests for the new `external_ips` modification logic. - [ ] Add validation logic to `external_ips` to enforce at most 1 ephemeral external IP. This was previously "validated" during instance creation but is not updated during instance update. Here's the error that's returned when an instance is created with more than 1 ephemeral external IP. ``` oxide_instance.foo: Creating... ╷ │ Error: Error creating instance │ │ with oxide_instance.foo, │ on main.tf line 24, in resource "oxide_instance" "foo": │ 24: resource "oxide_instance" "foo" { │ │ API error: POST https://oxide.example.com/v1/instances?project=5476ccc9-464d-4dc4-bfc0-5154de1c986f │ ----------- RESPONSE ----------- │ Status: 400 InvalidRequest │ Message: An instance may not have more than 1 ephemeral IP address │ RequestID: fc6144e5-fa76-4583-a024-2e49ce17140e │ ------- RESPONSE HEADERS ------- │ Content-Type: [application/json] │ X-Request-Id: [fc6144e5-fa76-4583-a024-2e49ce17140e] │ Date: [Thu, 09 Jan 2025 03:28:48 GMT] │ Content-Length: [166] │ ╵ ```
Yes, unlike floating IP, each instance can have no more than one ephemeral IP. We can model after how it works on the web console which already makes use of the attach/detach APIs. |
Thanks for the clarification! |
Overview
Currently, a change in the instance external IP spec results in a forced replacement in
terraform apply
, e.g.There is API support to dynamically attach/detach floating IP and ephemeral IP without the need to stop/start the instance. We can improve the user experience and instance uptime by having
terraform apply
make those external IP changes without recreating instnaces.Implementation details
No response
Anything else you would like to add?
No response
The text was updated successfully, but these errors were encountered: