Skip to content

[nexus] Allow specifying anti-affinity groups during instance creation#7864

Merged
smklein merged 251 commits into
mainfrom
instance-create-affinity
Mar 27, 2025
Merged

[nexus] Allow specifying anti-affinity groups during instance creation#7864
smklein merged 251 commits into
mainfrom
instance-create-affinity

Conversation

@smklein

@smklein smklein commented Mar 24, 2025

Copy link
Copy Markdown
Collaborator

Fixes #7723

@smklein smklein marked this pull request as ready for review March 25, 2025 21:54
@smklein smklein requested a review from david-crespo March 25, 2025 21:55
Comment thread nexus/types/src/external_api/params.rs Outdated

/// Affinity groups which this instance should be added into.
#[serde(default)]
pub affinity_groups: Vec<NameOrId>,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If affinity groups are considered experimental, should we leave them out here at first?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Yeah, good idea. I'll just delete this portion of the code for now.

}
}
}
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

not_found_by_id and not_found_by_name might make this very slightly shorter. Also you could loop through the names and IDs vecs since you've already done the match to separate them above. Neither change is necessary though, this is all clear enough.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Sure thing, I went ahead and made both these changes.

Comment thread nexus/src/app/instance.rs
.iter()
.map(|id| NameOrId::Id(id.into_untyped_uuid()))
.collect::<Vec<NameOrId>>())
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Worth having these return just Vec<Uuid> since they're all IDs? I'm guessing that would require changes downstream that might be annoying, though it could also let you delete some annoying match statements.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I would like to - this what my TODO comment is about below. Right now, InstanceCreate is a big struct of unvalidated user parameters, and we do perform validation on it, but don't transform the type before handing it to the saga machinery. I think we should transform the type (hence the TODO) but it needs to be a NameOrId for now.

Comment thread nexus/src/app/sagas/instance_create.rs Outdated
"Non-UUID group".to_string(),
));
}
};

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Yeah, if they're all IDs you don't even need this match.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Agreed, this will require a new struct, and InstanceCreate already needs some clean-up. I can do this, but I'm probably going to save it for a follow-up PR?

@david-crespo david-crespo left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks good to me. My comments are just suggestions. I think the API is good, don't really see what else it could be.

Base automatically changed from group-size-limits to main March 26, 2025 21:25
@smklein smklein changed the title [nexus] Allow specifying affinity/anti-affinity groups during instance creation [nexus] Allow specifying anti-affinity groups during instance creation Mar 26, 2025
@smklein smklein enabled auto-merge (squash) March 26, 2025 23:39
@smklein smklein merged commit 7c33248 into main Mar 27, 2025
@smklein smklein deleted the instance-create-affinity branch March 27, 2025 00:23
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.

Instance Create could allow specifying affinity, anti-affinity groups

2 participants