Skip to content

Commit

Permalink
fix: avoid overwritten truncated pipeline definitions (#653)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
AndyEfaa authored Jan 18, 2024
1 parent d287bad commit 4273e54
Showing 1 changed file with 10 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -173,13 +173,16 @@ def start_executions(
full_pipeline_name = pipeline.get('name', 'no-pipeline-name')
# AWS Step Functions supports max 80 characters.
# Since the run_id equals 49 characters plus the dash, we have 30
# characters available. To ensure we don't run over, lets use a
# truncated version concatenated with an hash generated from
# the pipeline name
truncated_pipeline_name = full_pipeline_name[:24]
name_bytes_to_hash = bytes(full_pipeline_name + run_id, 'utf-8')
execution_unique_hash = hashlib.md5(name_bytes_to_hash).hexdigest()[:5]
sfn_execution_name = f"{truncated_pipeline_name}-{execution_unique_hash}-{run_id}"
# characters available. To ensure we don't run over in case of 80+
# characters, lets use a truncated version concatenated with an
# hash generated from the pipeline name. If below 80 characters, the
# full_pipeline_name + run_id is used.
sfn_execution_name = f"{full_pipeline_name}-{run_id}"
if len(sfn_execution_name) > 80:
truncated_pipeline_name = full_pipeline_name[:60]
name_bytes_to_hash = bytes(full_pipeline_name, 'utf-8')
execution_unique_hash = hashlib.md5(name_bytes_to_hash).hexdigest()[:5]
sfn_execution_name = f"{truncated_pipeline_name}-{execution_unique_hash}-{run_id}"[:80]
sfn_client.start_execution(
stateMachineArn=PIPELINE_MANAGEMENT_STATEMACHINE,
name=sfn_execution_name,
Expand Down

0 comments on commit 4273e54

Please sign in to comment.