-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Trigger block device rescan via PUT /actions #430
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code is much improved now <3 I like the general direction, but there are some nits here and there.
vmm/Cargo.toml
Outdated
@@ -7,6 +7,7 @@ authors = ["Amazon firecracker team <[email protected]>"] | |||
libc = ">=0.2.39" | |||
epoll = "=2.1.0" | |||
scopeguard = "=0.3.3" | |||
serde_json = "=1.0.9" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should use >=1.0.9
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
api_server/src/request/async/mod.rs
Outdated
device_type: DeviceType, | ||
device_resource_id: String, | ||
force: bool, | ||
pub device_type: DeviceType, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do you need the fields to be public?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For easy instantiation and comparison (inside tests). It would be cumbersome to add getters, setters and builders in the test section.
vmm/src/lib.rs
Outdated
@@ -618,6 +615,16 @@ impl Vmm { | |||
self.network_interface_configs.put(body) | |||
} | |||
|
|||
fn rescan_device(&mut self, body: RequestBody) -> result::Result<SyncOkStatus, SyncError> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is more of a nit, but I don't think you still need both the rescan and rescan_device functions. It adds a bit of confusion because it is not very clear what is the difference between them. For clarity, I would only keep handle_rescan_block_device, which would be the function handling the communication with the API thread and a function rescan_block_device that actually implements the VMM logic.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. Only handle_rescan_block_device
and rescan_block_device
are left.
api_server/src/request/async/mod.rs
Outdated
} | ||
} | ||
|
||
#[test] | ||
fn test_to_parsed_request() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this test gone?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's moved to actions.rs
-> test_into_parsed_request
because RequestBody
no longer has a to_parsed_request
method, but implements the IntoParsedRequest
trait instead. Since actions::IntoParsedRequest
can return either a SyncRequest
or an AsyncRequest
, it didn't make sense for the test to stay in the async
module.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I totally missed that, sorry.
api_server/src/request/actions.rs
Outdated
#[derive(Clone, Debug, Deserialize, Serialize)] | ||
#[serde(deny_unknown_fields)] | ||
pub struct RequestBody { | ||
pub action_id: String, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The action_id can be optional as it will only be used for Async requests. When we change InstanceStart & InstanceHalt to also be sync requests, we can remove it altogether.
Making the action_id optional would require changes in into_parsed_request. We should unwrap the action_id only when parsing InstanceStart and the InstanceHalt.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
api_server/src/request/actions.rs
Outdated
// json body into this. | ||
#[derive(Clone, Debug, Deserialize, Serialize)] | ||
#[serde(deny_unknown_fields)] | ||
pub struct RequestBody { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ActionBody seems like a better name for this struct.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
PUT Requests to /actions don't necessarily need to be async. Renaming to avoid confusion when the need for sync PUT /actions requests arises (soon). Moving structs related to /actions to a separate file. Preparing the code for the addition of sync requests to /actions. Signed-off-by: Alexandra Iordache <[email protected]>
Made action_id optional in the request body, as sync actions don't need an ID. Added a new action that triggers block device rescan. PUT /drives is no longer allowed after the guest boots. Signed-off-by: Alexandra Iordache <[email protected]>
Signed-off-by: Alexandra Iordache <[email protected]>
Signed-off-by: Alexandra Iordache <[email protected]>
Changes
AsyncRequest
toRequest
and refactored*Request
structs accordingly to facilitate sync requests to/actions
as well as async ones.PUT /actions
used to create an async request that had to be queried withGET
.payload
field to the/actions
resource. Future actions should use this to encapsulate the necessary information. For block device rescan,payload
contains the block device's ID.PUT /drives
.PUT /drives
now returns403
after guest boot.PUT /drives
is not allowed anymore and that the rescan works properly.Fixes #280.
Partially addresses #409 as it cleans up the logic for updating drive resources.
Testing
pytest
.