Skip to content

CP-308455 VM.sysprep CA-414158 wait for "action" key to disappear #6604

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

Merged
merged 1 commit into from
Jul 24, 2025

Conversation

lindig
Copy link
Contributor

@lindig lindig commented Jul 24, 2025

The code misses the timeout exception becaue of we are using a module alias.

Copy link
Contributor

@edwintorok edwintorok left a comment

Choose a reason for hiding this comment

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

That is a bit unexpected, that alias is not a real module alias then.

@lindig lindig force-pushed the private/christianlin/vm-sysprep branch from de09270 to 6311f64 Compare July 24, 2025 12:34
The code misses the timeout exception becaue of we are using a module
alias.

Signed-off-by: Christian Lindig <christian.lindig@cloud.com>
@lindig lindig force-pushed the private/christianlin/vm-sysprep branch from 6311f64 to b574b9a Compare July 24, 2025 12:39
@last-genius
Copy link
Contributor

I'm a bit confused here, why would this not work?

@lindig
Copy link
Contributor Author

lindig commented Jul 24, 2025

We are all a bit surprised. A simple repro does work as intended. It could be related to functors or dune. The code below works as expected.

module Outer = struct
  module Inner = struct
    exception E

    let f () = raise E
  end
end

let main () =
  let module I = Outer.Inner in
  try 
    I.f ()
  with
    I.E -> print_endline "gotcha"

let () = main ()

@edwintorok
Copy link
Contributor

edwintorok commented Jul 24, 2025

We need to confirm that the test was indeed running the latest code, and not some older version that lacked the exception handler, otherwise sounds like a compiler bug if we can reproduce it, but like Christian said a simple repro attempt works as expected.

@lindig
Copy link
Contributor Author

lindig commented Jul 24, 2025

The test failure was on this code:

let trigger ~domid ~uuid ~timeout =
  let open Ezxenstore_core.Xenstore in
  let module Watch = Ezxenstore_core.Watch in
  let control = Printf.sprintf "/local/domain/%Ld/control/sysprep" domid in
  let domain = Printf.sprintf "/local/domain/%Ld" domid in
  with_xs (fun xs ->
      xs.Xs.write (control // "filename") "d://unattend.xml" ;
      xs.Xs.write (control // "vdi-uuid") uuid ;
      xs.Xs.write (control // "action") "sysprep" ;
      debug "%s: notified domain %Ld" __FUNCTION__ domid ;
      try
        (* wait for sysprep to start, then domain to dissapear *)
        Watch.(
          wait_for ~xs ~timeout:5.0
            (value_to_become (control // "action") "running")
        ) ;
        debug "%s: sysprep is runnung; waiting for sysprep to finish"
          __FUNCTION__ ;
        Watch.(wait_for ~xs ~timeout (key_to_disappear (control // "action"))) ;
        debug "%s sysprep is finished" __FUNCTION__ ;
        Watch.(wait_for ~xs ~timeout (key_to_disappear domain)) ;
        true
      with Watch.Timeout _ ->
        debug "%s: sysprep timeout" __FUNCTION__ ;
        false
  )

@lindig lindig added this pull request to the merge queue Jul 24, 2025
Merged via the queue into xapi-project:master with commit dd75195 Jul 24, 2025
14 of 18 checks passed
lindig added a commit to lindig/xen-api that referenced this pull request Jul 25, 2025
…pi-project#6604)

We have seen failures to eject the CD at the end; catch exceptions when
failing to eject the ISO/CD from the VM.

Signed-off-by: Christian Lindig <christian.lindig@cloud.com>
lindig added a commit to lindig/xen-api that referenced this pull request Jul 25, 2025
…pi-project#6604)

Eject CD once sysprep is no longer running. This moves it to an earlier
point to avoid we try to eject the CD when the VM is rebooting and is
not cooperating.

Signed-off-by: Christian Lindig <christian.lindig@cloud.com>
lindig pushed a commit to lindig/xen-api that referenced this pull request Jul 28, 2025
…ear (xapi-project#6604)

Signed-off-by: Christian Lindig <christian.lindig@cloud.com>
lindig added a commit to lindig/xen-api that referenced this pull request Jul 28, 2025
…pi-project#6604)

Make sure we eject the CD on the failure path as well.

Signed-off-by: Christian Lindig <christian.lindig@cloud.com>
lindig added a commit to lindig/xen-api that referenced this pull request Jul 29, 2025
…pi-project#6604)

Change when a CD is ejected because ideally the VM is still running at
this point:

* wait for sysprep no longer being reported as running
* eject

Make sure we still eject the CD if we hit a timeout before reaching that
point.

Signed-off-by: Christian Lindig <christian.lindig@cloud.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