xen-orchestra icon indicating copy to clipboard operation
xen-orchestra copied to clipboard

Job using jun.runSequence always fails with Parameter Errors

Open billgertz opened this issue 1 year ago • 6 comments

Built from XO sources:

Bug Description Jobs using XO API job.runSequence always fail with invalid parameters. Even a simple job that stops and restarts a VM fails with or without a schedule. Should the array bug reported earlier in #5983, #5973, and #5944 affect job.runSequence? If not known please be aware this is also broken.

To Reproduce Just so you know, this is not my original intent but rather a simple example expressing the problem with job.runSequence. Steps to reproduce the behavior:

  1. Go to Jobs > +New
  2. Create the following new Jobs:

a. Stop-Hosts: - User: admin user with authority to run jobs - Name: Stop-Hosts - API Command: vm.stop -- VM(s): Pick running VM(s) -- Enable: force -- Enable: bypassBlockedOperation

b. Restart-Hosts: - User: admin user with authority to run jobs - Name: Restart-Hosts - API Command: vm.restart -- VM(s): Same VM(s) as above -- Enable: force -- Enable: bypassBlockedOperation

c. Reboot-Hosts: - User: admin user with authority to run jobs - Name: Restart-Hosts - API Command: job.runSequence -- idSequence Add job ids from the above two jobs using the copy to clipboard button for each listed job on the +New tab

  1. Click on the Play button on the Reboot-Hosts job from the +New tab
  2. Go to the Overview tab
  3. See the details of the failed job by clicking on the View button by the red Finished cartouche
  4. Details show something like: job.runSequence: idSequence: 369b79ba-1986-45ce-b1ca-db394cb5ad8e description: Reboot selected VMs VM: BFXOA002 (great old ones) Start: Sep 12, 2023 at 01:46:54 PM invalid parameters job.runSequence: idSequence: 65c8afa0-2520-4a85-93c3-cbd8f0584863 description: Reboot selected VMs VM: BFXOA002 (great old ones) Start: Sep 12, 2023 at 01:46:54 PM invalid parameters

Expected behavior Stop and restart the VMs configured in the sequence job.

Environment:

  • OS: Debian GNU/Linux 11 (bullseye)
  • Node: 18.17.1
  • hypervisor: XCP-ng 8.2.1 w/ most recent updates (August 2023 Security Updates)

Syslog entries

Sep 12 13:19:41 bfxoa001 systemd[787239]: Listening on GnuPG cryptographic agent and passphrase cache.
Sep 12 13:19:41 bfxoa001 systemd[787239]: Listening on D-Bus User Message Bus Socket.
Sep 12 13:19:41 bfxoa001 systemd[787239]: Reached target Sockets.
Sep 12 13:19:41 bfxoa001 systemd[787239]: Reached target Basic System.
Sep 12 13:19:41 bfxoa001 systemd[1]: Started User Manager for UID 1000.
Sep 12 13:19:41 bfxoa001 systemd[1]: Started Session 795 of user xxxxxxxx.
Sep 12 13:19:41 bfxoa001 systemd[787239]: Reached target Main User Target.
Sep 12 13:19:41 bfxoa001 systemd[787239]: Startup finished in 476ms.
Sep 12 13:26:25 bfxoa001 xo-server[637133]: 2023-09-12T11:26:25.966Z xo:api WARN xxxxxxxx.| job.runSequence(...) [1ms] =!> XoError: invalid parameters
Sep 12 13:26:25 bfxoa001 xo-server[637133]: 2023-09-12T11:26:25.967Z xo:api WARN xxxxxxxx. | job.runSequence(...) [2ms] =!> XoError: invalid parameters

Settings Logs Listing

job.runSequence
{
  "idSequence": "65c8afa0-2520-4a85-93c3-cbd8f0584863",
  "description": "Reboot selected VMs",
  "id": "795067e2-b1b3-bb99-3007-33b607494766"
}
{
  "code": 10,
  "data": {
    "errors": [
      {
        "instancePath": "",
        "schemaPath": "#/additionalProperties",
        "keyword": "additionalProperties",
        "params": {
          "additionalProperty": "description"
        },
        "message": "must NOT have additional properties"
      },
      {
        "instancePath": "",
        "schemaPath": "#/additionalProperties",
        "keyword": "additionalProperties",
        "params": {
          "additionalProperty": "id"
        },
        "message": "must NOT have additional properties"
      },
      {
        "instancePath": "/idSequence",
        "schemaPath": "#/properties/idSequence/type",
        "keyword": "type",
        "params": {
          "type": "array"
        },
        "message": "must be array"
      }
    ]
  },
  "message": "invalid parameters",
  "name": "XoError",
  "stack": "XoError: invalid parameters
    at Module.invalidParameters (/opt/xo/xo-builds/xen-orchestra-202309062341/packages/xo-common/api-errors.js:26:11)
    at Xo.call (file:///opt/xo/xo-builds/xen-orchestra-202309062341/packages/xo-server/src/xo-mixins/api.mjs:65:20)
    at Api.#callApiMethod (file:///opt/xo/xo-builds/xen-orchestra-202309062341/packages/xo-server/src/xo-mixins/api.mjs:413:19)"
}

billgertz avatar Sep 12 '23 12:09 billgertz

Hello,

What's the full error displayed in Settings/Logs?

julien-f avatar Sep 12 '23 12:09 julien-f

@julien-f Added the Settings/ Logs entry to the original report (above). A quick parse of that log seems to show it doesn't seem to digest any of the parameters (description, id, or idSequence)

billgertz avatar Sep 12 '23 12:09 billgertz

Screen snapshot of job.runSequence as configured:

Screenshot 2023-09-12 at 14 36 51

billgertz avatar Sep 12 '23 12:09 billgertz

@julien-f This has been seen before in a forum discussion. On 21 Dec 2022 @julien-f mentioned this is related to #5973.

billgertz avatar Sep 12 '23 13:09 billgertz

AFAIK, currently reworked by @julien-f

olivierlambert avatar Sep 15 '23 07:09 olivierlambert

@julien-f Would be happy to lend a hand in patching and refactoring. But need a pointer in groking the job parser.

billgertz avatar Sep 15 '23 09:09 billgertz