Skip to content

Commit 4273e54

Browse files
authored
fix: avoid overwritten truncated pipeline definitions (#653)
* fix: avoid overwritten truncated pipeline definitions * fix: typo * fix: refactor truncation method based on feedback * Update process_deployment_map.py Fix trailing space * Update src/lambda_codebase/initial_commit/bootstrap_repository/adf-bootstrap/deployment/lambda_codebase/pipeline_management/process_deployment_map.py Co-authored-by: Stewart Wallace * fix: consider comment execution_unique_hash --------- Co-authored-by: Andreas Falkenberg Co-authored-by: Stewart Wallace Co-authored-by: Simon Kok
1 parent d287bad commit 4273e54

1 file changed

Lines changed: 10 additions & 7 deletions

File tree

  • src/lambda_codebase/initial_commit/bootstrap_repository/adf-bootstrap/deployment/lambda_codebase/pipeline_management

src/lambda_codebase/initial_commit/bootstrap_repository/adf-bootstrap/deployment/lambda_codebase/pipeline_management/process_deployment_map.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -173,13 +173,16 @@ def start_executions(
173173
full_pipeline_name = pipeline.get('name', 'no-pipeline-name')
174174
# AWS Step Functions supports max 80 characters.
175175
# Since the run_id equals 49 characters plus the dash, we have 30
176-
# characters available. To ensure we don't run over, lets use a
177-
# truncated version concatenated with an hash generated from
178-
# the pipeline name
179-
truncated_pipeline_name = full_pipeline_name[:24]
180-
name_bytes_to_hash = bytes(full_pipeline_name + run_id, 'utf-8')
181-
execution_unique_hash = hashlib.md5(name_bytes_to_hash).hexdigest()[:5]
182-
sfn_execution_name = f"{truncated_pipeline_name}-{execution_unique_hash}-{run_id}"
176+
# characters available. To ensure we don't run over in case of 80+
177+
# characters, lets use a truncated version concatenated with an
178+
# hash generated from the pipeline name. If below 80 characters, the
179+
# full_pipeline_name + run_id is used.
180+
sfn_execution_name = f"{full_pipeline_name}-{run_id}"
181+
if len(sfn_execution_name) > 80:
182+
truncated_pipeline_name = full_pipeline_name[:60]
183+
name_bytes_to_hash = bytes(full_pipeline_name, 'utf-8')
184+
execution_unique_hash = hashlib.md5(name_bytes_to_hash).hexdigest()[:5]
185+
sfn_execution_name = f"{truncated_pipeline_name}-{execution_unique_hash}-{run_id}"[:80]
183186
sfn_client.start_execution(
184187
stateMachineArn=PIPELINE_MANAGEMENT_STATEMACHINE,
185188
name=sfn_execution_name,

0 commit comments

Comments
 (0)