Skip to content

fix: propagate job tags to ECS tasks so cost allocation reaches compute#46

Open
nh13 wants to merge 1 commit into
snakemake:mainfrom
nh13:nh_propagate-tags
Open

fix: propagate job tags to ECS tasks so cost allocation reaches compute#46
nh13 wants to merge 1 commit into
snakemake:mainfrom
nh13:nh_propagate-tags

Conversation

@nh13

@nh13 nh13 commented Jun 24, 2026

Copy link
Copy Markdown
Collaborator

Without propagateTags=True on submit_job, tags on the Batch job object never reach the underlying ECS task, so Cost Explorer attribution by project/run tags misses the actual EC2/ECS spend. Set propagateTags alongside tags whenever the merged tag set is non-empty (completes the per-job-tags feature from #40). Also notes in the tags help text that ecs:TagResource may be required on the executor role depending on account ECS tagging-authorization settings.

Test Plan

  • 3 new assertions in TestSubmitTagPropagation: propagateTags=True when settings tags present, when env-var tags only, and absent when there are no tags
  • Builder suite green; black + flake8 clean

Merge-order note

This adds a kwarg to submit(), which #44 (pre-existing job definitions) also touches — #44 introduces a separate pre-existing submit path. Whichever of #44 / this lands second needs a trivial rebase, and once both are merged propagateTags must also be mirrored into #44's pre-existing path. I'll handle that reconciliation on the second-to-merge branch.

Summary by CodeRabbit

  • New Features
    • AWS Batch job tags now automatically propagate to the underlying ECS task during submissions, improving cost attribution and tag visibility.
  • Bug Fixes
    • Tag propagation is applied consistently for both dynamic and pre-existing job-definition submission flows whenever tags are provided.
  • Documentation
    • Updated job tag documentation and CLI help to describe propagation behavior and note that executor permissions (for ECS tagging) may be required.
  • Tests
    • Added unit tests verifying propagateTags is set when tags exist and omitted when no tags are configured.

@coderabbitai

coderabbitai Bot commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@nh13, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 50 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 8fb97171-0301-4382-bfe0-956ccc9aa572

📥 Commits

Reviewing files that changed from the base of the PR and between 8f8206a and a337b47.

📒 Files selected for processing (4)
  • docs/further.md
  • snakemake_executor_plugin_aws_batch/__init__.py
  • snakemake_executor_plugin_aws_batch/batch_job_builder.py
  • tests/test_batch_job_builder.py
📝 Walkthrough

Walkthrough

The PR updates AWS Batch submissions to set propagateTags=True when tags are present, adds coverage for both submission paths, and documents ECS task propagation and required tagging permissions.

Changes

AWS Batch tag propagation

Layer / File(s) Summary
Submit tags with propagation
snakemake_executor_plugin_aws_batch/batch_job_builder.py
Dynamic and pre-existing job-definition submissions include propagateTags=True when tags are configured.
Validation and documentation
tests/test_batch_job_builder.py, snakemake_executor_plugin_aws_batch/__init__.py, docs/further.md
Tests cover tagged and untagged submissions, while help text and documentation describe ECS propagation and the possible ecs:TagResource requirement.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

Suggested reviewers: cademirch

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: propagating job tags to ECS tasks to support cost allocation.
Docstring Coverage ✅ Passed Docstring coverage is 85.71% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@nh13
nh13 requested a review from cademirch June 24, 2026 18:45
@nh13

nh13 commented Jun 24, 2026

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@nh13
nh13 enabled auto-merge (squash) June 24, 2026 21:59
@coderabbitai

coderabbitai Bot commented Jun 24, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@cademirch

Copy link
Copy Markdown

hi @nh13, could you resolve the conflicts in the docs?

@nh13
nh13 force-pushed the nh_propagate-tags branch from 2c1fd52 to 8f8206a Compare July 15, 2026 22:30

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@tests/test_batch_job_builder.py`:
- Around line 273-283: Update test_propagate_tags_absent_when_no_tags and the
corresponding test near the alternate line range to assert that “propagateTags”
is not present in submit_job call_args kwargs, rather than checking
kwargs.get("propagateTags") is None. Use direct key-presence validation so an
explicitly supplied None value fails the tests.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: d79f43a5-5756-43e8-9a4e-3e6ffcfac0c4

📥 Commits

Reviewing files that changed from the base of the PR and between 2c1fd52 and 8f8206a.

📒 Files selected for processing (4)
  • docs/further.md
  • snakemake_executor_plugin_aws_batch/__init__.py
  • snakemake_executor_plugin_aws_batch/batch_job_builder.py
  • tests/test_batch_job_builder.py
🚧 Files skipped from review as they are similar to previous changes (3)
  • snakemake_executor_plugin_aws_batch/batch_job_builder.py
  • docs/further.md
  • snakemake_executor_plugin_aws_batch/init.py

Comment thread tests/test_batch_job_builder.py Outdated
Without propagateTags=True on submit_job, tags on the Batch job object never
reach the underlying ECS task, so Cost Explorer attribution by project/run tags
misses the actual EC2/ECS spend. Set propagateTags alongside tags whenever the
merged tag set is non-empty. Also note in the tags setting help text that
ecs:TagResource may be required depending on account tagging-authorization
settings.
@nh13
nh13 force-pushed the nh_propagate-tags branch from 8f8206a to a337b47 Compare July 15, 2026 22:40
@nh13

nh13 commented Jul 16, 2026

Copy link
Copy Markdown
Collaborator Author

@cademirch done!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants