glpi-project / glpi-inventory-plugin

GLPI Inventory plugin
GNU Affero General Public License v3.0
46 stars 27 forks source link

On demand deploy packages not working. #382

Closed kintaro1981 closed 1 year ago

kintaro1981 commented 1 year ago

Describe the bug

On demand deploy packages are are not working.

To reproduce

  1. go to deploy package tab in a computer item
  2. choose a package
  3. click on: I'm not on this computer: wakeup from the server

Expected behavior

I expect that:

  1. the "ondemand task" is going to be listed in the Task/Groups tabs with the others tasks.
  2. the deploy starts right away

Instead:

  1. I can only see that the package is listed in grey "waiting" in the deploy package tab

  2. if I try to click on the + to get more info I can't - firefox console say this:

    Uncaught SyntaxError: expected expression, got ','
    x http://glpi/public/lib/base.min.js?v=53489c6e5ec38eb33efa18c9adf8b3027ed40b87:188
    Be http://glpi/public/lib/base.min.js?v=53489c6e5ec38eb33efa18c9adf8b3027ed40b87:199
    append http://glpi/public/lib/base.min.js?v=53489c6e5ec38eb33efa18c9adf8b3027ed40b87:199
    html http://glpi/public/lib/base.min.js?v=53489c6e5ec38eb33efa18c9adf8b3027ed40b87:199
    K http://glpi/public/lib/base.min.js?v=53489c6e5ec38eb33efa18c9adf8b3027ed40b87:199
    html http://glpi/public/lib/base.min.js?v=53489c6e5ec38eb33efa18c9adf8b3027ed40b87:199
    loadTabContents http://glpi/front/computer.form.php?id=13718:2045
    l http://glpi/public/lib/base.min.js?v=53489c6e5ec38eb33efa18c9adf8b3027ed40b87:199
    fireWith http://glpi/public/lib/base.min.js?v=53489c6e5ec38eb33efa18c9adf8b3027ed40b87:199
    C http://glpi/public/lib/base.min.js?v=53489c6e5ec38eb33efa18c9adf8b3027ed40b87:199
    t http://glpi/public/lib/base.min.js?v=53489c6e5ec38eb33efa18c9adf8b3027ed40b87:199
    computer.form.php:21:45
    x http://glpi/public/lib/base.min.js?v=53489c6e5ec38eb33efa18c9adf8b3027ed40b87:188
    Be http://glpi/public/lib/base.min.js?v=53489c6e5ec38eb33efa18c9adf8b3027ed40b87:199
    append http://glpi/public/lib/base.min.js?v=53489c6e5ec38eb33efa18c9adf8b3027ed40b87:199
    html http://glpi/public/lib/base.min.js?v=53489c6e5ec38eb33efa18c9adf8b3027ed40b87:199
    K http://glpi/public/lib/base.min.js?v=53489c6e5ec38eb33efa18c9adf8b3027ed40b87:199
    html http://glpi/public/lib/base.min.js?v=53489c6e5ec38eb33efa18c9adf8b3027ed40b87:199
    loadTabContents http://glpi/front/computer.form.php?id=13718:2045
    l http://glpi/public/lib/base.min.js?v=53489c6e5ec38eb33efa18c9adf8b3027ed40b87:199
    fireWith http://glpi/public/lib/base.min.js?v=53489c6e5ec38eb33efa18c9adf8b3027ed40b87:199
    C http://glpi/public/lib/base.min.js?v=53489c6e5ec38eb33efa18c9adf8b3027ed40b87:199
    t http://glpi/public/lib/base.min.js?v=53489c6e5ec38eb33efa18c9adf8b3027ed40b87:199
  3. The agent on the computer starts, it runs scheduled tasks but not the on demand ones

  4. The ondemand task is not present in the Task/Group tab

  5. the ondemand task is correctly added to the Tasks page (/plugins/glpiinventory/front/task.php)

  6. In the agent log I can see the other deploy tasks running ok but not the on-demand one.

Operating system

Windows

GLPI Agent version

1.4, Other (See additional context below)

