Skip to content
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

Instance network interfaces don't need to be paginated (#1009) #1164

Conversation

ryaeng
Copy link
Contributor

@ryaeng ryaeng commented Jun 6, 2022

Removed page params from entrypoint, app, and db calls.

…#1009)

Removed page params from entrypoint, app, and db calls.
@smklein smklein requested a review from david-crespo June 7, 2022 13:43
.filter(dsl::time_deleted.is_null())
.filter(dsl::instance_id.eq(authz_instance.id()))
.filter(dsl::vpc_id.eq(authz_instance.id()))
Copy link
Contributor

Choose a reason for hiding this comment

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

It seems you're checking if the vpc_id equals the instance ID — that can't be right.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@david-crespo What's a good way to test this?

Copy link
Collaborator

@bnaecker bnaecker Jun 15, 2022

Choose a reason for hiding this comment

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

I believe this would be caught by the existing integration tests. Specifically, this call here fetches the existing NICs attached to an instance. I can't see how that would return anything if the wrong UUID were used.

Can you show the output of your tests against this commit?

Copy link
Contributor

Choose a reason for hiding this comment

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

If you look at CI on this commit, the tests passed even when that bug was in place

c563bfe

@david-crespo
Copy link
Contributor

Thank you for your contribution. I have been meaning to make a similar change at some point.

nexus/src/db/datastore.rs Outdated Show resolved Hide resolved
@ryaeng
Copy link
Contributor Author

ryaeng commented Jun 7, 2022

I'll have these fixed momentarily.

What's the best way to amend this PR with the changes?

@bnaecker
Copy link
Collaborator

bnaecker commented Jun 7, 2022

@ryaeng Pushing a new commit is fine. It'll all be squashed at merge time.

@ryaeng
Copy link
Contributor Author

ryaeng commented Jun 7, 2022

@ryaeng Pushing a new commit is fine. It'll all be squashed at merge time.

Awesome! Thanks.

@ryaeng
Copy link
Contributor Author

ryaeng commented Jun 7, 2022

Done

@david-crespo
Copy link
Contributor

This is looking pretty good. The reason I haven't merged is I'm mulling over whether the endpoint should still return ResultsPage<NetworkInterface>, which has the items key with the items and a next_page key will which always be null. If you look at firewall rules, which are similarly not paginated

