Skip to content

Commit 1810093

Browse files
Replace Goofys with mountpoint-s3 for S3 mounting (#417)
* Replace Goofys with mountpoint-s3 for S3 mounting This update replaces the Goofys S3 filesystem with mountpoint-s3 throughout the codebase, including Dockerfile, shell scripts, and utility functions. The decode_run_json and create_mount_command_list functions now support AWS region and KMS key ARN for encrypted mounts. Tests and documentation have been updated accordingly. Version bumped to 5.6.0. * Update top.py * Bump version
1 parent f4039a5 commit 1810093

File tree

9 files changed

+50
-23
lines changed

9 files changed

+50
-23
lines changed

CHANGELOG.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@
33
Change Log
44
==========
55

6+
6.0.0
7+
=====
8+
9+
* Replace Goofys with mountpoint-s3 (https://github.com/awslabs/mountpoint-s3)
10+
11+
612
5.5.3
713
=====
814

awsf3-docker/Dockerfile

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,22 @@ RUN ARCH="$(dpkg --print-architecture)" && \
5757
apt install -y ./singularity-ce_${SINGULARITY_VERSION}-focal_${ARCH}.deb && \
5858
rm singularity-ce_${SINGULARITY_VERSION}-focal_${ARCH}.deb
5959

60-
# goofys
61-
# RUN wget https://github.com/kahing/goofys/releases/download/v0.24.0/goofys && chmod +x goofys
62-
RUN ARCH="$(dpkg --print-architecture)" && \
63-
wget https://tibanna-dependencies.s3.amazonaws.com/goofys/v0.24.0/${ARCH}/goofys && chmod +x goofys
60+
# mountpoint-s3
61+
RUN set -eux; \
62+
ARCH="$(dpkg --print-architecture)"; \
63+
if [ "$ARCH" = "amd64" ]; then \
64+
DEB_URL="https://s3.amazonaws.com/mountpoint-s3-release/latest/x86_64/mount-s3.deb"; \
65+
elif [ "$ARCH" = "arm64" ]; then \
66+
DEB_URL="https://s3.amazonaws.com/mountpoint-s3-release/latest/arm64/mount-s3.deb"; \
67+
else \
68+
echo "Unsupported architecture: $ARCH" >&2; \
69+
exit 1; \
70+
fi; \
71+
wget "$DEB_URL"; \
72+
apt-get update; \
73+
apt-get install -y ./mount-s3.deb; \
74+
rm -f ./mount-s3.deb
75+
6476

6577
# python packages
6678
RUN pip install boto3==1.15 awscli==1.18.152 botocore==1.18.11

awsf3-docker/run.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ exl echo "## cwltool version $(cwltool --version | cut -f2 -d' ')"
150150
exl echo "## cromwell version $(java -jar /usr/local/bin/cromwell-35.jar --version | cut -f2 -d ' ') for WDL draft2"
151151
exl echo "## cromwell version $(java -jar /usr/local/bin/cromwell.jar --version | cut -f2 -d ' ') for WDL v1.0"
152152
exl echo "## $(singularity --version)"
153-
exl echo "## $(goofys --version 2>&1)"
153+
exl echo "## $(mount-s3 --version)"
154154

155155

156156
# getting run.json file
@@ -163,7 +163,7 @@ if [ -z "$S3_ENCRYPT_KEY_ID" ];
163163
then
164164
exl awsf3 decode_run_json -i $RUN_JSON_FILE_NAME
165165
else
166-
exl awsf3 decode_run_json -i $RUN_JSON_FILE_NAME -k $S3_ENCRYPT_KEY_ID
166+
exl awsf3 decode_run_json -i $RUN_JSON_FILE_NAME -k $S3_ENCRYPT_KEY_ID -r $INSTANCE_REGION
167167
fi
168168

169169

awsf3/__main__.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ def args(self):
3333
return {
3434
'decode_run_json':
3535
[{'flag': ["-i", "--input-run-json"], 'help': "input run json file"},
36-
{'flag': ["-k", "--kms-key-id"], 'help': "kms-key-id to use for encrypting s3 files"}],
36+
{'flag': ["-k", "--kms-key-id"], 'help': "kms-key-id to use for encrypting s3 files"},
37+
{'flag': ["-r", "--region"], 'help': "AWS region"}],
3738
'download_workflow':
3839
[],
3940
'update_postrun_json_init':
@@ -56,8 +57,8 @@ def args(self):
5657
}
5758

5859

59-
def decode_run_json(input_run_json, kms_key_id=None):
60-
utils.decode_run_json(input_run_json, kms_key_id=kms_key_id)
60+
def decode_run_json(input_run_json, kms_key_id=None, region=None):
61+
utils.decode_run_json(input_run_json, kms_key_id=kms_key_id, region=region)
6162

6263

6364
def download_workflow():

awsf3/utils.py

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
INPUT_MOUNT_DIR_PREFIX = "/data1/input-mounted-" # data are mounted to this directory + bucket name
2727

2828

29-
def decode_run_json(input_json_file, kms_key_id=None):
29+
def decode_run_json(input_json_file, kms_key_id=None, region=None):
3030
"""reads a run json file and creates three text files:
3131
download command list file (commands to download input files from s3)
3232
input yml file (for cwl/wdl/snakemake run)
@@ -42,7 +42,7 @@ def decode_run_json(input_json_file, kms_key_id=None):
4242
create_download_command_list(downloadlist_filename, runjson_input)
4343

4444
# create a bucket-mounting command list file
45-
create_mount_command_list(mountlist_filename, runjson_input, kms_key_id=kms_key_id)
45+
create_mount_command_list(mountlist_filename, runjson_input, kms_key_id=kms_key_id, region=region)
4646

4747
# create an input yml file to be used on awsem
4848
if language in ['wdl', 'wdl_v1', 'wdl_draft2']: # wdl
@@ -57,24 +57,31 @@ def decode_run_json(input_json_file, kms_key_id=None):
5757

5858

5959
def create_mount_command_list(mountlist_filename, runjson_input,
60-
kms_key_id=None):
61-
""" This function creates a mount point directory and starts goofys
60+
kms_key_id=None, region=None):
61+
""" This function creates a mount point directory and starts mountpoint-s3
6262
with some default arguments.
6363
Note that KMS key arguments are needed for the mount if encryption
6464
is enabled.
6565
"""
66+
key_arn = None
67+
if kms_key_id and region:
68+
kms = boto3.client("kms", region_name=region)
69+
response = kms.describe_key(KeyId=kms_key_id)
70+
key_arn = response["KeyMetadata"]["Arn"]
71+
6672
buckets_to_be_mounted = set()
6773
for category in ["Input_files_data", "Secondary_files_data"]:
6874
for inkey, v in getattr(runjson_input, category).items():
6975
if v.mount:
7076
buckets_to_be_mounted.add(v.dir_)
7177
with open(mountlist_filename, 'w') as f:
72-
for b in sorted(buckets_to_be_mounted):
73-
f.write("mkdir -p %s\n" % (INPUT_MOUNT_DIR_PREFIX + b))
74-
if kms_key_id:
75-
f.write("goofys --sse-kms %s -f %s %s &\n" % (kms_key_id, b, INPUT_MOUNT_DIR_PREFIX + b))
78+
for bucket in sorted(buckets_to_be_mounted):
79+
path_to_mount = INPUT_MOUNT_DIR_PREFIX + bucket
80+
f.write(f"mkdir -p {path_to_mount}\n")
81+
if key_arn:
82+
f.write(f"mount-s3 {bucket} {path_to_mount} --sse aws:kms --sse-kms-key-id {key_arn} &\n")
7683
else:
77-
f.write("goofys -f %s %s &\n" % (b, INPUT_MOUNT_DIR_PREFIX + b))
84+
f.write(f"mount-s3 {bucket} {path_to_mount} &\n")
7885

