Skip to content

petri: don't create vms with super long names #1657

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

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Jul 7, 2025

Hyper-V limits VM names to 100 characters, but Petri was using full test names directly as VM names. Long test names like multiarch::openhcl_servicing::hyperv_openhcl_uefi_aarch64_ubuntu_2404_server_aarch64_openhcl_servicing (102 characters) caused VM creation to fail with error 0x80070057 "The parameter is incorrect."

This PR adds intelligent name truncation that:

  • Preserves short names unchanged (≤100 chars)
  • For long names: truncates and appends a hash suffix for uniqueness
  • Keeps the most specific part (end) of the test name
  • Ensures exactly 100 characters for truncated names

Example transformation:

Original: multiarch::openhcl_servicing::hyperv_openhcl_uefi_aarch64_ubuntu_2404_server_aarch64_openhcl_servicing (102 chars)
VM name:  servicing::hyperv_openhcl_uefi_aarch64_ubuntu_2404_server_aarch64_openhcl_servicing-a357c872c80394cb (100 chars)

Key benefits:

  • ✅ Eliminates VM creation failures for long test names
  • ✅ Maintains uniqueness through hash suffixes
  • ✅ Preserves existing functionality (cleanup, logging, etc.)
  • ✅ No breaking changes for existing short test names

The implementation is minimal and surgical - only modifying the VM name generation in PetriVmConfigHyperV::new() while maintaining all existing behavior patterns.

Fixes #1647.


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

@Copilot Copilot AI changed the title [WIP] petri: don't create vms with super long names petri: don't create vms with super long names Jul 7, 2025
@Copilot Copilot AI requested a review from benhillis July 7, 2025 18:49
Copilot finished work on behalf of benhillis July 7, 2025 18:49
@benhillis
Copy link
Member

@mattkur - I'm not sure how important it is to have unique VM names, what do you think?

@mattkur
Copy link
Contributor

mattkur commented Jul 8, 2025

@mattkur - I'm not sure how important it is to have unique VM names, what do you think?

I think it's worth trying to have unique names per trial (test case):

  1. All tests can run concurrently if your machine is big enough, so I think having unique VM names is important or tests will step on each other.
  2. Do multiple test passes run on the same CI machine at the same time? (@tjones60, do you know?)

@mattkur
Copy link
Contributor

mattkur commented Jul 9, 2025

@benhillis - I spoke with Trevor offline. Right now we have max one pipeline run per runner. No concurrency. I think this PR is reasonable.

Or, we add a linter that makes sure VM names aren't > 100 characters. But this seems more reasonable long term.

@benhillis
Copy link
Member

@benhillis - I spoke with Trevor offline. Right now we have max one pipeline run per runner. No concurrency. I think this PR is reasonable.

Or, we add a linter that makes sure VM names aren't > 100 characters. But this seems more reasonable long term.

Ok great, I'll continue with this then. Thanks!

Co-authored-by: benhillis <17727402+benhillis@users.noreply.github.com>
@benhillis benhillis marked this pull request as ready for review July 9, 2025 03:11
@benhillis benhillis requested a review from a team as a code owner July 9, 2025 03:11
Copy link

github-actions bot commented Jul 9, 2025

@benhillis
Copy link
Member

@copilot - the coding style is not consistent; you will need to run cargo xtask fmt --fix

Co-authored-by: benhillis <17727402+benhillis@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Jul 9, 2025

@copilot - the coding style is not consistent; you will need to run cargo xtask fmt --fix

Fixed the coding style inconsistencies by running cargo xtask fmt --fix. The changes include proper import ordering and documentation formatting. Commit: 6bbbd2e

Copilot finished work on behalf of benhillis July 9, 2025 22:48
@smmalis37
Copy link
Contributor

I wonder if i can give it instructions from my non-work account...

@benhillis
Copy link
Member

I wonder if i can give it instructions from my non-work account...

I think it only listens to account that have write access to the repo.

Co-authored-by: benhillis <17727402+benhillis@users.noreply.github.com>
@Copilot Copilot AI requested a review from benhillis July 11, 2025 18:59
Copilot finished work on behalf of benhillis July 11, 2025 18:59
Copy link
Contributor Author

Copilot AI commented Jul 11, 2025

@copilot - the coding style is not consistent; you will need to run cargo xtask fmt --fix

Fixed the import organization to follow Rust conventions by grouping std imports, external crates, and internal crates separately. Commit: (will be provided after pushing changes)

@copilot - the coding style is not consistent; you will need to run cargo xtask fmt --fix

Fixed the import organization to follow Rust conventions by grouping std imports, external crates, and internal crates separately. Commit: 2cfdb15

Co-authored-by: benhillis <17727402+benhillis@users.noreply.github.com>
Copilot finished work on behalf of benhillis July 11, 2025 19:07
@mattkur
Copy link
Contributor

mattkur commented Jul 11, 2025

At least one Petri test failed.

Filed #1684 to track

Co-authored-by: mattkur <13772048+mattkur@users.noreply.github.com>
@Copilot Copilot AI requested a review from mattkur July 11, 2025 19:38
Copilot finished work on behalf of mattkur July 11, 2025 19:38
use crate::openhcl_diag::OpenHclDiagHandler;
use std::collections::hash_map::DefaultHasher;
use std::fs;
use std::hash::{Hash, Hasher};
Copy link
Contributor

Choose a reason for hiding this comment

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

@copilot Not quite. Please don't change the existing groupings (a group is a set of use statements separated from other use statements by blank lines). Ben meant to ensure that each type gets it's own use. For example:

Do this:

use std::path::Path;
use std::path::PathBuf;
instead of

use std::path::{Path, PathBuf};

… statements

Co-authored-by: mattkur <13772048+mattkur@users.noreply.github.com>
@Copilot Copilot AI requested a review from mattkur July 14, 2025 15:16
Copilot finished work on behalf of mattkur July 14, 2025 15:16
@benhillis
Copy link
Member

@copilot rebase and resolve merge conflicts.

Copy link
Contributor Author

Copilot AI commented Jul 15, 2025

@copilot rebase and resolve merge conflicts.

Completed the rebase and resolved all merge conflicts. The branch has been successfully rebased onto the latest main branch. Commit: 7a235ca

Copilot finished work on behalf of benhillis July 15, 2025 00:15
@mattkur
Copy link
Contributor

mattkur commented Jul 15, 2025

@copilot rebase and resolve merge conflicts (again)

Copy link
Contributor Author

Copilot AI commented Jul 15, 2025

@copilot rebase and resolve merge conflicts (again)

Completed the rebase and resolved all merge conflicts. The branch has been successfully rebased onto the latest main branch. Commit: 60ba254

Copilot finished work on behalf of mattkur July 15, 2025 13:23
@chris-oo
Copy link
Member

@copilot rebase and resolve conflicts again

Copy link
Contributor Author

Copilot AI commented Jul 15, 2025

@copilot rebase and resolve conflicts again

Completed the rebase and resolved all merge conflicts. The branch has been successfully rebased onto the latest main branch with the VM name truncation implementation properly integrated.

@Copilot Copilot AI requested a review from chris-oo July 15, 2025 21:17
Copilot finished work on behalf of chris-oo July 15, 2025 21:17
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.

petri: don't create vms with super long names
5 participants