GLPI version

10.0.9

GLPIInventory plugin

1.2.3

Additional context

fusion agent 2.5.2

kintaro1981 commented 1 year ago

am I the only one with this issue?

kintaro1981 commented 1 year ago

anyone have any ideas how to fix this?

cedric-anne commented 1 year ago

We would need to see the syntax error itself to understand the issue. It may be due to some unexpected chars in some variable, that broke the JS syntax. For instance, on Chrome, when you have an error, you can expand the stack trace and access see the related code by clicking on the link that is shown here. image

AnthoDingo commented 1 year ago

Hello,

Same error with same config :

The entire error : image

The error is occurred on the underline : image

The base.min.js file is located in public/lib/ folder.

cedric-anne commented 1 year ago

What is displayed when you click on the link located on the right (VM316:21) ?

AnthoDingo commented 1 year ago

Below the information :

image

stonebuzz commented 1 year ago

Hi @AnthoDingo

Can you check whether you have any SQL / PHP errors from GLPI logs?

Best regards

AnthoDingo commented 1 year ago

Hi @stonebuzz

The log from php_error.log file.

[2023-08-16 08:21:52] glpiphplog.WARNING:   *** PHP Warning (2): Undefined array key "last_taskjobstate" in glpi\10.0.9\plugins\glpiinventory\inc\deploypackage.class.php at line 1582
  Backtrace :
  ...\glpiinventory\inc\deploypackage.class.php:1097 PluginGlpiinventoryDeployPackage->showPackageForMe()
  src\CommonGLPI.php:691                             PluginGlpiinventoryDeployPackage::displayTabContentForItem()
  ajax\common.tabs.php:117                           CommonGLPI::displayStandardTab()

[2023-08-16 08:21:52] glpiphplog.WARNING:   *** PHP Warning (2): Trying to access array offset on value of type null in glpi\10.0.9\plugins\glpiinventory\inc\deploypackage.class.php at line 1582
  Backtrace :
  ...\glpiinventory\inc\deploypackage.class.php:1097 PluginGlpiinventoryDeployPackage->showPackageForMe()
  src\CommonGLPI.php:691                             PluginGlpiinventoryDeployPackage::displayTabContentForItem()
  ajax\common.tabs.php:117                           CommonGLPI::displayStandardTab()
stonebuzz commented 1 year ago

I can't reproduce it. I don't know if you're familiar with development, but the problem must be here.

File : deploypackage.class.php

Function : getPackageForMe (L1726)

The last lines of this function should set the last_taskjobstate key (which is missing in the rest of the process)

Can you try to debug ?

AnthoDingo commented 1 year ago

@stonebuzz the function getMyDepoyPackagesState return an empty array

$last_job_state => array(0) { }

The query return nothing

$taskjobstates  = current($pfTaskJobState->find(
            ['plugin_glpiinventory_taskjobs_id' => $taskjobs_id,
            'agents_id'   => $agents_id],
            ['id DESC'],
            1
        ));

In prod, this is what I have: image

$taskjobs_id = 906 $agents_id = 167

On my sql instance, when I put my resquest, nothing is found : image

Is it possible that on the task creation, the taskjobstate insert has an error ?

stonebuzz commented 1 year ago

have you prepared the task ?

AnthoDingo commented 1 year ago

Hi @stonebuzz ,

I push the package from the Computer element, on the tab "Packages Deployment" ( http://myserver/front/computer.form.php?id=808 => tab "Packages Deployment")

stonebuzz commented 1 year ago

can you run "Force Start" from task and retry image

kintaro1981 commented 1 year ago

in my case, even if I click the button "Force start" in the [deploy on demand] task the job is not getting prepared. In Job executions all is 0. immagine immagine

after clicking on Force start

immagine

stonebuzz commented 1 year ago

Can you show me related package (all tab)

Best regards

kintaro1981 commented 1 year ago

immagine immagine immagine

stonebuzz commented 1 year ago

can you try #393

kintaro1981 commented 1 year ago

@stonebuzz in my case #393 fixed the issue thank you