7986

8087
def create_download_command_list(downloadlist_filename, runjson_input):

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "tibanna"
3-
version = "5.5.3"
3+
version = "6.0.0"
44
description = "Tibanna runs portable pipelines (in CWL/WDL) on the AWS Cloud."
55
authors = ["4DN-DCIC Team <support@4dnucleome.org>"]
66
license = "MIT"

tests/awsf3/postrunjson/GBPtlqb2rFGH.postrun.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@
169169
"behavior_on_capacity_limit": "wait_and_retry",
170170
"cloudwatch_dashboard": false,
171171
"cpu": "",
172+
"disable_metrics_collection": false,
172173
"ebs_iops": "",
173174
"ebs_size": 45,
174175
"ebs_size_as_is": false,

tests/awsf3/test_utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -297,9 +297,9 @@ def test_create_mount_command_list():
297297
mcfile_content = f.read()
298298

299299
right_content = ('mkdir -p /data1/input-mounted-somebucket\n'
300-
'goofys -f somebucket /data1/input-mounted-somebucket &\n'
300+
'mount-s3 somebucket /data1/input-mounted-somebucket &\n'
301301
'mkdir -p /data1/input-mounted-somebucket2\n'
302-
'goofys -f somebucket2 /data1/input-mounted-somebucket2 &\n')
302+
'mount-s3 somebucket2 /data1/input-mounted-somebucket2 &\n')
303303

304304
assert mcfile_content == right_content
305305
os.remove(mountcommand_filename)

tibanna/top.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ class Top(object):
6666
# These commands are excluded when parsing the top output
6767
# Currently only 1-, 2- or 3-word prefixes work.
6868
exclude_list = ['top', 'docker', 'dockerd', '/usr/bin/dockerd', 'cron',
69-
'docker-untar', 'containerd', 'goofys-latest', 'cwltool',
70-
'/usr/bin/containerd-shim-runc-v2', 'goofys', 'nodejs --eval',
69+
'docker-untar', 'containerd', 'mount-s3', 'cwltool',
70+
'/usr/bin/containerd-shim-runc-v2', 'nodejs --eval',
7171
'/usr/bin/python3 /usr/local/bin/cwltool', 'containerd-shim',
7272
'/usr/bin/python3 /bin/unattended-upgrade',
7373
'/usr/bin/python3 /usr/local/bin/awsf3',

0 commit comments

Comments
 (0)