Skip to content

[live-migration] deliver structured live migration notifications end to end#2696

Open
rawahars wants to merge 3 commits intomicrosoft:mainfrom
rawahars:lm_event_notifications
Open

[live-migration] deliver structured live migration notifications end to end#2696
rawahars wants to merge 3 commits intomicrosoft:mainfrom
rawahars:lm_event_notifications

Conversation

@rawahars
Copy link
Copy Markdown
Contributor

@rawahars rawahars commented Apr 21, 2026

Summary

Replace the opaque event-data string surfaced from HCS live migration callbacks with a typed notification payload, and propagate that shape through the migration gRPC API so callers can act on migration progress without parsing raw JSON.

  • Add OperationSystemMigrationNotificationInfo to the HCS schema along with MigrationOrigin, MigrationEvent, and MigrationResult enumerations covering the full set of states reported by HCS (setup, blackout, transfer, recovery, completion, failure, etc.).
  • Update the HCS migration callback to unmarshal the JSON event payload into the new struct, drop malformed events with a warning, and deliver typed values over MigrationNotifications() instead of raw strings.
  • Add unit tests for the callback handler covering nil arguments, valid payloads, empty data, malformed JSON, and a full notification channel.

@rawahars rawahars requested a review from a team as a code owner April 21, 2026 08:02
@rawahars rawahars force-pushed the lm_event_notifications branch 2 times, most recently from 4c68686 to 747d8e8 Compare April 21, 2026 09:35
Comment thread internal/hcs/schema2/migration.go Outdated
Result MigrationResult `json:"Result,omitempty"`
// AdditionalDetails carries extra event-specific information whose schema
// depends on the event being reported. Modeled as the HCS schema `Any` type.
AdditionalDetails *interface{} `json:"AdditionalDetails,omitempty"`
Copy link
Copy Markdown
Contributor

@jterry75 jterry75 Apr 22, 2026

Choose a reason for hiding this comment

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

I thought for the internal we decided this has to be json.RawMessage ptrs?

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.

Yes that's correct. I've made the changes now and have added a test as well which validates the same.

…to-end

Replace the opaque event-data string surfaced from HCS live migration callbacks with a typed notification payload so callers can act on migration progress without parsing raw JSON.
- Add OperationSystemMigrationNotificationInfo to the HCS schema along with MigrationOrigin, MigrationEvent, and MigrationResult enumerations covering the full set of states reported by HCS (setup, blackout, transfer, recovery, completion, failure, etc.).
- Update the HCS migration callback to unmarshal the JSON event payload into the new struct, drop malformed events with a warning, and deliver typed values over MigrationNotifications() instead of raw strings.
- Add unit tests for the callback handler covering nil arguments, valid payloads, empty data, malformed JSON, and a full notification channel.

Signed-off-by: Harsh Rawat <harshrawat@microsoft.com>
Signed-off-by: Harsh Rawat <harshrawat@microsoft.com>
@rawahars rawahars force-pushed the lm_event_notifications branch from 747d8e8 to 76f2096 Compare April 23, 2026 04:04
Signed-off-by: Harsh Rawat <harshrawat@microsoft.com>
Copy link
Copy Markdown
Contributor

@shreyanshjain7174 shreyanshjain7174 left a comment

Choose a reason for hiding this comment

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

LGTM!

Comment thread internal/hcs/migration.go
Comment on lines +63 to +77
var info hcsschema.OperationSystemMigrationNotificationInfo
if eventData != "" {
if err := json.Unmarshal([]byte(eventData), &info); err != nil {
logrus.WithFields(logrus.Fields{
"event-type": e.Type.String(),
"event-data": eventData,
logrus.ErrorKey: err,
}).Warn("failed to unmarshal migration notification payload, dropping event")
return 0
}
}

// Non-blocking send to avoid blocking the HCS callback thread.
select {
case ch <- eventData:
case ch <- info:
Copy link
Copy Markdown
Contributor

@shreyanshjain7174 shreyanshjain7174 Apr 23, 2026

Choose a reason for hiding this comment

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

When EventData is nil from HCS, this sends a zero-value struct where Event == "" instead of MigrationEventUnknown. Might be worth a short comment here noting that empty string means "no payload" vs the Unknown sentinel.

Comment on lines +287 to +288
got := <-ch
if got.AdditionalDetails != nil {
Copy link
Copy Markdown
Contributor

@shreyanshjain7174 shreyanshjain7174 Apr 23, 2026

Choose a reason for hiding this comment

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

nit: bare <-ch here can hang if the test regresses — the other tests use expectNotification or a select with default. Worth using the same pattern for consistency.

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.

3 participants