Skip to content

Commit 490ffdd

Browse files
committed
Allow to ignore stages executions
1 parent b9a4ce7 commit 490ffdd

File tree

9 files changed

+207
-82
lines changed

9 files changed

+207
-82
lines changed

.cicd/buildspec.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,11 @@ phases:
9898
--amend ${PUBLIC_REGISTRY}/ecs-files-composer:${VERSION}-x86_64 \
9999
--amend ${PUBLIC_REGISTRY}/ecs-files-composer:${VERSION}-aarch64;
100100
docker manifest push ${PUBLIC_REGISTRY}/ecs-files-composer:latest;
101+
else
102+
docker manifest create ${PUBLIC_REGISTRY}/ecs-files-composer:nightly \
103+
--amend ${PUBLIC_REGISTRY}/ecs-files-composer:${VERSION}-x86_64 \
104+
--amend ${PUBLIC_REGISTRY}/ecs-files-composer:${VERSION}-aarch64;
105+
docker manifest push ${PUBLIC_REGISTRY}/ecs-files-composer:nightly;
101106
fi
102107
103108
finally:

docker-compose.override.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ services:
2424
ECS_CONTAINER_METADATA_URI: http://169.254.170.2/v3/containers/files-sidecar
2525
AWS_DEFAULT_REGION: ${AWS_DEFAULT_REGION:-eu-west-1}
2626
context: plain
27+
LOGLEVEL: debug
2728
ECS_CONFIG_CONTENT: |
2829
2930
files:
@@ -34,6 +35,7 @@ services:
3435
group: root
3536
mode: 600
3637
/opt/files/aws.template:
38+
ignore_failure: true
3739
source:
3840
S3:
3941
BucketName: ${BUCKET_NAME:-sacrificial-lamb}

docker-compose.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,8 @@ services:
1313
image: public.ecr.aws/compose-x/ecs-files-composer:latest
1414
deploy:
1515
resources:
16-
# Smallest RAM size for a lambda
1716
limits:
18-
cpus: 0.1
17+
cpus: "0.1"
1918
memory: 128M
2019
build:
2120
context: ./

ecs-files-input.json

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,13 +96,43 @@
9696
],
9797
"default": "plain"
9898
},
99-
"ignore_if_failed": {
100-
"type": "boolean",
101-
"description": "Whether or not the failure to retrieve the file should stop the execution",
102-
"default": false
99+
"ignore_failure": {
100+
"oneOf": [
101+
{
102+
"type": "object",
103+
"additionalProperties": false,
104+
"properties": {
105+
"commands": {
106+
"type": "boolean",
107+
"default": false,
108+
"description": "Ignore if any of the commands failed"
109+
},
110+
"mode": {
111+
"type": "boolean",
112+
"default": false,
113+
"description": "Ignore if `mode` (using chmod) failed."
114+
},
115+
"owner": {
116+
"type": "boolean",
117+
"default": false,
118+
"description": "Ignore if `owner` (using chown) failed"
119+
},
120+
"source_download": {
121+
"type": "boolean",
122+
"default": false,
123+
"description": "Ignore if a Source download failed. Any subsequent action is cancelled."
124+
}
125+
}
126+
},
127+
{
128+
"type": "boolean",
129+
"description": "Ignore if any step fails (download, transform, commands etc.)"
130+
}
131+
]
103132
},
104133
"commands": {
105134
"type": "object",
135+
"additionalProperties": false,
106136
"properties": {
107137
"post": {
108138
"$ref": "#/definitions/CommandsDef",

ecs_files_composer/ecs_files_composer.py

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,21 @@
55

66
from __future__ import annotations
77

8+
import os
89
from typing import TYPE_CHECKING
910

1011
if TYPE_CHECKING:
1112
from .input import Model
1213

1314
import json
14-
import uuid
1515
from os import environ, path
1616
from tempfile import TemporaryDirectory
1717

1818
import yaml
19-
from compose_x_common.compose_x_common import keyisset
2019
from yaml import Loader
2120

2221
from ecs_files_composer import input
23-
from ecs_files_composer.aws_mgmt import S3Fetcher, SecretFetcher, SsmFetcher
22+
from ecs_files_composer.aws_mgmt import S3Fetcher
2423
from ecs_files_composer.certbot_aws_store import handle_certbot_store_certificates
2524
from ecs_files_composer.certificates_mgmt import process_x509_certs
2625
from ecs_files_composer.common import LOG
@@ -110,18 +109,22 @@ def init_config(
110109
if context:
111110
initial_config["context"] = context
112111
start_jobs(jobs_input_def)
113-
with open(config_path) as config_fd:
114-
try:
115-
config = yaml.load(config_fd.read(), Loader=Loader)
116-
LOG.info(f"Successfully loaded YAML config {config_path}")
117-
return config
118-
except yaml.YAMLError:
119-
config = json.loads(config_fd.read())
120-
LOG.info(f"Successfully loaded JSON config {config_path}")
121-
return config
122-
except Exception:
123-
LOG.error("Input content is neither JSON nor YAML formatted")
124-
raise
112+
try:
113+
with open(config_path) as config_fd:
114+
try:
115+
config = yaml.load(config_fd.read(), Loader=Loader)
116+
LOG.info(f"Successfully loaded YAML config {config_path}")
117+
return config
118+
except yaml.YAMLError:
119+
config = json.loads(config_fd.read())
120+
LOG.info(f"Successfully loaded JSON config {config_path}")
121+
return config
122+
except Exception:
123+
LOG.error("Input content is neither JSON nor YAML formatted")
124+
raise
125+
except OSError as error:
126+
LOG.exception(error)
127+
LOG.error(f"Failed to read input file from {config_path}")
125128

126129

127130
def process_files(job: Model, override_session=None) -> None:

0 commit comments

Comments
 (0)