Skip to content
This repository was archived by the owner on Aug 9, 2023. It is now read-only.

Commit 9b68f9c

Browse files
authored
Merge branch 'master' into add_swap_space
2 parents 3bf06f7 + 784d4c5 commit 9b68f9c

File tree

7 files changed

+92
-2
lines changed

7 files changed

+92
-2
lines changed

src/containers/nextflow/nextflow.aws.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ cat ./nextflow.config
5252

5353
# stage in session cache
5454
# .nextflow directory holds all session information for the current and past runs.
55-
# it should be `sync`'d with an s3 uri, so that runs from previous sessions can be
55+
# it should be `sync`'d with an s3 uri, so that runs from previous sessions can be
5656
# resumed
5757
echo "== Restoring Session Cache =="
5858
aws s3 sync --no-progress $NF_LOGSDIR/.nextflow .nextflow

src/ecs-additions/awscli-shim.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/bash
2+
3+
# This shim is for using the AWS ClI v2 with containers that do not have full glibc
4+
# it makes the shared libraries the AWS CLI v2 findable via LD_LIBRARY_PATH
5+
#
6+
# expect to be installed as /opt/aws-cli/bin/aws
7+
# expect to actually call /opt/aws-cli/dist/aws
8+
# expect that /opt/aws-cli is mapped to containers
9+
10+
BIN_DIR=`dirname $0`
11+
DIST_DIR=`dirname $BIN_DIR`/dist
12+
AWS=$DIST_DIR/aws
13+
14+
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$DIST_DIR
15+
16+
$AWS $@
17+

src/ecs-additions/ecs-additions-common.sh

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,16 @@
44
chmod a+x /opt/ecs-additions/fetch_and_run.sh
55
cp /opt/ecs-additions/fetch_and_run.sh /usr/local/bin
66

7+
# add awscli-shim
8+
mv /opt/aws-cli/bin /opt/aws-cli/dist
9+
chmod a+x /opt/ecs-additions/awscli-shim.sh
10+
mkdir /opt/aws-cli/bin
11+
cp /opt/ecs-additions/awscli-shim.sh /opt/aws-cli/bin/aws
12+
713
# add 4GB of swap space
814
dd if=/dev/zero of=/swapfile bs=128M count=32
915
chmod 600 /swapfile
1016
mkswap /swapfile
1117
swapon /swapfile
1218
swapon -s
13-
echo '/swapfile swap swap defaults 0 0' >> /etc/fstab
19+
echo '/swapfile swap swap defaults 0 0' >> /etc/fstab

src/ecs-additions/fetch_and_run.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
# See below for usage instructions.
1717

1818
#PATH="/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin:/usr/local/sbin"
19+
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/aws-cli/v2/current/dist
1920
BASENAME="${0##*/}"
2021
AWS="/usr/local/aws-cli/v2/current/bin/aws"
2122

src/templates/gwfcore/gwfcore-batch.template.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,8 @@ Resources:
128128
Type: MANAGED
129129
State: ENABLED
130130
ComputeResources:
131+
Ec2Configuration:
132+
- ImageType: ECS_AL2
131133
AllocationStrategy: SPOT_CAPACITY_OPTIMIZED
132134
# Set the Spot price to 100% of on-demand price
133135
# This is the maximum price for spot instances that Batch will launch.
@@ -257,6 +259,12 @@ Resources:
257259
- Order: 2
258260
ComputeEnvironment: !Ref OnDemandComputeEnv
259261

262+
ContainerInstanceLogGroup:
263+
Type: AWS::Logs::LogGroup
264+
Properties:
265+
LogGroupName: !Sub "/aws/ecs/container-instance/${Namespace}"
266+
RetentionInDays: 7
267+
260268
Outputs:
261269
DefaultJobQueueArn:
262270
Value: !Ref DefaultQueue

