perfsonar / psconfig-web

pSConfig Web Admin
Apache License 2.0
7 stars 9 forks source link

Bugfix/meshconfig adhoc hosts #233

Open mty22 opened 4 months ago

mty22 commented 4 months ago

This bugfix covers corner cases when you add an Adhoc host via API then add the respective host to a host group, then mesh config.

The error encountered when loading mesh config:

Thu May 02 2024 05:19:14 GMT+0000 (Coordinated Universal Time) - ESC[31merrorESC[39m: Thu, 02 May 2024 05:19:14 GMT uncaughtException: Cannot read properties of undefined (reading 'location-country')
Thu May 02 2024 05:19:14 GMT+0000 (Coordinated Universal Time) - ESC[31merrorESC[39m: TypeError: Cannot read properties of undefined (reading 'location-country')
    at /usr/lib/perfsonar/psconfig-web-admin/pub/api/pub/meshconfig.js:989:50
    at Array.forEach (<anonymous>)
    at /usr/lib/perfsonar/psconfig-web-admin/pub/api/pub/meshconfig.js:988:19
    at /usr/lib/perfsonar/psconfig-web-admin/shared/node_modules/async/dist/async.js:473:16
    at replenish (/usr/lib/perfsonar/psconfig-web-admin/shared/node_modules/async/dist/async.js:1009:25)
    at iterateeCallback (/usr/lib/perfsonar/psconfig-web-admin/shared/node_modules/async/dist/async.js:998:17)
    at /usr/lib/perfsonar/psconfig-web-admin/shared/node_modules/async/dist/async.js:972:16
    at /usr/lib/perfsonar/psconfig-web-admin/shared/node_modules/async/dist/async.js:3891:9
    at /usr/lib/perfsonar/psconfig-web-admin/shared/node_modules/async/dist/async.js:473:16
    at iteratorCallback (/usr/lib/perfsonar/psconfig-web-admin/shared/node_modules/async/dist/async.js:1067:13)
    at /usr/lib/perfsonar/psconfig-web-admin/shared/node_modules/async/dist/async.js:972:16
    at /usr/lib/perfsonar/psconfig-web-admin/shared/node_modules/async/dist/async.js:3888:13
    at /usr/lib/perfsonar/psconfig-web-admin/pub/api/pub/meshconfig.js:544:9
    at /usr/lib/perfsonar/psconfig-web-admin/pub/api/pub/meshconfig.js:338:13
    at /usr/lib/perfsonar/psconfig-web-admin/pub/api/pub/meshconfig.js:324:21
    at /usr/lib/perfsonar/psconfig-web-admin/shared/node_modules/async/dist/async.js:473:16

This isn't a problem if you add the host via the PsConfig Web Admin UI, although even the data returned from the API indicates that the hosts configurations are identical (less unique fields such as _id, hostname, sitename and update_date):

image

file: a.test = json data from the host added via API. file: b.test = json data from the host added via GUI.

mty22 commented 1 month ago

Just noting that this PR containing fix works fine with perfSONAR 5.1.0 and 5.1.1

mty22 commented 1 month ago

Also works fine with perfSONAR 5.1.2