Tutorial · Compose

Bring in S3 and Google Cloud.

Object stores connect to CLIO Core in two ways. The assimilation engine imports s3:// and gs:// objects. A build with the cloud options can also use a bucket as a storage tier.

Time
20 minutes
You need
An AWS account
Status
S3 tier verified
Partly verified

An S3 bucket as a tier was run end to end against Amazon S3 with iowarp-core 2.5.1 from pip, exactly as written below. Importing objects and everything on Google Cloud Storage were checked only against the source code. For those, expect to adjust details, and please report what you find.

Which one do you need?

Import (CAE)Bucket as a tier
What it doesCopies objects into CLIO Core onceStores tiered data in a bucket
Data ends upOn your local tiers, searchable from PythonIn the bucket
Build optionsCAE_ENABLE_S3, CAE_ENABLE_GCSCLIO_ENABLE_AMAZON_DRIVE, CLIO_ENABLE_GOOGLE_CLOUD
In the pip wheelNoYes (2.5.1 and later)
StatusSupported, with unit testsS3 run end to end; GCS config parsing tested

The pip wheel includes the bucket tiers; it does not include the importers. For the importers, build from source with the options you need, or use Spack (spack install iowarp +s3_cae +gcs for import, +s3_bdev +gcs_bdev for the tiers).

shell
$ cmake --preset release-fuse \
    -DCAE_ENABLE_S3=ON -DCAE_ENABLE_GCS=ON \
    -DCLIO_ENABLE_AMAZON_DRIVE=ON -DCLIO_ENABLE_GOOGLE_CLOUD=ON
$ cmake --build build -j"$(nproc)" && sudo cmake --install build

S3 support needs the AWS SDK for C++ (aws-cpp-sdk-s3). The GCS importer needs google-cloud-cpp, and the GCS block device needs Poco (Net, NetSSL, Crypto, JSON). If one is missing, the build turns that option off with a warning.

Try an S3 tier from pip

This is the shortest path to data in a bucket, and the one that was run end to end: install from pip, sign in with the AWS CLI, create a bucket, then write and read blobs through a CTE tier stored in it. No source build is needed.

Every node that runs the runtime needs outbound HTTPS to s3.<region>.amazonaws.com. On a cluster, check from a compute node, not the login node. Any HTTP status (for example 307) means it is reachable:

shell
$ curl -s -o /dev/null -w "HTTP %{http_code}\n" https://s3.us-east-2.amazonaws.com/
HTTP 307

1. Install CLIO Core

shell
$ python3 -m venv ~/venv-iowarp
$ ~/venv-iowarp/bin/pip install --upgrade pip
$ ~/venv-iowarp/bin/pip install iowarp-core
$ source ~/venv-iowarp/bin/activate      # puts clio_run and clio_cte_bench on PATH

2. Install the AWS CLI

The AWS CLI v2 installs without root. This puts it in ~/aws-cli, with the aws command in ~/bin:

shell
$ mkdir -p ~/awscli-dl && cd ~/awscli-dl
$ curl -sSLo awscliv2.zip https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip
$ unzip -q awscliv2.zip
$ ./aws/install -i ~/aws-cli -b ~/bin
$ cd ~ && rm -rf ~/awscli-dl
$ aws --version                          # add ~/bin to PATH if not found

On ARM64, download awscli-exe-linux-aarch64.zip instead.

3. Sign in to AWS

Browser sign-in (recommended)

shell
$ aws login

Prints a link to open in any browser, so it works over SSH. Needs AWS CLI 2.32 or newer.

Organization SSO portal

shell
$ aws configure sso

For accounts reached through a *.awsapps.com/start portal.

An access key from the console

shell
$ aws configure          # key ID, secret, region, output format

To create a key, open the account menu (top right of the console) → Security credentials → Access keys → Create access key → Command Line Interface (CLI). The secret is shown once. Do not create keys for the root user (an email sign-in); make an IAM user first, as in least-privilege keys.

Check who you are signed in as, and the default region:

shell
$ aws sts get-caller-identity
$ aws configure get region

4. Create a bucket

Bucket names are global across AWS, so add a random suffix:

shell
$ BUCKET="clio-s3-test-$(head -c4 /dev/urandom | od -An -tx1 | tr -d ' \n')"
$ REGION=us-east-2
$ aws s3 mb "s3://$BUCKET" --region "$REGION"
make_bucket: clio-s3-test-d806c972
$ aws s3api head-bucket --bucket "$BUCKET" --region "$REGION"

The runtime does not create buckets unless allow_bucket_create is set, so a typo in the name fails loudly instead of creating a new bucket.

5. Hand the credentials to the runtime

The tier reads only its s3: block and the AWS_* environment variables. aws login and SSO keep their credentials in a cache, not in ~/.aws/credentials, so export them into the shell that starts the runtime:

