Skip to content

core: introduce a set of type adapters - #13624

Draft
weizhouapache wants to merge 6 commits into
apache:4.22from
shapeblue:4.22-type_adapters
Draft

core: introduce a set of type adapters#13624
weizhouapache wants to merge 6 commits into
apache:4.22from
shapeblue:4.22-type_adapters

Conversation

@weizhouapache

Copy link
Copy Markdown
Member

Description

This PR fixes the issue that There is a set of TO classes with renamed fields, which makes impossible to correctly communicate between Management Servers and Agents

Types of changes

  • Breaking change (fix or feature that would cause existing functionality to change)
  • New feature (non-breaking change which adds functionality)
  • Bug fix (non-breaking change which fixes an issue)
  • Enhancement (improves an existing feature and functionality)
  • Cleanup (Code refactoring and cleanup, that may add test cases)
  • Build/CI
  • Test (unit or integration test code)

Feature/Enhancement Scale or Bug Severity

Feature/Enhancement Scale

  • Major
  • Minor

Bug Severity

  • BLOCKER
  • Critical
  • Major
  • Minor
  • Trivial

Screenshots (if appropriate):

How Has This Been Tested?

How did you try to break this feature and the system with this change?

…ble to correctly communicate between Management Servers and Agents
@weizhouapache

Copy link
Copy Markdown
Member Author

@blueorangutan package

@blueorangutan

Copy link
Copy Markdown

@weizhouapache a [SL] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress.

@codecov

codecov Bot commented Jul 15, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 3.69%. Comparing base (7107d28) to head (5efe316).
⚠️ Report is 214 commits behind head on 4.22.

❗ There is a different number of reports uploaded between BASE (7107d28) and HEAD (5efe316). Click for more details.

HEAD has 1 upload less than BASE
Flag BASE (7107d28) HEAD (5efe316)
unittests 1 0
Additional details and impacted files
@@              Coverage Diff              @@
##               4.22   #13624       +/-   ##
=============================================
- Coverage     17.60%    3.69%   -13.92%     
=============================================
  Files          5917      449     -5468     
  Lines        531493    38176   -493317     
  Branches      64977     7072    -57905     
=============================================
- Hits          93570     1409    -92161     
+ Misses       427369    36580   -390789     
+ Partials      10554      187    -10367     
Flag Coverage Δ
uitests 3.69% <ø> (-0.02%) ⬇️
unittests ?

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@blueorangutan

Copy link
Copy Markdown

Packaging result [SF]: ✖️ el8 ✖️ el9 ✖️ debian ✖️ suse15. SL-JID 18582

@weizhouapache

Copy link
Copy Markdown
Member Author

@blueorangutan package

@blueorangutan

Copy link
Copy Markdown

@weizhouapache a [SL] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress.

@blueorangutan

Copy link
Copy Markdown

Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ el10 ✔️ debian ✔️ suse15. SL-JID 18584

@weizhouapache

Copy link
Copy Markdown
Member Author

@blueorangutan test

@blueorangutan

Copy link
Copy Markdown

@weizhouapache a [SL] Trillian-Jenkins test job (ol8 mgmt + kvm-ol8) has been kicked to run smoke tests

@blueorangutan

Copy link
Copy Markdown

[SF] Trillian Build Failed (tid-16576)

@weizhouapache

Copy link
Copy Markdown
Member Author

@blueorangutan test

@blueorangutan

Copy link
Copy Markdown

@weizhouapache a [SL] Trillian-Jenkins test job (ol8 mgmt + kvm-ol8) has been kicked to run smoke tests

@nvazquez nvazquez added this to the 4.22.2 milestone Jul 16, 2026

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

Code LGTM

@blueorangutan

Copy link
Copy Markdown

[SF] Trillian test result (tid-16577)
Environment: kvm-ol8 (x2), zone: Advanced Networking with Mgmt server ol8
Total time taken: 51298 seconds
Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr13624-t16577-kvm-ol8.zip
Smoke tests completed. 149 look OK, 0 have errors, 0 did not run
Only failed and skipped tests results shown below:

Test Result Time (s) Test File

Comment thread core/src/main/java/com/cloud/agent/transport/compat/AbstractTOAdaptor.java Outdated
Comment thread core/src/main/java/com/cloud/agent/transport/compat/AbstractTOAdaptor.java Outdated
Comment thread core/src/main/java/com/cloud/agent/transport/compat/AbstractTOAdaptor.java Outdated
loggerBuilder.setExclusionStrategies(new LoggingExclusionStrategy(LOGGER));
}

private Map<String, String> fieldMappings;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Can this be final?

Comment thread core/src/main/java/com/cloud/agent/transport/compat/AbstractTOAdaptor.java Outdated
Comment thread core/src/main/java/com/cloud/agent/transport/compat/AbstractTOAdaptor.java Outdated
weizhouapache and others added 2 commits July 16, 2026 15:44
AbstractTOAdaptor built its own private Gson to run the pre-rename
serialization step through, which meant it never honoured the
LoggingExclusionStrategy the enclosing Gson (GsonHelper's logging
instance) was configured with, so fields marked @loglevel(Off) (e.g.
VirtualMachineTO.vncPassword) leaked in plaintext when logged. It also
had no adapters for the sibling compat TOs, so nested TOs (disks/nics
inside a VirtualMachineTO, or a VirtualMachineTO inside a
MigrateCommand) kept their new field names instead of being renamed
for backward compatibility with older Agents.

AbstractTOAdaptor no longer owns a Gson at all: it takes one via
initGson(), mirroring the existing InterfaceTypeAdaptor pattern.
GsonHelper.setDefaultGsonConfig now wires each compat adaptor's
delegate Gson incrementally off the same builder, snapshotting it via
builder.create() right before each adaptor registers itself, so every
adaptor's delegate carries its sibling adaptors (for correct nested
renaming) without ever routing back into itself and recursing
forever. NetworkTO is now registered via registerTypeHierarchyAdapter
since VirtualMachineTO.nics is declared as NicTO[] (a NetworkTO
subclass) and was never matched by the previous exact-type
registration.

This also removes AbstractTOAdaptor's now-unused loggerBuilder/LOGGER
and its duplicate copy of GsonHelper.setDefaultGsonConfig, and
replaces a dead null check (getAsJsonObject() never returns null) with
a real isJsonObject() check.

Added RequestTest#testCompatFieldRenamingNestedTOs covering a
StartCommand and a MigrateCommand with nested disks/nics, asserting
old field names appear at every nesting level on the wire and that
vncPassword never appears in the logging serialization.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
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