src/templates/gwfcore/gwfcore-iam.template.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ Resources:
129129
- "arn:aws:iam::aws:policy/service-role/AmazonEC2ContainerServiceforEC2Role"
130130
- "arn:aws:iam::aws:policy/AmazonS3ReadOnlyAccess"
131131
- "arn:aws:iam::aws:policy/AmazonSSMManagedInstanceCore"
132+
- "arn:aws:iam::aws:policy/CloudWatchAgentServerPolicy"
132133
BatchInstanceProfile:
133134
Type: AWS::IAM::InstanceProfile
134135
Properties:

src/templates/gwfcore/gwfcore-launch-template.template.yaml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,15 +94,72 @@ Resources:
9494
--==BOUNDARY==
9595
Content-Type: text/cloud-config; charset="us-ascii"
9696

97+
#cloud-config
98+
repo_update: true
99+
repo_upgrade: security
100+
97101
packages:
98102
- jq
99103
- btrfs-progs
100104
- sed
101105
- git
102106
- amazon-ssm-agent
103107
- unzip
108+
- amazon-cloudwatch-agent
109+
110+
write_files:
111+
- permissions: '0644'
112+
path: /opt/aws/amazon-cloudwatch-agent/etc/config.json
113+
content: |
114+
{
115+
"agent": {
116+
"logfile": "/opt/aws/amazon-cloudwatch-agent/logs/amazon-cloudwatch-agent.log"
117+
},
118+
"logs": {
119+
"logs_collected": {
120+
"files": {
121+
"collect_list": [
122+
{
123+
"file_path": "/opt/aws/amazon-cloudwatch-agent/logs/amazon-cloudwatch-agent.log",
124+
"log_group_name": "/aws/ecs/container-instance/${Namespace}",
125+
"log_stream_name": "/aws/ecs/container-instance/${Namespace}/{instance_id}/amazon-cloudwatch-agent.log"
126+
},
127+
{
128+
"file_path": "/var/log/cloud-init.log",
129+
"log_group_name": "/aws/ecs/container-instance/${Namespace}",
130+
"log_stream_name": "/aws/ecs/container-instance/${Namespace}/{instance_id}/cloud-init.log"
131+
},
132+
{
133+
"file_path": "/var/log/cloud-init-output.log",
134+
"log_group_name": "/aws/ecs/container-instance/${Namespace}",
135+
"log_stream_name": "/aws/ecs/container-instance/${Namespace}/{instance_id}/cloud-init-output.log"
136+
},
137+
{
138+
"file_path": "/var/log/ecs/ecs-init.log",
139+
"log_group_name": "/aws/ecs/container-instance/${Namespace}",
140+
"log_stream_name": "/aws/ecs/container-instance/${Namespace}/{instance_id}/ecs-init.log"
141+
},
142+
{
143+
"file_path": "/var/log/ecs/ecs-agent.log",
144+
"log_group_name": "/aws/ecs/container-instance/${Namespace}",
145+
"log_stream_name": "/aws/ecs/container-instance/${Namespace}/{instance_id}/ecs-agent.log"
146+
},
147+
{
148+
"file_path": "/var/log/ecs/ecs-volume-plugin.log",
149+
"log_group_name": "/aws/ecs/container-instance/${Namespace}",
150+
"log_stream_name": "/aws/ecs/container-instance/${Namespace}/{instance_id}/ecs-volume-plugin.log"
151+
}
152+
]
153+
}
154+
}
155+
}
156+
}
104157
105158
runcmd:
159+
160+
# start the amazon-cloudwatch-agent
161+
- /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a fetch-config -m ec2 -s -c file:/opt/aws/amazon-cloudwatch-agent/etc/config.json
162+
106163
# install aws-cli v2 and copy the static binary in an easy to find location for bind-mounts into containers
107164
- curl -s "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "/tmp/awscliv2.zip"
108165
- unzip -q /tmp/awscliv2.zip -d /tmp

0 commit comments

Comments
 (0)