Skip to content

[internal/hcs] Migrate package from HCS V1 to V2#2735

Merged
rawahars merged 1 commit into
microsoft:mainfrom
rawahars:migrate_hcs_v1_v2
Jun 16, 2026
Merged

[internal/hcs] Migrate package from HCS V1 to V2#2735
rawahars merged 1 commit into
microsoft:mainfrom
rawahars:migrate_hcs_v1_v2

Conversation

@rawahars

Copy link
Copy Markdown
Contributor

Presently, we were using HCS V1 (vmcompute) within internal/hcs but it has been deprecated and therefore, we are moving to use computecore within hcs package.

@rawahars rawahars force-pushed the migrate_hcs_v1_v2 branch 15 times, most recently from 54b7a44 to d3f62f2 Compare May 17, 2026 19:39
@rawahars rawahars force-pushed the migrate_hcs_v1_v2 branch 4 times, most recently from c399db9 to e76ebeb Compare May 19, 2026 17:22
@rawahars rawahars marked this pull request as ready for review May 19, 2026 17:23
@rawahars rawahars requested a review from a team as a code owner May 19, 2026 17:23

@helsaawy helsaawy 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.

this change will cause the shim to always block on all operations, right? do we have any perf numbers on how much impact this will have?

Comment thread internal/hcs/notification.go Outdated
// owns the operation handle leads to use-after-free crashes
// (EXCEPTION_ACCESS_VIOLATION) inside computecore.dll. Callers must not
// rely on ctx to bound the call's duration.
func runOperation(ctx context.Context, fn func(op computecore.HcsOperation) error) (resultDoc string, err error) {

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.

we always end up calling processHcsResult on the operation result; ie:

	resultJSON, err := runOperation(ctx, func(op computecore.HcsOperation) error { /* ... */ })
	if err != nil {
		return nil, makeSystemError(computeSystem, operation, err, processHcsResult(ctx, resultJSON))
	}

can we elevate hcsResult to an error type (since it already (sorta) matches the ResultError API type), and then move the processHcsResult logic into run[Process]Operation?
that would reduce a lot of boilerplate

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the suggestion. Incorporated the same.

Comment thread internal/hcs/system.go Outdated
@rawahars rawahars force-pushed the migrate_hcs_v1_v2 branch 2 times, most recently from 78d3a26 to 5e7dd9c Compare May 23, 2026 16:47
@rawahars

Copy link
Copy Markdown
Contributor Author

@helsaawy You're right that every call now goes through HcsCreateOperationAPIHcsWaitForOperationResult.

Looking at ClientOperation::HcsWaitResult in computecore, the wait itself is just an event wait, so when HCS completes the work synchronously inside the API call, the wait returns immediately — wall-clock per-operation should be ~identical to V1 (which either completed inline or returned ERR_PENDING and made us wait on a callback anyway).

We are planning on creating a perf calculation tool which can run in CI and can provide us a ballpark of the figures.

Comment thread internal/hcs/migration.go Outdated
@@ -361,36 +225,33 @@ func (computeSystem *System) FinalizeLiveMigration(ctx context.Context, resume b
}
optionsJSON, err := json.Marshal(hcsschema.MigrationFinalizedOptions{FinalizedOperation: finalOp})

@Kavya-Bharadwaj Kavya-Bharadwaj May 25, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

MigrationFinalizedOptions takes two parameters Origin and FinalizedOperation. HCS uses Origin to evaluate if this is a normal finalization or a rollback after failure. Omitting origin would lead to wrong recovery path. It's safer to set the origin field here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the suggestion! I have updated FinalizeLiveMigration to the same pattern as other methods. We will accept the opts which are passed by the caller and will set all the options there.

@rawahars rawahars force-pushed the migrate_hcs_v1_v2 branch 2 times, most recently from 9fd1f62 to 67168df Compare June 16, 2026 19:56
Presently, we were using HCS V1 (vmcompute) within internal/hcs but it has been deprecated and therefore, we are moving to use computecore within hcs v2 package.

Signed-off-by: Harsh Rawat <harshrawat@microsoft.com>
@rawahars rawahars force-pushed the migrate_hcs_v1_v2 branch from 67168df to cf50569 Compare June 16, 2026 20:09
@rawahars rawahars merged commit 1a0726e into microsoft:main Jun 16, 2026
19 checks passed
@rawahars rawahars deleted the migrate_hcs_v1_v2 branch June 16, 2026 20:43
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.

5 participants