Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Issue] Improve cron error logging #37453

Open
3 of 4 tasks
m2-assistant bot opened this issue May 3, 2023 · 2 comments · May be fixed by #32690
Open
3 of 4 tasks

[Issue] Improve cron error logging #37453

m2-assistant bot opened this issue May 3, 2023 · 2 comments · May be fixed by #32690
Assignees
Labels
Area: Framework Component: Cron Component: Shell Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Priority: P3 May be fixed according to the position in the backlog. Progress: PR in progress Reported on 2.4.x Indicates original Magento version for the Issue report. Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch

Comments

@m2-assistant
Copy link

m2-assistant bot commented May 3, 2023

This issue is automatically created based on existing pull request: #32690: Improve cron error logging


Description (*)

This pull request improves logging of errors within cron processes.

Current scenario
Currently any error messages are lost / not recorded. For the main group (and any groups not set to use a separate process), STDERR is left for the scheduler to capture. This is most easily caught with the MAILTO= directive on unix, however experience suggests this is rarely configured usefully. Any cron group currently configured to run in a separate process will have its STDOUT and STDERR lost forever.

Proposed scenario
With the changes here, both STDERR and STDOUT are caught and logged. This is very valuable in scenarios where one cannot configure the scheduler, or when a job running in a separate process is suffering from errors. A good example of this is Magento Cloud hosting where cron processes often fail without any useful diagnostic information available. These changes will mean that STDERR output is readily available, aiding in diagnostics.

Related Pull Requests

Fixed Issues (if relevant)

None

Manual testing scenarios (*)

  1. Artificially introduce a memory leak into a cron job, eg indexer_reindex_all_invalid
  2. Run php bin/magento cron:run without these changes
  3. Observe lack of information about the failure
  4. Run php bin/magento cron:run with these changes
  5. Observe information available in var/log (in this example, var/log/magento.cron.index.log)

Questions or comments

I can see that using posix_isatty() is discouraged, but no alternative is provided / suggested. There are functions in packages installed via composer as development dependencies which provide the required functionality. (eg here and here) What's the recommended approach in this case? Do we simply remove the output line altogether?

Contribution checklist (*)

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All new or changed code is covered with unit/integration tests (if applicable)
  • All automated tests passed successfully (all builds are green)
@m2-assistant m2-assistant bot added Component: Cron Component: Shell Priority: P3 May be fixed according to the position in the backlog. labels May 3, 2023
@m2-assistant m2-assistant bot linked a pull request May 3, 2023 that will close this issue
5 tasks
@m2-community-project m2-community-project bot added this to Pull Request In Progress in Low Priority Backlog May 3, 2023
@engcom-Lima engcom-Lima added Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch Reported on 2.4.x Indicates original Magento version for the Issue report. Area: Framework labels May 3, 2023
@github-jira-sync-bot
Copy link

✅ Jira issue https://jira.corp.adobe.com/browse/AC-8662 is successfully created for this GitHub issue.

@m2-assistant
Copy link
Author

m2-assistant bot commented May 3, 2023

✅ Confirmed by @engcom-Lima. Thank you for verifying the issue.
Issue Available: @engcom-Lima, You will be automatically unassigned. Contributors/Maintainers can claim this issue to continue. To reclaim and continue work, reassign the ticket to yourself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Framework Component: Cron Component: Shell Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Priority: P3 May be fixed according to the position in the backlog. Progress: PR in progress Reported on 2.4.x Indicates original Magento version for the Issue report. Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch
Projects
Low Priority Backlog
  
Pull Request In Progress
Development

Successfully merging a pull request may close this issue.

3 participants