Skip to content

Commit d5e8052

Browse files
authored
(5/5) [nexus] Implement Affinity/Anti-Affinity Groups in external API (#7447)
Pulled out of #7076 This PR is a partial implementation of RFD 522 It adds: - Affinity and Anti-Affinity groups, contained within projects. These groups are configured with a **policy** and **failure domain** can currently contain zero or more **members**. Affinity groups attempt to co-locate members, anti-affinity groups attempt to avoid co-locating members. - **Policy** describes "what to do if we cannot fulfill the co-location request". Currently, these options are "fail" (reject the request) or "allow" (continue with provisioning of the group member regardless). - **Failure Domain** describes the scope of what is considered "co-located". In this PR, the only option is "sled", but in the future, this may be expanded to e.g. "rack". - **Members** describe what can be added to affinity/anti-affinity groups. In this PR, the only option is "instance". RFD 522 describes how "anti-affinity groups may also contain affinity groups" -- which is why this "member" terminology is introduced -- but it is not yet implemented. - (anti-)Affinity groups are exposed by the API, through a CRUD interface - (anti-)Affinity groups are considered during "sled reservation", where instances are placed on a sled. This is most significantly implemented (and tested) within `nexus/db-queries/src/db/datastore/sled.rs`, within #7446 Fixes #1705
1 parent a7b7c09 commit d5e8052

File tree

11 files changed

+2056
-77
lines changed

11 files changed

+2056
-77
lines changed

common/src/api/external/http_pagination.rs

+13
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,19 @@ pub type PaginatedByNameOrId<Selector = ()> = PaginationParams<
312312
pub type PageSelectorByNameOrId<Selector = ()> =
313313
PageSelector<ScanByNameOrId<Selector>, NameOrId>;
314314

315+
pub fn id_pagination<'a, Selector>(
316+
pag_params: &'a DataPageParams<Uuid>,
317+
scan_params: &'a ScanById<Selector>,
318+
) -> Result<PaginatedBy<'a>, HttpError>
319+
where
320+
Selector:
321+
Clone + Debug + DeserializeOwned + JsonSchema + PartialEq + Serialize,
322+
{
323+
match scan_params.sort_by {
324+
IdSortMode::IdAscending => Ok(PaginatedBy::Id(pag_params.clone())),
325+
}
326+
}
327+
315328
pub fn name_or_id_pagination<'a, Selector>(
316329
pag_params: &'a DataPageParams<NameOrId>,
317330
scan_params: &'a ScanByNameOrId<Selector>,

0 commit comments

Comments
 (0)