cconard96 / jamf

JAMF Plugin for GLPI
GNU General Public License v2.0
6 stars 5 forks source link

No devices on IMPORT/SYNC #108

Closed bacus99 closed 2 years ago

bacus99 commented 2 years ago

Describe the bug PHP error, unable to get my devices [2022-06-02 16:47:55] glpiphplog.CRITICAL: Uncaught Exception RuntimeException: Required argument missing! in /usr/share/glpi/marketplace/jamf/ajax/import.php at line 69
[2022-06-02 16:48:22] glpiphplog.CRITICAL:
Uncaught Exception RuntimeException: Required argument missing! in /usr/share/glpi/marketplace/jamf/ajax/merge.php at line 129

Not clear what is missing there

To Reproduce Anytime I click on import button

Expected behavior

Screenshots

System Specifications (please complete the following information):

Additional context Add any other context about the problem here.

cconard96 commented 2 years ago

Do you get any warnings or errors in the browser console when you try to import or merge (F12 key > Console tab)? You may need to check the box in the console tab that preserves log entries for this test.

bacus99 commented 2 years ago

New version looks more reliable. I can now see the devices in import. Still issue with merge

[2022-06-09 08:06:23] glpiphplog.WARNING: *** PHP Warning (2): array_column() expects parameter 1 to be array, null given in /usr/share/glpi/marketplace/jamf/front/merge.php at line 95 Backtrace : marketplace/jamf/front/merge.php:95 array_column()

[2022-06-09 08:06:23] glpiphplog.WARNING: *** PHP Warning (2): array_column() expects parameter 1 to be array, null given in /usr/share/glpi/marketplace/jamf/front/merge.php at line 95 Backtrace : marketplace/jamf/front/merge.php:95 array_column()

bacus99 commented 2 years ago

ok, new errors since the 3.0.1 beta version

[2022-06-09 08:01:38] glpisqllog.ERROR: DBmysql::query() in /usr/share/glpi/src/DBmysql.php line 370 *** MySQL query error: SQL: SELECT id, jamf_type, jamf_items_id FROM glpi_plugin_jamf_devices Error: Unknown column 'id' in 'field list' Backtrace : src/DBmysqlIterator.php:110
src/DBmysql.php:1048 DBmysqlIterator->execute() marketplace/jamf/inc/migration.class.php:551 DBmysql->request() marketplace/jamf/inc/migration.class.php:84 PluginJamfMigration->apply_3_0_0_migration() marketplace/jamf/hook.php:29 PluginJamfMigration->applyMigrations() src/Plugin.php:779 plugin_jamf_install() : Plugin->install() src/Marketplace/Controller.php:545 call_user_func() src/Marketplace/Controller.php:435 Glpi\Marketplace\Controller->setPluginState() ajax/marketplace.php:82 Glpi\Marketplace\Controller->installPlugin()

When importing manually

[2022-06-09 08:02:36] glpisqllog.ERROR: DBmysql::query() in /usr/share/glpi/src/DBmysql.php line 370 *** MySQL query error: SQL: INSERT INTO glpi_plugin_jamf_imports (jamf_type, jamf_items_id, name, type, date_discover) VALUES ('Computer', '22', 'LMENEBBENS', 'Computer', '2022-06-09 08:02:35') Error: Field 'udid' doesn't have a default value Backtrace : src/DBmysql.php:1312
marketplace/jamf/inc/computersync.class.php:572 DBmysql->insert() marketplace/jamf/inc/cron.class.php:56 PluginJamfComputerSync::discover() src/CronTask.php:1018 PluginJamfCron::cronImportJamf() marketplace/jamf/ajax/cron.php:50 CronTask::launch()

bacus99 commented 2 years ago

[2022-06-09 08:34:05] glpisqllog.ERROR: DBmysql::query() in /usr/share/glpi/src/DBmysql.php line 370 *** MySQL query error: SQL: INSERT INTO glpi_plugin_jamf_devices (itemtype, items_id, udid, jamf_type, jamf_items_id, model_identifier) VALUES ('Computer', '59053', 'F8655FE4-FAD3-5571-91B8-0E2AF0FDE46A', 'Computer', '22', 'MacBookPro14,3') Error: Unknown column 'udid' in 'field list' Backtrace : src/DBmysql.php:1312
marketplace/jamf/inc/computersync.class.php:644 DBmysql->insert() marketplace/jamf/ajax/import.php:65 PluginJamfComputerSync::import()

[2022-06-09 08:34:06] glpisqllog.ERROR: DBmysql::query() in /usr/share/glpi/src/DBmysql.php line 370 *** MySQL query error: SQL: INSERT INTO glpi_plugin_jamf_devices (itemtype, items_id, udid, jamf_type, jamf_items_id, model_identifier) VALUES ('Computer', '59054', '65AF887E-9D86-58A3-871E-4B3C4FA1A9C2', 'Computer', '26', 'MacBookAir6,2') Error: Unknown column 'udid' in 'field list' Backtrace : src/DBmysql.php:1312
marketplace/jamf/inc/computersync.class.php:644 DBmysql->insert() marketplace/jamf/ajax/import.php:65 PluginJamfComputerSync::import()

cconard96 commented 2 years ago

The error seen regarding "udid" not having a default value was fixed by #106 (database schema needs changed to allow NULL in that column). The missing "id" and "udid" columns in the glpi_plugin_jamf_devices table makes it seem like one or more database changes were not applied during the update process. There is not an easy way to force the installation process of a plugin to re-run to catch missed migrations even though I made them safe to replay (If a needed table or field already exists or matches the expected format, the migration isn't run again).

The only way I can think to do it is to reset the plugin's last known version:

UPDATE `glpi_configs` SET `value` = '1.0.0' WHERE (`context` = 'plugin:Jamf' AND `name` = 'plugin_version'); 

Then, force the install from the CLI tool:

bin/console plugin:install jamf --force
bin/console plugin:activate jamf

I would recommend as always before an update, to backup the database or in this case, at least the glpi_plugin_jamf tables.

bacus99 commented 2 years ago

force install says denied, but I changed the version as ROOT

[root@lidsnocprd02 glpi]# bin/console plugin:install jamf --force bash: bin/console: Permission denied

I script to add UUID to my devices, now they are same in sync. Forcing sync give:

Sync:

[2022-06-10 13:14:36] glpiphplog.WARNING: *** PHP Warning (2): array_column() expects parameter 1 to be array, null given in /usr/share/glpi/marketplace/jamf/front/merge.php at line 95 Backtrace : marketplace/jamf/front/merge.php:95 array_column()

cconard96 commented 2 years ago

Hello,

This should be fixed by #111

bacus99 commented 2 years ago

error looks corrected

cconard96 commented 2 years ago

Merged fix for master and 3.0.1 versions. The fix was manually backported for 2.2.1. After some other import/sync issues are fixed, I plan to release the 3.0.1 (GLPI 10) and 2.2.1 (GLPI 9.5) versions.