Skip to content

Commit

Permalink
IH-747 - xapi/import: Don't lie in VDI import logs
Browse files Browse the repository at this point in the history
Instead of logging errors like this and then immediately handling them:
```
[error|1141 |VM metadata import |import]
Found no VDI with location = dedeeb44-62b3-460e-b55c-6de45ba10cc0:
treating as fatal and abandoning import

[debug|1141 |VM metadata import |import]
Ignoring missing disk Ref:4 -
this will be mirrored during a real live migration.
```

Log once in the handler:
```
[ warn|VM metadata import |import]
Ignoring missing disk Ref:16 -
this will be mirrored during a real live migration.
(Suppressed error: 'Found no VDI with location = c208b47c-cf87-495f-bd3c-a4bc8167ef83')
```

Signed-off-by: Andrii Sultanov <[email protected]>
  • Loading branch information
last-genius committed Dec 13, 2024
1 parent c3bb182 commit 314cedf
Showing 1 changed file with 28 additions and 22 deletions.
50 changes: 28 additions & 22 deletions ocaml/xapi/import.ml
Original file line number Diff line number Diff line change
Expand Up @@ -939,7 +939,7 @@ module VDI : HandlerTools = struct
| Found_iso of API.ref_VDI
| Found_no_iso
| Found_disk of API.ref_VDI
| Found_no_disk of exn
| Found_no_disk of string * exn
| Skip
| Create of API.vDI_t

Expand Down Expand Up @@ -1090,27 +1090,31 @@ module VDI : HandlerTools = struct
| Some vdi ->
Found_disk vdi
| None ->
error "Found no VDI with location = %s: %s"
vdi_record.API.vDI_location
( if config.force then
"ignoring error because '--force' is set"
else
"treating as fatal and abandoning import"
) ;
if config.force then
Skip
else if exists vdi_record.API.vDI_SR state.table then
let error_string =
Printf.sprintf "Found no VDI with location = %s%s"
vdi_record.API.vDI_location
( if config.force then
": ignoring error because '--force' is set"
else
""
)
in
if config.force then (
warn "%s" error_string ; Skip
) else if exists vdi_record.API.vDI_SR state.table then
let sr = lookup vdi_record.API.vDI_SR state.table in
Found_no_disk
(Api_errors.Server_error
( Api_errors.vdi_location_missing
, [Ref.string_of sr; vdi_record.API.vDI_location]
)
( error_string
, Api_errors.Server_error
( Api_errors.vdi_location_missing
, [Ref.string_of sr; vdi_record.API.vDI_location]
)
)
else
Found_no_disk
(Api_errors.Server_error
(Api_errors.vdi_content_id_missing, [])
( error_string
, Api_errors.Server_error
(Api_errors.vdi_content_id_missing, [])
)
)
)
Expand All @@ -1123,18 +1127,19 @@ module VDI : HandlerTools = struct
state.table <- (x.cls, x.id, Ref.string_of vdi) :: state.table
| Found_no_iso ->
() (* VDI will be ejected. *)
| Found_no_disk e -> (
| Found_no_disk (error_string, e) -> (
match config.import_type with
| Metadata_import {live= true; _} ->
(* We expect the disk to be missing during a live migration dry run. *)
debug
warn
"Ignoring missing disk %s - this will be mirrored during a real \
live migration."
x.id ;
live migration. (Suppressed error: '%s')"
x.id error_string ;
(* Create a dummy disk in the state table so the VBD import has a disk to look up. *)
let dummy_vdi = Ref.make () in
state.table <- (x.cls, x.id, Ref.string_of dummy_vdi) :: state.table
| _ ->
error "%s - treating as fatal and abandoning import" error_string ;
raise e
)
| Skip ->
Expand All @@ -1161,7 +1166,8 @@ module VDI : HandlerTools = struct
with Not_found -> ()
)
Xapi_globs.vdi_other_config_sync_keys
| Found_no_disk e ->
| Found_no_disk (error_string, e) ->
error "%s - treating as fatal and abandoning import" error_string ;
raise e
| Create vdi_record ->
(* Make a new VDI for streaming data into; adding task-id to sm-config on VDI.create so SM backend can see this is an import *)
Expand Down

0 comments on commit 314cedf

Please sign in to comment.