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

Improve cron error logging #32690

Open
wants to merge 38 commits into
base: 2.4-develop
Choose a base branch
from
Open

Conversation

fredden
Copy link
Member

@fredden fredden commented Apr 7, 2021

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)

Resolved issues:

  1. resolves [Issue] Improve cron error logging #37453: Improve cron error logging

@m2-assistant
Copy link

m2-assistant bot commented Apr 7, 2021

Hi @fredden. Thank you for your contribution
Here are some useful tips how you can test your changes using Magento test environment.
Add the comment under your pull request to deploy test or vanilla Magento instance:

  • @magento give me test instance - deploy test instance based on PR changes
  • @magento give me 2.4-develop instance - deploy vanilla Magento instance

❗ Automated tests can be triggered manually with an appropriate comment:

  • @magento run all tests - run or re-run all required tests against the PR changes
  • @magento run <test-build(s)> - run or re-run specific test build(s)
    For example: @magento run Unit Tests

<test-build(s)> is a comma-separated list of build names. Allowed build names are:

  1. Database Compare
  2. Functional Tests CE
  3. Functional Tests EE,
  4. Functional Tests B2B
  5. Integration Tests
  6. Magento Health Index
  7. Sample Data Tests CE
  8. Sample Data Tests EE
  9. Sample Data Tests B2B
  10. Static Tests
  11. Unit Tests
  12. WebAPI Tests
  13. Semantic Version Checker

You can find more information about the builds here

ℹ️ Please run only needed test builds instead of all when developing. Please run all test builds before sending your PR for review.

For more details, please, review the Magento Contributor Guide documentation.

⚠️ According to the Magento Contribution requirements, all Pull Requests must go through the Community Contributions Triage process. Community Contributions Triage is a public meeting.

🕙 You can find the schedule on the Magento Community Calendar page.

📞 The triage of Pull Requests happens in the queue order. If you want to speed up the delivery of your contribution, please join the Community Contributions Triage session to discuss the appropriate ticket.

🎥 You can find the recording of the previous Community Contributions Triage on the Magento Youtube Channel

✏️ Feel free to post questions/proposals/feedback related to the Community Contributions Triage process to the corresponding Slack Channel

@gabrieldagama gabrieldagama added the Priority: P3 May be fixed according to the position in the backlog. label Apr 21, 2021
@m2-community-project m2-community-project bot added this to Pending Review in Pull Requests Dashboard Apr 21, 2021
@magento-automated-testing
Copy link

The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time.

@magento-automated-testing
Copy link

The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time.

@magento-automated-testing
Copy link

The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time.

@magento-automated-testing
Copy link

The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time.

@evktalo
Copy link
Contributor

evktalo commented Feb 14, 2023

I can confirm this issue has caused a problem with monitoring for one of our clients.

@fredden
Copy link
Member Author

fredden commented Feb 14, 2023

I can confirm this issue has caused a problem with monitoring for one of our clients.

@evktalo I'm having a little trouble interpreting your statement. Are you saying that (1) you have applied the changes in this pull request to a website and these have caused a problem somehow? Or, are you saying that (2) you have witnessed the issue that this pull request aims to solve?

@magento-automated-testing
Copy link

The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time.

@sinhaparul sinhaparul added the Project: Community Picked PRs upvoted by the community label Mar 4, 2023
@m2-community-project m2-community-project bot added this to Pending Review in Community Dashboard Mar 4, 2023
@engcom-Charlie
Copy link
Contributor

@magento run all tests

@engcom-Charlie engcom-Charlie moved this from Ready for Testing to Testing in Progress in Community Dashboard Mar 7, 2024
@engcom-Charlie
Copy link
Contributor

engcom-Charlie commented Mar 7, 2024

As this PR has been moved from Extended Testing to On hold, now moving back it to Extended Testing. It seems that bot moved it to Testing.

@engcom-Charlie engcom-Charlie moved this from Testing in Progress to Extended testing (optional) in Community Dashboard Mar 7, 2024
@engcom-Charlie
Copy link
Contributor

@magento run all tests

@engcom-Charlie
Copy link
Contributor

As mentioned here, SVC PR is also got merged.

@engcom-Charlie
Copy link
Contributor

@magento run Functional Tests B2B, Functional Tests CE, Functional Tests EE, Semantic Version Checker, WebAPI Tests

@engcom-Charlie
Copy link
Contributor

@magento run Functional Tests B2B, Functional Tests EE, Semantic Version Checker

@engcom-Charlie
Copy link
Contributor

@magento run all tests

@engcom-Charlie
Copy link
Contributor

@magento run Functional Tests B2B, Functional Tests CE, WebAPI Tests

@engcom-Charlie
Copy link
Contributor

@engcom-Charlie
Copy link
Contributor

engcom-Charlie commented Mar 11, 2024

Once semver version will get release and all the related updation will be done we will take this PR further, till then moving this PR to On Hold.

@engcom-Charlie engcom-Charlie moved this from Extended testing (optional) to On Hold in Community Dashboard Mar 11, 2024
@engcom-Charlie
Copy link
Contributor

@magento run all tests

@engcom-Charlie
Copy link
Contributor

As mentioned here, the semver version will get release in upcoming month, post that we can take this PR further.

@engcom-Charlie
Copy link
Contributor

@magento run all tests

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Cron Component: Shell Issue: needs update Additional information is require, waiting for response Partner: Fisheye partners-contribution Pull Request is created by Magento Partner Priority: P3 May be fixed according to the position in the backlog. Progress: on hold Project: Community Picked PRs upvoted by the community Release Line: 2.4
Projects
Development

Successfully merging this pull request may close these issues.

[Issue] Improve cron error logging
10 participants