Skip to content

Conversation

jmcarp
Copy link
Contributor

@jmcarp jmcarp commented Aug 13, 2025

Resolves #468.
Resolves #469.

@jmcarp jmcarp requested a review from a team as a code owner August 13, 2025 13:52
@jmcarp
Copy link
Contributor Author

jmcarp commented Aug 13, 2025

Manual acceptance testing, for now:

❯ TEST_ACC_NAME=TestAccAddressLot make testacc          
-> Running terraform acceptance tests
=== RUN   TestAccAddressLot
=== PAUSE TestAccAddressLot
=== CONT  TestAccAddressLot
--- PASS: TestAccAddressLot (1.91s)
PASS
ok  	github.com/oxidecomputer/terraform-provider-oxide/internal/provider	2.258s
❯ TEST_ACC_NAME=TestAccDataSourceAddressLot make testacc
-> Running terraform acceptance tests
=== RUN   TestAccDataSourceAddressLot
=== PAUSE TestAccDataSourceAddressLot
=== CONT  TestAccDataSourceAddressLot
--- PASS: TestAccDataSourceAddressLot (0.92s)
PASS
ok  	github.com/oxidecomputer/terraform-provider-oxide/internal/provider	1.270s

@jmcarp jmcarp force-pushed the jmcarp/address-lot branch 2 times, most recently from f8537d9 to 2d53051 Compare August 13, 2025 15:04
@internet-diglett
Copy link
Contributor

Looks like this resolves #306 as well

@sudomateo sudomateo linked an issue Aug 14, 2025 that may be closed by this pull request
Copy link
Collaborator

@sudomateo sudomateo left a comment

Choose a reason for hiding this comment

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

Nice work on this! I left some feedback to update documentation and to confirm that the nested id attribute within the blocks attribute is okay because we've seen issues with non-empty refresh plans in the past with such a setup. I've discussed this issue on other pull requests (#426 (comment)) if you're curious for context.


- `blocks` (Attributes Set) (see [below for nested schema](#nestedatt--blocks))
- `description` (String) Description for the address lot.
- `kind` (String) Kind for the address lot.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's note that this can be infra or pool.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

Comment on lines +108 to +111
"id": schema.StringAttribute{
Description: "ID of the address lot block.",
Computed: true,
},
Copy link
Collaborator

Choose a reason for hiding this comment

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

I've run into issues with nested computed attributes within sets before. The acceptance tests generally enforce that there's an empty refresh plan after applying a resource but the acceptance tests only use one block. Can you update the acceptance tests to use multiple blocks and see if there's any issue?

Alternatively, could you apply this resource with multiple blocks, dump the state file, run terraform refresh, and dump the state file again? I just want to ensure we're not shipping changes that'll result in non-empty refresh plans.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Applied the following resource:

resource "oxide_address_lot" "test" {
        description       = "a test address lot"
        name              = "terraform-acc-my-address-lot"
        kind              = "infra"
        blocks = [
                {
                        first_address = "172.0.1.1"
                        last_address  = "172.0.1.10"
                },
                {
                        first_address = "172.0.2.1"
                        last_address  = "172.0.2.10"
                },
        ]
}

Dump state: terraform state show oxide_address_lot.test > state-after-apply.

Refresh: terraform refresh.

Dump state again:terraform state show oxide_address_lot.test > state-after-refresh.

Get an empty diff with diff state-after-apply state-after-refresh.

This behavior, plus the passing acceptance test with multiple blocks, makes me think we're ok in this case.

Comment on lines +272 to +280
// Update updates the resource and sets the updated Terraform state on success.
// Note: the API doesn't currently support updating an Address Lot in place, so we leave this implementation blank and mark all attributes with RequiresReplace.
// TODO: support in-place updates.
func (r *addressLotResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) {
resp.Diagnostics.AddError(
"Error updating address lot",
"the oxide API currently does not support updating address lots",
)
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Some of our APIs don't have an update method but instead use the create method as both create and update. Can you quickly test whether a "patch" to the create endpoint is explicitly disallowed before we move forward with an error diag here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

joshcarp@j0sh ~/c/omicron (jmcarp/prereqs-omit-sudo)> oxide api -X PATCH /v1/system/networking/address-lot
error; status code: 405 Method Not Allowed
{
  "message": "Method Not Allowed",
  "request_id": "014253b3-a094-4af5-aeb6-cc76055ebe71"
}

Comment on lines +57 to +66
blocks = [
{
first_address = "172.0.1.1"
last_address = "172.0.1.10"
},
{
first_address = "172.0.10.1"
last_address = "172.0.10.10"
},
]
Copy link
Collaborator

Choose a reason for hiding this comment

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

Hm, you do already have multiple blocks in the test. I wonder if truly the nested computed attribute in sets is only an issue when it's nested deeper than the top level. The testing I asked for in another comment would show more.

Copy link
Collaborator

@sudomateo sudomateo left a comment

Choose a reason for hiding this comment

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

Just noting that this will also need a changelog entry.

@jmcarp jmcarp force-pushed the jmcarp/address-lot branch from 2d53051 to f8be494 Compare August 22, 2025 19:06
@jmcarp jmcarp force-pushed the jmcarp/address-lot branch from f8be494 to f2f5093 Compare August 22, 2025 19:43
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.

Create address lot data source Create address lot resource System Networking - Address Lots

3 participants