Skip to content

Commit

Permalink
u32 max attach count
Browse files Browse the repository at this point in the history
  • Loading branch information
smklein committed May 27, 2022
1 parent a1b10d0 commit 63e95b8
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
4 changes: 2 additions & 2 deletions nexus/src/db/collection_attach.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ pub trait DatastoreAttachTarget<ResourceType>: Selectable<Pg> + Sized {
collection_query: BoxedQuery<CollectionTable<ResourceType, Self>>,
resource_query: BoxedQuery<ResourceTable<ResourceType, Self>>,

max_attached_resources: usize,
max_attached_resources: u32,

// We are intentionally picky about this update statement:
// - The second argument - the WHERE clause - must match the default
Expand Down Expand Up @@ -344,7 +344,7 @@ where
// A (mostly) user-provided query for validating the resource.
resource_query: Box<dyn QueryFragment<Pg> + Send>,
// The maximum number of resources which may be attached to the collection.
max_attached_resources: usize,
max_attached_resources: u32,

// Update statement for the resource.
update_resource_statement:
Expand Down
4 changes: 1 addition & 3 deletions nexus/src/db/datastore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1171,7 +1171,6 @@ impl DataStore {
let attached_label =
api::external::DiskState::Attached(authz_instance.id()).label();

// TODO "u32" seems reasonable for the max disks value (input / output)
let (instance, disk) = Instance::attach_resource(
authz_instance.id(),
authz_disk.id(),
Expand All @@ -1181,8 +1180,7 @@ impl DataStore {
disk::table
.into_boxed()
.filter(disk::dsl::disk_state.eq_any(ok_to_attach_disk_state_labels)),
// TODO: Remove unwrap?
usize::try_from(max_disks).unwrap(),
max_disks,
diesel::update(disk::dsl::disk)
.set((
disk::dsl::disk_state.eq(attached_label),
Expand Down

0 comments on commit 63e95b8

Please sign in to comment.