async fn vpc_firewall_rules_get(
rqctx: Arc<RequestContext<Arc<ServerContext>>>,
path_params: Path<VpcPathParam>,
) -> Result<HttpResponseOk<VpcFirewallRules>, HttpError> {

we return a dedicated struct that just has the rules on it:

/// Collection of a [`Vpc`]'s firewall rules
#[derive(Clone, Debug, Deserialize, Serialize, JsonSchema)]
pub struct VpcFirewallRules {
pub rules: Vec<VpcFirewallRule>,
}

That is probably what we should do here too, though I would prefer it live in nexus/src/external_api/views.rs rather than omicron_common spot.

@zephraph
Copy link
Contributor

zephraph commented Jun 9, 2022

ResultsPage should be used only for paginated endpoints. Not doing so introduces ambiguity into the API that'd be a potential point of confusion for users.

@ryaeng
Copy link
Contributor Author

ryaeng commented Jun 9, 2022

I'll make this happen tomorrow, fellas.

- Modify instance_network_interfaces_get to return NetworkInterfaces
@ryaeng
Copy link
Contributor Author

ryaeng commented Jun 13, 2022

Got this done. Spent a couple of hours working on it before I realized I was comparing it to subnets and not firewall rules 🤦‍♂️.

What is the rule for creating tests? Trying to determine whether this change needs a test or not. Seems rather trivial so I didn't include one but I can fix that if necessary.

@ryaeng
Copy link
Contributor Author

ryaeng commented Jun 13, 2022

Seems there's a conflict. Lemme pull that in real quick and then I'll perform another push.

@david-crespo
Copy link
Contributor

Ok, this is good! Thank you!

Re: tests, I would have said no additional test is required beyond what we already have for basic functionality, but the vpc_id == instance_id mistake was not caught by any existing test. So if you want to add one that would have caught that, that would be great.

Add test to list interfaces attached to an instance
- Create test for instance_network_interfaces_get
- Replace object_get with helper function across tests
- Fix typos
@ryaeng
Copy link
Contributor Author

ryaeng commented Jun 23, 2022

@david-crespo Came back around to this one. Should be up to par. Thanks.

@david-crespo
Copy link
Contributor

Thanks for your work on this @ryaeng, but in #1495 we decided that even an endpoint with a capped-length result set should still return the paginated interface for consistency (and flexibility, in case we paginate later). So I'm going to close this and leave the endpoint as-is.

leftwo pushed a commit that referenced this pull request Mar 4, 2024
Crucible changes:
Per client, queue-based backpressure (#1186)
A builder for the Downstairs Downstairs struct. (#1152)
Update Rust to v1.76.0 (#1153)
Deactivate the read only parent after a scrub (#1180)
Start byte-based backpressure earlier (#1179)
Tweak CI scripts to fix warnings (#1178)
Make `gw_ds_complete` less public (#1175)
Verify extent under repair is valid after copying files (#1159)
Remove individual panic setup, use global panic settings (#1174)
[smf] Use new zone network config service (#1096)
Move a few methods into downstairs (#1160)
Remove extra clone in upstairs read (#1163)
Make `crucible-downstairs` not depend on upstairs (#1165)
Update Rust crate rusqlite to 0.31 (#1171)
Update Rust crate reedline to 0.29.0 (#1170)
Update Rust crate clap to 4.5 (#1169)
Update Rust crate indicatif to 0.17.8 (#1168)
Update progenitor to bc0bb4b (#1164)
Do not 500 on snapshot delete for deleted region (#1162)
Drop jobs from Offline downstairs. (#1157)
`Mutex<Work>` → `Work` (#1156)
Added a contributing.md (#1158)
Remove ExtentFlushClose::source_downstairs (#1154)
Remove unnecessary mutexes from Downstairs (#1132)

Propolis changes:
PHD: improve Windows reliability (#651)
Update progenitor and omicron deps
Clean up VMM resource on server shutdown
Remove Inventory mechanism
Update vergen dependency
Properly handle pre/post illumos#16183 fixups
PHD: add `pfexec` to xtask phd-runner invocation (#647)
PHD: add Windows Server 2016 adapter & improve WS2016/2019 reliability (#646)
PHD: use `clap` for more `cargo xtask phd` args (#645)
PHD: several `cargo xtask phd` CLI fixes (#642)
PHD: Use ZFS clones for file-backed disks (#640)
PHD: improve ctrl-c handling (#634)
leftwo added a commit that referenced this pull request Mar 4, 2024
Crucible changes:
Per client, queue-based backpressure (#1186)
A builder for the Downstairs Downstairs struct. (#1152) Update Rust to
v1.76.0 (#1153)
Deactivate the read only parent after a scrub (#1180) Start byte-based
backpressure earlier (#1179)
Tweak CI scripts to fix warnings (#1178)
Make `gw_ds_complete` less public (#1175)
Verify extent under repair is valid after copying files (#1159) Remove
individual panic setup, use global panic settings (#1174) [smf] Use new
zone network config service (#1096)
Move a few methods into downstairs (#1160)
Remove extra clone in upstairs read (#1163)
Make `crucible-downstairs` not depend on upstairs (#1165) Update Rust
crate rusqlite to 0.31 (#1171)
Update Rust crate reedline to 0.29.0 (#1170)
Update Rust crate clap to 4.5 (#1169)
Update Rust crate indicatif to 0.17.8 (#1168)
Update progenitor to bc0bb4b (#1164)
Do not 500 on snapshot delete for deleted region (#1162) Drop jobs from
Offline downstairs. (#1157)
`Mutex<Work>` → `Work` (#1156)
Added a contributing.md (#1158)
Remove ExtentFlushClose::source_downstairs (#1154) Remove unnecessary
mutexes from Downstairs (#1132)

Propolis changes:
PHD: improve Windows reliability (#651)
Update progenitor and omicron deps
Clean up VMM resource on server shutdown
Remove Inventory mechanism
Update vergen dependency
Properly handle pre/post illumos#16183 fixups
PHD: add `pfexec` to xtask phd-runner invocation (#647) PHD: add Windows
Server 2016 adapter & improve WS2016/2019 reliability (#646) PHD: use
`clap` for more `cargo xtask phd` args (#645) PHD: several `cargo xtask
phd` CLI fixes (#642)
PHD: Use ZFS clones for file-backed disks (#640)
PHD: improve ctrl-c handling (#634)

Co-authored-by: Alan Hanson <alan@oxide.computer>
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.

4 participants