shell
$ eval "$(aws configure export-credentials --format env)"
$ export AWS_DEFAULT_REGION=$REGION

This sets AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY and AWS_SESSION_TOKEN. The keys are temporary, typically a few hours. When they expire, run aws login and the export again, then restart the runtime.

6. Write the config

Save this as clio_s3.yaml. It has the required DRAM block device and one CTE tier in the bucket:

yaml · clio_s3.yaml
networking:
  port: 9413

compose:
  - mod_name: clio_bdev
    pool_name: "ram::chi_default_bdev"
    pool_query: local
    pool_id: "301.0"
    bdev_type: ram
    capacity: "2g"

  - mod_name: clio_cte_core
    pool_name: cte_main
    pool_query: local
    pool_id: "512.0"
    storage:
      - path: "s3://${S3_TEST_BUCKET}/clio-s3-test"
        bdev_type: "s3"
        capacity_limit: "10GB"
        score: 0.5
        persistence_level: "long_term"
        # region and keys come from AWS_DEFAULT_REGION and AWS_*
${VAR} is not expanded inside s3:

Variables are expanded in path, but not inside an s3: block. region: "${AWS_DEFAULT_REGION}" reaches the runtime as literal text and fails with Host not found: <bucket>.s3.${aws_default_region}.amazonaws.com. Inside s3:, write literal values, or leave the key out and set the variable.

7. Write and read through the bucket

shell
$ export S3_TEST_BUCKET=$BUCKET
$ export CLIO_SERVER_CONF=$PWD/clio_s3.yaml
$ clio_run --local start --fresh > runtime.log 2>&1 &
$ until clio_run --local status 2>/dev/null | grep -q running; do sleep 1; done
$ grep "S3 bdev ready" runtime.log
INFO Init S3 bdev ready: bucket='clio-s3-test-d806c972' prefix='clio-s3-test_node0' region='us-east-2' endpoint='' capacity=...
$ clio_cte_bench --op PutGet --threads 1 --depth 1 --io-size 1m --io-count 16

The benchmark should end with Total ops: 16 and no PutBlob or GetBlob errors. Then look in the bucket. CTE appends _node<N> to each node's tier, so node 0 writes under clio-s3-test_node0/, one object per block:

shell
$ aws s3 ls "s3://$BUCKET" --recursive --summarize | tail -2
Total Objects: 16
   Total Size: 16777216

The benchmark checks return codes, not the bytes it reads back. Each thread fills its buffer with its thread number, so with one thread every object is 1 MiB of zeros; aws s3 cp "s3://$BUCKET/clio-s3-test_node0/block_0" - | od -An -tx1 | sort -u shows it. Expect about 2 MB/s at one thread and depth 1, because every 1 MiB put and get is its own HTTPS round trip. Raise --threads and --depth to measure throughput.

8. Stop and clean up

shell
$ clio_run --local stop
$ aws s3 rb "s3://$BUCKET" --force      # deletes every object, then the bucket

If it fails

Runtime log saysCause and fix
Host not found: …s3.${aws_default_region}…A ${VAR} inside the s3: block. Use a literal, or drop the key and set the variable.
S3 bdev: no credentialsThe shell that started the runtime has no keys. Run the export in step 5 in that shell and restart.
RegisterTarget Failed to create bdev container s3://…, then PutBlob rc=11The S3 tier did not start, so CTE has nowhere to write. The real error is a few lines above it.
ExpiredToken or 403 after a few hoursTemporary keys expired. aws login, export again, restart.
404, bucket not foundWrong name or region. Check with aws s3api head-bucket --bucket <name>.
Timeouts on compute nodes onlyNo outbound internet from those nodes. Use the curl check at the top of this section.

Least-privilege keys

Your own sign-in is fine for a test. For a long-lived deployment, give the runtime a key that can only use one bucket: in the console, IAM → Users → Create user (no console access), attach this policy with your bucket name, then Security credentials → Create access key → Application running outside AWS. These keys do not expire; delete them when you are done.

json
{
  "Version": "2012-10-17",
  "Statement": [
    { "Effect": "Allow",
      "Action": ["s3:ListBucket"],
      "Resource": "arn:aws:s3:::YOUR-BUCKET" },
    { "Effect": "Allow",
      "Action": ["s3:GetObject", "s3:PutObject", "s3:DeleteObject"],
      "Resource": "arn:aws:s3:::YOUR-BUCKET/*" }
  ]
}

Import objects

1. Provide credentials

Amazon S3

shell
$ export AWS_ACCESS_KEY_ID=...
$ export AWS_SECRET_ACCESS_KEY=...
$ export AWS_DEFAULT_REGION=us-east-1
$ export S3_ENDPOINT=https://s3.us-east-1.amazonaws.com   # or MinIO, Ceph, ...

