Commit 40af00d8 authored by Yakubov, Sergey's avatar Yakubov, Sergey
Browse files

refactor, update README

parent 37a1f262
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -6,7 +6,7 @@ stages:
variables:
  GIT_STRATEGY: clone
  CONTAINER_RDM_URL: "${NDIP_DOCKER_REPOSITORY}/${CI_PROJECT_PATH}/remote-data-broker"
  TAG: 0.5.1
  TAG: 0.5.2

# This import is for the func_rse_docker_* functions
before_script:
+2 −2
Original line number Diff line number Diff line
@@ -7,7 +7,7 @@ set (TARGET_NAME remote-data-broker)
set (exe_name "${TARGET_NAME}")

add_custom_target(remote-data-broker ALL
    COMMAND go build ${GO_OPTS} -o ${CMAKE_CURRENT_BINARY_DIR}/${exe_name} main/rdb.go
    COMMAND go build ${GO_OPTS} -o ${CMAKE_CURRENT_BINARY_DIR}/${exe_name} main/main.go
    WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/src
    VERBATIM)
define_property(TARGET PROPERTY EXENAME
@@ -23,7 +23,7 @@ SET(CPACK_RPM_PACKAGE_MAINTAINER "ORNL")

set(CPACK_PACKAGE_VERSION_MAJOR "0")
set(CPACK_PACKAGE_VERSION_MINOR "5")
set(CPACK_PACKAGE_VERSION_PATCH "1")
set(CPACK_PACKAGE_VERSION_PATCH "2")

INCLUDE(CPack)

LICENSE.txt

0 → 100644
+22 −0
Original line number Diff line number Diff line
MIT License


Copyright (c) 2024 UT-Battelle, LLC

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
+49 −5
Original line number Diff line number Diff line
# Remote Data Broker

Remote Data Broker a is a low-level service within NDIP 
data management solution that is responsible
for serving files to other NDIP components using HTTP protocol.
Remote Data Broker is a low-level service within the NDIP data management solution responsible for serving files to
other NDIP components using the HTTP protocol. It is primarily used when files are not available locally and need to be
transferred from another location. Additionally, it provides the capability to delete remote files.

It is usually used when the files are not available locally but need to be
transferred from some other location.
 No newline at end of file
## Architecture

The broker consists of two main components:

1. **Server** – Handles HTTP requests and serves files directly or redirects them to the client via RabbitMQ. 
2. **Client** (optional) – Listens to a RabbitMQ (RMQ) queue and processes requests in cases where the broker runs on a
   machine restricted by firewall rules from accepting inbound HTTP connections.


## File Access Modes

- If the request is processed by the client, it is assumed to have direct access to the files.
- If the request is processed by the server, access is managed in two ways, depending of a query parameter in the request:
    - As the user running the service.
    - On behalf of another user via an OIDC token provided in the HTTP request.

For the latter, we use the [oidc-run-as-user](https://code.ornl.gov/ndip/ssh-oidc) utility.

## Configuration

Both the server and client are configured using a JSON file. See the example configuration file [here](conf.sample.json).

## Running the Service

The service is containerized using Docker. To build the image, run:

```bash
docker build -f dockerfiles/Dockerfile -t rdb .
```

To run the service, use:

```bash
docker run -it -p 9000:9000 -v <path to config file>:/config.json rdb /remote-data-broker -config /config.json
```

## REST API

After you start a docker container (see above), you can access the REST API documentation at the address:
http://localhost:9000/swagger/

In NDIP, the Remote Data Broker is used internally by Rucio, via an extra [protocol](https://code.ornl.gov/ndip/rucio-protocols) so there is no need to directly interact with it.

## License

See [License File](LICENSE.txt)

conf.sample.json

0 → 100644
+37 −0
Original line number Diff line number Diff line
{
  "CatCommand": "oidc-run-as-user oidc-pam.json $token -f $filename",
  "TestCommand": "oidc-run-as-user oidc-pam.json $token -c 'test -r $filename'",
  "DeleteCommand": "oidc-run-as-user oidc-pam.json $token -c 'rm -f $filename'",
  "Auth": {
    "Enabled": true,
    "JwksUrls": [
      "https://login.microsoftonline.com/xxx/discovery/v2.0/keys"
    ],
    "UserFields": [
      "username",
      "preferred_username"
    ],
    "UserList": [
      "usdr"
    ]
  },
  "Http": {
    "Enabled": true,
    "EndpointUrl": "http://127.0.0.1:9000",
    "Port": 9000,
    "ChunkSize": 100000,
    "Timeout": 30
  },
  "Rmq": {
    "Url": "amqp://guest:guest@127.0.0.1:5672"
  },
  "RmqClient": {
    "Enabled": true,
    "Queue": "test"
  },
  "LogSettings": {
    "Level": "debug",
    "LogToFile": true,
    "FileFolder": "/tmp"
  }
}
Loading