Commit d20177c
Fix nested TO renaming, log redaction and cleanup in compat TypeAdaptors
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>1 parent 15b39f4 commit d20177c
3 files changed
Lines changed: 130 additions & 60 deletions
File tree
- core/src
- main/java/com/cloud
- agent/transport/compat
- serializer
- test/java/com/cloud/agent/transport
Lines changed: 15 additions & 56 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
19 | | - | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | 19 | | |
33 | 20 | | |
34 | 21 | | |
35 | | - | |
36 | 22 | | |
37 | 23 | | |
38 | 24 | | |
39 | 25 | | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | 26 | | |
45 | 27 | | |
46 | 28 | | |
47 | | - | |
48 | 29 | | |
49 | 30 | | |
50 | 31 | | |
51 | 32 | | |
52 | 33 | | |
53 | 34 | | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
54 | 43 | | |
55 | 44 | | |
56 | | - | |
57 | | - | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | | - | |
64 | | - | |
65 | | - | |
66 | | - | |
| 45 | + | |
67 | 46 | | |
68 | 47 | | |
69 | 48 | | |
| |||
82 | 61 | | |
83 | 62 | | |
84 | 63 | | |
85 | | - | |
86 | | - | |
87 | | - | |
88 | | - | |
89 | | - | |
90 | | - | |
91 | | - | |
92 | | - | |
93 | | - | |
94 | | - | |
95 | | - | |
96 | | - | |
97 | | - | |
98 | | - | |
99 | | - | |
100 | | - | |
101 | | - | |
102 | | - | |
103 | | - | |
104 | | - | |
105 | | - | |
106 | | - | |
107 | | - | |
| 64 | + | |
| 65 | + | |
108 | 66 | | |
109 | 67 | | |
110 | 68 | | |
111 | 69 | | |
112 | 70 | | |
113 | 71 | | |
114 | 72 | | |
115 | | - | |
116 | | - | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
117 | 76 | | |
118 | 77 | | |
119 | 78 | | |
| |||
122 | 81 | | |
123 | 82 | | |
124 | 83 | | |
125 | | - | |
| 84 | + | |
126 | 85 | | |
127 | 86 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
86 | 86 | | |
87 | 87 | | |
88 | 88 | | |
| 89 | + | |
89 | 90 | | |
90 | | - | |
91 | | - | |
92 | | - | |
93 | | - | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
94 | 125 | | |
95 | 126 | | |
96 | 127 | | |
| |||
Lines changed: 80 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| 23 | + | |
23 | 24 | | |
24 | 25 | | |
25 | 26 | | |
| |||
35 | 36 | | |
36 | 37 | | |
37 | 38 | | |
| 39 | + | |
38 | 40 | | |
| 41 | + | |
39 | 42 | | |
40 | 43 | | |
41 | 44 | | |
| 45 | + | |
42 | 46 | | |
| 47 | + | |
| 48 | + | |
43 | 49 | | |
44 | 50 | | |
| 51 | + | |
45 | 52 | | |
46 | 53 | | |
47 | 54 | | |
48 | 55 | | |
49 | 56 | | |
50 | 57 | | |
| 58 | + | |
| 59 | + | |
51 | 60 | | |
52 | 61 | | |
53 | 62 | | |
| |||
186 | 195 | | |
187 | 196 | | |
188 | 197 | | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
189 | 269 | | |
190 | 270 | | |
191 | 271 | | |
| |||
0 commit comments