AWS_SESSION_TOKEN is read for temporary credentials. AWS_ENDPOINT_URL works in place of S3_ENDPOINT. Set these in the environment of clio-run start, because downloads run inside the runtime.

Google Cloud Storage

shell
$ gcloud auth application-default login
# or, for a service account:
$ export GOOGLE_APPLICATION_CREDENTIALS=$HOME/keys/clio-sa.json

The importer uses Application Default Credentials: the variable above, gcloud's stored login, or the metadata server on Google Cloud VMs. GCS_ENDPOINT overrides the endpoint, for example for an emulator.

2. Import from Python

python
import os
os.environ["CLIO_WITH_RUNTIME"] = "0"
import clio_cee as cee

ctx = cee.ContextInterface()
rc = ctx.context_bundle([
    cee.AssimilationCtx(src="s3://my-lab-bucket/runs/run42/output.bin",
                        dst="iowarp::run42", format="binary"),
    cee.AssimilationCtx(src="gs://my-lab-bucket/papers/ice-2024.txt",
                        dst="iowarp::papers", format="binary"),
])
print("imported" if rc == 0 else f"failed: {rc}")

Each object becomes data under the destination tag, stored on your local tiers. range_off and range_size import part of an object. Imports in one bundle can depend on each other through depends_on.

3. Or describe imports in YAML

The same imports can be written as an OMNI file, which suits repeatable pipelines:

yaml · imports.yaml
transfers:
  - src: s3://my-lab-bucket/runs/run42/output.bin
    dst: iowarp::run42
    format: binary
    depends_on: ""
    range_off: 0
    range_size: 0         # 0 = the whole object
  - src: gs://my-lab-bucket/papers/ice-2024.txt
    dst: iowarp::papers
    format: binary
Imported data and the mount

Imports create CTE tags, not filesystem entries, so they do not show up under the mount. Find them from Python with TagQuery, context_query or SemanticSearch. To make an object appear as a file, copy it into the mount instead: aws s3 cp s3://bucket/key ~/clio-mnt/.

Buckets as tiers

A build with CLIO_ENABLE_AMAZON_DRIVE or CLIO_ENABLE_GOOGLE_CLOUD can use a bucket as a storage tier. Give the tier bdev_type: "s3" or "gcs" and a path of the form s3://bucket/prefix or gcs://bucket/prefix. The prefix is required: CLIO Core appends _node<N> to the path for each node, and without a prefix that would change the bucket name.

1. Credentials for a bucket tier

Give credentials either in the tier's entry, as an s3: or gcs: block (step 2), or as environment variables of the process that starts the runtime. A key in the block wins over its variable. The bdev reference lists every key.

Amazon S3

shell
$ export AWS_DEFAULT_REGION=us-east-1
$ export AWS_ACCESS_KEY_ID=...  AWS_SECRET_ACCESS_KEY=...

Only these variables and the s3: block are read: ~/.aws/credentials and instance roles are not. After aws login or SSO, eval "$(aws configure export-credentials --format env)" sets all three, including AWS_SESSION_TOKEN (see step 5 above).

Google Cloud Storage

shell
$ export GCS_ACCESS_TOKEN=$(gcloud auth print-access-token)
$ export GCS_PROJECT_ID=my-project        # used only when creating the bucket

Access tokens expire after about an hour, so refresh the token and restart the runtime for long runs.

2. Add the bucket to the tier list

In the clio_cte_core entry of clio.yaml, add the bucket below your local tiers:

yaml
    storage:
      - path: "ram::hot"
        bdev_type: "ram"
        capacity_limit: "16GB"
        score: 1.0
      - path: "${CLIO_STORAGE_ROOT}/cte_disk_tier.dat"
        bdev_type: "file"
        capacity_limit: "100GB"
        score: 0.2
        persistence_level: "temporary"
      - path: "s3://my-lab-bucket/clio"      # or gcs://my-lab-bucket/clio
        bdev_type: "s3"                      # or gcs
        capacity_limit: "1TB"
        score: 0.05
        persistence_level: "long_term"
        s3:                                  # optional; else the environment
          region: us-east-2
          access_key_id: AKIA...
          secret_access_key: ...
        # gcs:
        #   access_token: ya29....

Keys in the file end up in the runtime's pool log under conf_dir too, so keep the file and that directory private, or use the environment variables instead.

Give the bucket the lowest score, so only data the organizer demotes reaches it (see tiering). The CTE roster in the dashboard lists it as a tier.

If the runtime logs CLIO_ENABLE_AMAZON_DRIVE is not defined. Cannot use S3 bdev., the build lacks the S3 option. Reconfigure with -DCLIO_ENABLE_AMAZON_DRIVE=ON.