X Tutup
Skip to content

Add job_name argument to cron wrapper script#11589

Merged
mekarpeles merged 2 commits intointernetarchive:masterfrom
jimchamp:fix-cron-wrapper-script
Dec 12, 2025
Merged

Add job_name argument to cron wrapper script#11589
mekarpeles merged 2 commits intointernetarchive:masterfrom
jimchamp:fix-cron-wrapper-script

Conversation

@jimchamp
Copy link
Collaborator

@jimchamp jimchamp commented Dec 12, 2025

Updates cron_wrapper script to accept a new job_name argument. Removes method that derives job name from the wrapped script's path.

Special Deployment Procedures

The new argument is required, so our cron file will need to be updated before this is deployed.

Technical

Testing

Screenshot

Stakeholders

Copilot AI review requested due to automatic review settings December 12, 2025 18:31
@jimchamp jimchamp added the Needs: Special Deploy This PR will need a non-standard deploy to production label Dec 12, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR refactors the cron_wrapper.py script to accept an explicit job_name argument instead of deriving it from the wrapped script's path. This change provides more flexibility in naming monitored jobs independently of their file paths, but introduces a breaking change to the CLI interface.

Key Changes

  • Adds job_name as a required positional argument to the CLI
  • Removes the _get_job_name() method that parsed job names from script paths
  • Updates MonitoredJob.__init__() to accept job_name as a parameter

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +99 to 101
_parser.add_argument("job_name", help="Name of the job to be monitored")
_parser.add_argument(
"script", help="Path to script that will be wrapped and monitored"
Copy link

Copilot AI Dec 12, 2025

Choose a reason for hiding this comment

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

Adding a positional argument before the existing 'script' argument creates a breaking change to the CLI interface. All existing cron jobs calling this wrapper will need to be updated to include the job_name argument. Consider making this an optional flag (e.g., '--job-name') or adding it after 'script' to minimize impact, or ensure all call sites are updated simultaneously.

Copilot uses AI. Check for mistakes.
)
self._setup_sentry(sentry_cfg.get("dsn", ""))
self.job_name = self._get_job_name()
self.job_name = job_name
Copy link

Copilot AI Dec 12, 2025

Choose a reason for hiding this comment

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

The job_name parameter should be validated to ensure it doesn't contain characters that would be problematic for StatsD metric names (e.g., dots are used as metric delimiters, spaces could cause issues). The job_name is used directly in metric names like 'cron.{self.job_name}.start', so invalid characters could lead to metric reporting issues.

Copilot uses AI. Check for mistakes.
sentry_cfg = dict(config["sentry"]) if config.has_section("sentry") else None
statsd_cfg = dict(config["statsd"]) if config.has_section("statsd") else None
command = [args.script] + args.script_args
job_name = args.job_name
Copy link

Copilot AI Dec 12, 2025

Choose a reason for hiding this comment

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

This intermediate variable assignment is unnecessary. The value can be passed directly to MonitoredJob on line 79 as 'args.job_name', which would be more concise and consistent with how 'command' is constructed on the previous line.

Copilot uses AI. Check for mistakes.
@mekarpeles mekarpeles merged commit 257468f into internetarchive:master Dec 12, 2025
4 checks passed
@jimchamp jimchamp deleted the fix-cron-wrapper-script branch December 12, 2025 19:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Needs: Special Deploy This PR will need a non-standard deploy to production

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

X Tutup