Skip to content

CP-308260: Handle networkd upgrade #6511

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

Conversation

changlei-li
Copy link
Contributor

In the upgrade scenario, net devices order has been converted to initial rule and pass to new system. See xenserver/host-installer#249

This PR is to handle the remaining things in networkd:

  • Recognize upgrade scenario to run sort for upgrade
  • Generate changed interfaces list to update networkd db
  • Get management interface and address type from /var/tmp/.previousInventory and write to inventory

@changlei-li changlei-li force-pushed the private/changleli/CP-308260 branch from ca7aeb8 to f6df121 Compare June 9, 2025 03:36
@changlei-li changlei-li changed the title CP-308260: Handle networkd update CP-308260: Handle networkd upgrade Jun 9, 2025

let read_previous_inventory () =
let previous_inventory = "/var/tmp/.previousInventory" in
Xapi_stdext_unix.Unixext.file_lines_fold
Copy link
Contributor

Choose a reason for hiding this comment

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

This can fail and I think the error needs to be treated here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am intended to expose the error.
We can only write a default management interface like "xenbr0" to inventory if it fails. But I think it's not reasonable in upgrade scenario. So, I want to expose the error.

Copy link
Contributor

@lindig lindig Jun 9, 2025

Choose a reason for hiding this comment

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

I am also slightly concerned about using a hidden file in /var/tmp. I would assume that his file should reside in /var/run/networkd/ to avoid any collisions with other services and to signal that this belongs to networkd. What is the lifetime of this file?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

See https://github.com/xenserver/host-installer/blob/v11.0.23/upgrade.py#L426. This file is a backup of old inventory during upgrade. It is also used in https://github.com/xapi-project/xen-api/blob/v25.21.0/ocaml/xapi/xapi_db_upgrade.ml#L254.
The tmp file is cleared on reboot.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I handle the exception explicitly in the latest commit by logging and raising a new Network_error-Internal_error

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I finally give up raising a new Network_error-Internal_error, just log an error message, to keep the uniform style.

@changlei-li changlei-li force-pushed the private/changleli/CP-308260 branch from 2ccd90e to 9a95184 Compare June 10, 2025 01:52
@changlei-li changlei-li requested a review from minglumlu June 10, 2025 01:57
@changlei-li changlei-li force-pushed the private/changleli/CP-308260 branch from 9a95184 to 380dea5 Compare June 11, 2025 05:07
@changlei-li
Copy link
Contributor Author

changlei-li commented Jun 11, 2025

I need to sync feature branch with master to adopt #6512 to fix CI error.
---> done

Consider both device_already_renamed and last_order:
True, None -> The netdev-rename version behaviour
True, Some _ -> Impossible
False, None -> Upgrade from netdev-rename version
False, None -> The networkd-sort version behaviour

To handle the upgrade, the previous order is converted
and passed to initial rules. So use [] here to sort.

Signed-off-by: Changlei Li <[email protected]>
Netwrok_device_order.sort won't return changed_interfaces as
last_order is void. Need to generate it based on the eth devs
name and sorted interface order for upgrade.

Signed-off-by: Changlei Li <[email protected]>
Read management interface and addr type from previous inventory,
write to inventory file.

Signed-off-by: Changlei Li <[email protected]>
@changlei-li changlei-li force-pushed the private/changleli/CP-308260 branch 2 times, most recently from 26e294f to 00d859c Compare June 11, 2025 10:12
@changlei-li changlei-li force-pushed the private/changleli/CP-308260 branch from 00d859c to c020dc7 Compare June 12, 2025 01:49
- Add function name in error log
- Use sscanf to get index of ethx
- Handle the exception explicitly when reading previous inventory
- Add more error log
- Don't write to inventory if not read the concerned keys

Signed-off-by: Changlei Li <[email protected]>
@changlei-li changlei-li force-pushed the private/changleli/CP-308260 branch from c020dc7 to bc6c7d1 Compare June 12, 2025 02:02
@changlei-li
Copy link
Contributor Author

Test upgrade manually success.

@changlei-li changlei-li merged commit 0a75417 into xapi-project:feature/host-network-device-ordering Jun 12, 2025
16 checks passed
@changlei-li changlei-li deleted the private/changleli/CP-308260 branch June 16, 2025 06:55
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