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 42 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
@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
@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
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

@engcom-Charlie
Copy link
Contributor

@magento run all tests

@engcom-Charlie
Copy link
Contributor

@magento run all tests

@engcom-Charlie
Copy link
Contributor

engcom-Charlie commented Nov 21, 2024

The semver version updation mentioned here, has been done in https://github.com/magento-commerce/magento2-infrastructure/commit/cb8dbe8c793a290c35ef345757719b9e77edb749. As the SVC is green and all the related PRs got merged, moving this PR back to Extended testing.

@engcom-Charlie
Copy link
Contributor

@magento run Functional Tests B2B, Functional Tests CE, Functional Tests EE, Unit Tests

@engcom-Charlie
Copy link
Contributor

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

@engcom-Charlie
Copy link
Contributor

@magento run all tests

@engcom-Charlie
Copy link
Contributor

@magento run all tests

@engcom-Charlie
Copy link
Contributor

engcom-Charlie commented Nov 25, 2024

@engcom-Charlie
Copy link
Contributor

@engcom-Charlie
Copy link
Contributor

@magento run Functional Tests B2B

@engcom-Charlie
Copy link
Contributor

engcom-Charlie commented Nov 25, 2024

The consistent Functional B2B failures in recent 2 builds, are not part of PR or not failing because of PR changes. Both the test failures are known issues, hence seems to be flaky. Moving this PR to Merge in Progress.

Run 1:
https://public-results-storage-prod.magento-testing-service.engineering/reports/magento/magento2/pull/32690/577a0cd1854a6706df08c1e53fbca6d1/Functional/allure-report-b2b/index.html#categories/3a3a8306986cbb01e5245b23e6e5b238/ec166d8c6b748555/

image

Run 2:
https://public-results-storage-prod.magento-testing-service.engineering/reports/magento/magento2/pull/32690/ff65cb5036efddc3880186342cd441ab/Functional/allure-report-b2b/index.html#categories

image

Known issues:
ACQE-7230 - StorefrontReuseCouponCodeAfterOrderCanceledTest
ACQE-7229 - MultiShippingWithCreationNewCustomerAndAddressesDuringCheckoutTest

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
Status: Merge in Progress
Development

Successfully merging this pull request may close these issues.

[Issue] Improve cron error logging
10 participants