Commit 73c4206
committed
backup(nas): move backup-mode policy + stdout markers from script to wrapper
Address abh1sar review on PR #13074 (nasbackup.sh:155, :193, :358; LibvirtTake
BackupCommandWrapper.java:124). The script was carrying caller-side policy:
arg validation, fallback decisions, and stdout markers that the wrapper had to
parse out before the size-parsing logic could run. Move that policy into Java
and use dedicated exit codes for the signals the wrapper needs.
Script (scripts/vm/hypervisor/kvm/nasbackup.sh):
* Drop the per-mode required-args checks (the wrapper now pre-validates).
* Replace the INCREMENTAL_FALLBACK stdout marker with exit code 21
(EXIT_INCREMENTAL_UNSUPPORTED): emitted when the running-VM path can't
re-register the parent checkpoint, and when the stopped-VM path was asked
for incremental. The wrapper retries the script as a full backup and sets
incrementalFallback on the BackupAnswer.
* Replace the BITMAP_CREATED stdout marker with exit code 22
(EXIT_BITMAP_NOT_SEEDED), emitted only by the stopped-VM path when
qemu-img bitmap --add failed for every source disk. Backup file is valid
but no usable bitmap exists on the host; wrapper records bitmapCreated=null
so NASBackupProvider clears active_checkpoint_id and the next backup starts
a fresh full chain. Running-VM success path no longer needs a marker —
libvirt's backup-begin atomically creates the checkpoint.
LibvirtTakeBackupCommandWrapper.java:
* Pre-validate incremental args (mode-vs-bitmapNew/Parent/parentPaths) before
invoking the script. Returns a failed BackupAnswer on missing args, keeping
the script agnostic to caller policy.
* Extract runBackupScript() so the same code can fire the retry-as-full after
EXIT_INCREMENTAL_UNSUPPORTED without duplicating arg assembly.
* On EXIT_INCREMENTAL_UNSUPPORTED + requestedMode==incremental, re-invoke
with mode=full and only --bitmap-new (drop --bitmap-parent/--parent-paths);
set incrementalFallback=true on the eventual answer.
* On EXIT_BITMAP_NOT_SEEDED, treat as success but set bitmapCreated=null.
* Drop the stdout-marker stripping loop (markers no longer emitted), and the
separate BITMAP_CREATED parsing — bitmapCreated mirrors command.getBitmapNew()
unless the not-seeded exit code says otherwise.
NASBackupProvider.java:
* Refresh the two comment blocks that referenced the old BITMAP_CREATED= stdout
signal to describe the new exit-code path. No behaviour change in this file.1 parent 096bef1 commit 73c4206
3 files changed
Lines changed: 152 additions & 96 deletions
File tree
- plugins
- backup/nas/src/main/java/org/apache/cloudstack/backup
- hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/wrapper
- scripts/vm/hypervisor/kvm
Lines changed: 11 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
406 | 406 | | |
407 | 407 | | |
408 | 408 | | |
409 | | - | |
410 | | - | |
411 | | - | |
412 | | - | |
413 | | - | |
414 | | - | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
415 | 415 | | |
416 | 416 | | |
417 | 417 | | |
| |||
562 | 562 | | |
563 | 563 | | |
564 | 564 | | |
565 | | - | |
566 | | - | |
567 | | - | |
568 | | - | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
569 | 570 | | |
570 | 571 | | |
571 | 572 | | |
| |||
Lines changed: 111 additions & 51 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
45 | 53 | | |
46 | 54 | | |
47 | 55 | | |
| |||
54 | 62 | | |
55 | 63 | | |
56 | 64 | | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
57 | 72 | | |
58 | 73 | | |
59 | 74 | | |
| |||
69 | 84 | | |
70 | 85 | | |
71 | 86 | | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 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 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
72 | 140 | | |
73 | 141 | | |
74 | 142 | | |
| |||
80 | 148 | | |
81 | 149 | | |
82 | 150 | | |
83 | | - | |
84 | | - | |
| 151 | + | |
85 | 152 | | |
86 | | - | |
| 153 | + | |
87 | 154 | | |
88 | | - | |
| 155 | + | |
89 | 156 | | |
90 | | - | |
| 157 | + | |
91 | 158 | | |
92 | | - | |
| 159 | + | |
93 | 160 | | |
94 | | - | |
| 161 | + | |
95 | 162 | | |
96 | | - | |
| 163 | + | |
97 | 164 | | |
98 | | - | |
| 165 | + | |
99 | 166 | | |
100 | 167 | | |
101 | 168 | | |
102 | 169 | | |
| 170 | + | |
| 171 | + | |
103 | 172 | | |
104 | | - | |
105 | | - | |
106 | | - | |
107 | | - | |
108 | | - | |
109 | | - | |
110 | | - | |
111 | | - | |
112 | | - | |
113 | | - | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
114 | 181 | | |
115 | | - | |
116 | | - | |
117 | | - | |
118 | | - | |
119 | | - | |
120 | | - | |
121 | | - | |
122 | | - | |
123 | | - | |
124 | | - | |
125 | | - | |
126 | | - | |
127 | | - | |
128 | | - | |
129 | | - | |
130 | | - | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
131 | 185 | | |
132 | | - | |
133 | | - | |
134 | | - | |
| 186 | + | |
| 187 | + | |
135 | 188 | | |
136 | | - | |
137 | | - | |
| 189 | + | |
| 190 | + | |
138 | 191 | | |
139 | | - | |
| 192 | + | |
140 | 193 | | |
141 | | - | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
142 | 202 | | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
143 | 209 | | |
144 | 210 | | |
145 | | - | |
| 211 | + | |
146 | 212 | | |
147 | 213 | | |
148 | 214 | | |
149 | 215 | | |
150 | | - | |
151 | | - | |
| 216 | + | |
152 | 217 | | |
153 | 218 | | |
154 | 219 | | |
155 | | - | |
156 | | - | |
157 | | - | |
158 | | - | |
159 | | - | |
160 | | - | |
| 220 | + | |
161 | 221 | | |
162 | 222 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
52 | 57 | | |
53 | 58 | | |
54 | 59 | | |
| |||
128 | 133 | | |
129 | 134 | | |
130 | 135 | | |
| 136 | + | |
| 137 | + | |
131 | 138 | | |
132 | 139 | | |
133 | 140 | | |
134 | | - | |
135 | | - | |
136 | | - | |
137 | | - | |
138 | | - | |
139 | | - | |
140 | | - | |
141 | | - | |
142 | | - | |
143 | | - | |
144 | | - | |
145 | | - | |
146 | | - | |
147 | | - | |
| 141 | + | |
148 | 142 | | |
149 | 143 | | |
150 | 144 | | |
| |||
174 | 168 | | |
175 | 169 | | |
176 | 170 | | |
177 | | - | |
178 | | - | |
179 | | - | |
180 | | - | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
181 | 177 | | |
182 | 178 | | |
183 | 179 | | |
| |||
338 | 334 | | |
339 | 335 | | |
340 | 336 | | |
| 337 | + | |
| 338 | + | |
341 | 339 | | |
342 | | - | |
343 | | - | |
344 | 340 | | |
345 | 341 | | |
346 | 342 | | |
| |||
349 | 345 | | |
350 | 346 | | |
351 | 347 | | |
352 | | - | |
353 | | - | |
354 | | - | |
| 348 | + | |
| 349 | + | |
355 | 350 | | |
356 | | - | |
357 | | - | |
358 | | - | |
| 351 | + | |
| 352 | + | |
359 | 353 | | |
360 | 354 | | |
361 | 355 | | |
| |||
397 | 391 | | |
398 | 392 | | |
399 | 393 | | |
400 | | - | |
401 | | - | |
402 | | - | |
403 | | - | |
404 | | - | |
405 | | - | |
406 | | - | |
407 | | - | |
408 | | - | |
409 | 394 | | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
410 | 405 | | |
411 | 406 | | |
412 | 407 | | |
| |||
0 commit comments