irods-contrib / metalnx-web

Metalnx Web Application
https://metalnx.github.io/
BSD 3-Clause "New" or "Revised" License
36 stars 36 forks source link

Metalnx upload fails against irods 4.2.9 #246

Closed peterverraedt closed 3 years ago

peterverraedt commented 3 years ago

Upload of new files through metalnx fail against irods 4.2.9. The following error is reported in the rods log:

Jun 21 15:49:15 pid:384 remote addresses: 127.0.0.1, 2a02:2c40:0:51:178:0:17:988f ERROR: [rsDataObjOpen_impl:860] - [SYS_RESC_DOES_NOT_EXIST: [-]      /repos/irods/server/core/src/irods_resource_manager.cpp:84:irods::error irods::resource_manager::resolve(std::string, irods::resource_ptr &) :  status [SYS_RESC_DOES_NOT_EXIST]  errno [] -- message [no resource found for name [undefined]]

We have set default.storage.resource=default in metalnx.properties, but setting to an empty value gives the same problem. We have set "default_resource_name": "default" in our irods configuration, and the following in core.re.

acSetRescSchemeForCreate {
  msiSetDefaultResc("default","null");
}
acSetRescSchemeForRepl {
  msiSetDefaultResc("default","null");
}

This was tested with metalnx 2.3.0 and 2.4.0 (with patches for mysql) against irods 4.2.9. The exact same versions of metalnx do work fine against irods 4.2.8 with exact the same configuration.

I wonder whether msiSetDefaultResc is still doing its thing in time, or metalnx is ignoring the default.storage.resource property altogether - maybe best to test first whether this can be reproduced.

trel commented 3 years ago

Hmm, this is news. Will reproduce here - pretty sure we had it working prior to 4.2.9 release.

peterverraedt commented 3 years ago

The following patch shows why this problem occurs and solves it. To be more precise, the error only occurs if the 'Advanced view' is disabled and the user does not see the form to select a target resource. On submission of the form, resourcesToUpload contains the string "undefined" which is in the end passed to irods as target resource.

diff --git a/src/metalnx-web/src/main/java/com/emc/metalnx/controller/UploadController.java b/src/metalnx-web/src/main/java/com/emc/metalnx/controller/UploadController.java
index 7c295d3c..5dc470e3 100755
--- a/src/metalnx-web/src/main/java/com/emc/metalnx/controller/UploadController.java
+++ b/src/metalnx-web/src/main/java/com/emc/metalnx/controller/UploadController.java
@@ -109,6 +109,10 @@ public class UploadController {
                boolean overwrite = Boolean.parseBoolean(multipartRequest.getParameter("overwriteDuplicateFiles"));
                String resources = multipartRequest.getParameter("resources");
                String resourcesToUpload = multipartRequest.getParameter("resourcesToUpload");
+               if (resourcesToUpload.equals("undefined")) {
+                       resourcesToUpload = "default";
+               }
+
                String destPath = multipartRequest.getParameter("uploadDestinationPath");

                logger.info("parsed parameters...");
trel commented 3 years ago

Very good find. Thank you.

korydraughn commented 3 years ago

If we enable the advanced settings and try to upload a file, we're given a dropdown box that allows us to pick a valid resource. The entries in the dropdown box are populated by calling getAvailableRescForPath.

Based on that, I can think of a few choices for this issue:

Further experimentation shows that attempting to set resourcesToUpload to null or an empty string results in the file not being uploaded. There is no indication of failure either.

For now, I think the best option is to set the parameter to the value of default.storage.resource if undefined is encountered. If no default resource has been defined, return an error to the client.

korydraughn commented 3 years ago

Another solution is to always use the advanced view. That way, users always provide a valid resource.