yasithdev opened a new pull request, #649:
URL: https://github.com/apache/airavata/pull/649

   ## The bug
   
   `StorageResourceEntity`'s `@OneToMany dataMovementInterfaces` joined on a 
`RESOURCE_ID` column:
   
   ```java
   @JoinColumn(name = "RESOURCE_ID", referencedColumnName = 
"STORAGE_RESOURCE_ID")
   ```
   
   But the child entity `DataMovementInterfaceEntity` (table 
`STORAGE_INTERFACE`) maps its FK to column `STORAGE_RESOURCE_ID` as part of its 
composite `@Id`. Hibernate therefore created a spurious, **always-NULL** 
`RESOURCE_ID` column and loaded the association with `WHERE RESOURCE_ID = ?` — 
which never matched.
   
   **Result:** every storage resource loaded zero data-movement interfaces, so 
`SSHJStorageAdaptor.init` threw `"No SCP data movement interface for storage 
resource"` and **all user-storage file operations failed.**
   
   Verified at the DB level: `STORAGE_INTERFACE` rows had `STORAGE_RESOURCE_ID` 
populated and `RESOURCE_ID` NULL.
   
   ## The fix
   
   Join the association on the column the child actually owns, and mark it 
read-only so the child remains the sole writer of the FK:
   
   ```java
   @JoinColumn(
           name = "STORAGE_RESOURCE_ID",
           referencedColumnName = "STORAGE_RESOURCE_ID",
           insertable = false,
           updatable = false)
   ```
   
   ## Dev-environment fixes (same symptom)
   
   These two changes only affect the local `tilt up` dev stack:
   
   1. **`DevStorageInitializer`** seeded `STORAGE_HOST` as `"localhost"`, 
unreachable from the server inside the `airavata-dind` network. Repointed to 
`"sftp"` (the atmoz/sftp compose service name). The idempotency check is now 
self-healing: if the dev storage resource already exists but has no SCP 
data-movement interface (from a partial prior init), it adds one.
   
   2. **`compose.yml` + `conf/sftp/chown-storage.sh`** — the named volume 
mounted at `/home/airavata/storage` in the atmoz/sftp container is created 
root-owned by Docker, so the chrooted uid-1000 `airavata` user could not create 
directories (`"Failed to create directory"`). Added an 
`/etc/sftp.d/chown-storage.sh` startup hook (atmoz/sftp runs these as root on 
boot) that chowns the volume, mounted via compose.
   
   ## Test plan
   
   - `mvn -pl airavata-api/storage-service,airavata-api/orchestration-service 
-am compile -DskipTests` → BUILD SUCCESS.
   - Locally via `tilt up`: storage resource now loads its SCP data-movement 
interface; user-storage file operations succeed.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to