Uploaded image for project: 'XNAT'
  1. XNAT
  2. XNAT-6081

Deleted resources show as available in project container launch

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 1.7.5
    • Fix Version/s: 1.7.6
    • Component/s: Cache, Resources, UI
    • Labels:
      None
    • Rank:
      0|ii1r13:

      Description

      To recreate this:

      1. Add the xnat/debug-command:1.5 docker image to your XNAT with Container Service.
      2. Add the command listed at the bottom of the ticket to the image.
      3. Create a new project. Enable the new command in the project.
      4. Create two new project resources, A and B.
      5. Delete resource A via REST. That is, with a DELETE to /data/projects/$PROJECTID/resources/A.
      6. Refresh the page. Find the container launch option in the actions box and select it.
      7. In the container UI displayed, both resources will be present.

      Kate originally found the issue. I've listed her more technical comments below:

      When I delete a project resource via API (DELETE to projects/PID/resources/RESID as occurs when you delete via Manage Files), the resource is removed via CatalogResource.java>handleDelete(), which deletes with SaveItemHelper.authorizedRemoveChild(...). However, if I then bring up the container launch UI for a container that uses project resources, the deleted resource still appears in the list. I believe this is because the project is cached via DefaultUserProjectCache and this cache entry isn’t updated from SaveItemHelper.authorizedRemoveChild(...).
      1) does that seem like a correct explanation of the behavior?
      2) if so, how do I get that cache to update? am I supposed to trigger an event?

      Incidentally, I don’t see the same thing when adding a resource, I believe because DefaultCatalogService>insertProjectResourceCatalog calls working.setResources_resource(resourceCatalog);, which is operating on the cached object, before calling SaveItemHelper.authorizedSave(...)
      Adding XDAT.triggerXftItemEvent(parent.getItem(), XftItemEvent.UPDATE); to SaveItemHelper.removeItemReference(...) fixes the issue… not sure if this is the appropriate thing to do, though

      Command:

      {
        "name": "debug-resource",
        "label": "debug-resource",
        "description": "Runs a user-provided command RESOURCE",
        "version": "1.5",
        "schema-version": "1.0",
        "image": "xnat/debug-command:latest",
        "type": "docker",
        "command-line": "echo #RESOURCE# > /output/#OUTFILE#",
        "override-entrypoint": true,
        "mounts": [
          {
            "name": "out",
            "writable": true,
            "path": "/output"
          }
        ],
        "environment-variables": {},
        "ports": {},
        "inputs": [
          {
            "name": "RESOURCE",
            "label": null,
            "description": "The resource",
            "type": "string",
            "required": true
          },
          {
            "name": "output-file",
            "label": null,
            "description": "Name of the file to collect stdout",
            "type": "string",
            "default-value": "out.txt",
            "required": false,
            "replacement-key": "#OUTFILE#"
          }
        ],
        "outputs": [
          {
            "name": "output",
            "description": "The command's stdout",
            "required": true,
            "mount": "out",
            "path": null,
            "glob": null
          }
        ],
        "xnat": [
          {
            "name": "debug-project-resource",
            "label": "Debug resource mount",
            "description": "Run the debug resource mount container on a project",
            "contexts": [
              "xnat:projectData"
            ],
            "external-inputs": [
              {
                "name": "project",
                "label": null,
                "description": "Input project",
                "type": "Project",
                "matcher": null,
                "default-value": null,
                "required": true,
                "replacement-key": null,
                "sensitive": null,
                "provides-value-for-command-input": null,
                "provides-files-for-command-mount": null,
                "via-setup-command": null,
                "user-settable": null,
                "load-children": true
              }
            ],
            "derived-inputs": [
              {
                "name": "resource",
                "label": "Resource",
                "description": null,
                "type": "Resource",
                "matcher": null,
                "default-value": null,
                "required": true,
                "replacement-key": null,
                "sensitive": null,
                "provides-value-for-command-input": "RESOURCE",
                "provides-files-for-command-mount": null,
                "user-settable": true,
                "load-children": true,
                "derived-from-wrapper-input": "project",
                "derived-from-xnat-object-property": null,
                "via-setup-command": null
              }
            ],
            "output-handlers": [
              {
                "name": "output-resource",
                "accepts-command-output": "output",
                "via-wrapup-command": null,
                "as-a-child-of": "project",
                "type": "Resource",
                "label": "DEBUG_OUTPUT",
                "format": null
              }
            ]
          }
        ]
      }
      

        Attachments

          Activity

            People

            Assignee:
            moore.c@wustl.edu Charlie Moore
            Reporter:
            moore.c@wustl.edu Charlie Moore
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:

                Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 2 hours
                2h