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

WRLGS-11: Utils to timestamp stderr logs #167

Merged
merged 5 commits into from
Jun 28, 2024

Conversation

BourgoisMickael
Copy link
Contributor

@BourgoisMickael BourgoisMickael commented Jun 26, 2024

Define functions that adds a timestamp to stderr logs: uncaughtException and warning events.

These functions should be used in every component, so if we want to refine the format of stderr logs, we can change only one function in one place


Based on assessment S3C-8936_logs_inventory

The versions of werelogs used by S3C components between S3C 7.10.8 and S3C 9.4 are:

Current version Next version Comment
8.1.4 8.1.5 Current default branch
8.1.0 8.1.0.1 Need new branch hotfix/8.1.0
7.10.1.6 7.10.5 7.4.10 and 7.10.1.0 to 7.10.4.10: they are all the same commit 23dfe7c
Branches hotfix/7.4.10 = hotfix/7.10.1 and above = development/7.10
7.10.3.9 7.10.5 same as above
8.0.1 Existing branch development/8.0 with unused version 8.0.0 in latest S3C assessed

Important

PR for hotfix/8.1.0 ⏭️ #168 ⏮️


Note

Logs will look like this for uncaught errors

2024-06-27T08:47:22.654Z: uncaughtException:
Error: TestingError
   at Object.<anonymous> (/home/mickael/scality/werelogs/tests/unit/fixtures/stderrUtils/catchUncaughtException.js:22:11)
   at Module._compile (node:internal/modules/cjs/loader:1198:14)
   at Object.Module._extensions..js (node:internal/modules/cjs/loader:1252:10)
   at Module.load (node:internal/modules/cjs/loader:1076:32)
   at Function.Module._load (node:internal/modules/cjs/loader:911:12)
   at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
   at node:internal/main/run_main_module:22:47

And like this for warnings

(node:39843) DeprecationWarning: TestWarningMessage
   at Object.<anonymous> (/home/mickael/scality/werelogs/tests/unit/fixtures/stderrUtils/catchWarning.js:15:17)
   at Module._compile (node:internal/modules/cjs/loader:1198:14)
   at Object.Module._extensions..js (node:internal/modules/cjs/loader:1252:10)
   at Module.load (node:internal/modules/cjs/loader:1076:32)
   at Function.Module._load (node:internal/modules/cjs/loader:911:12)
   at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
   at node:internal/main/run_main_module:22:47
Above Warning Date: 2024-06-27T08:48:45.046Z
(node:41812) NOTE: The AWS SDK for JavaScript (v2) will enter maintenance mode
on September 8, 2024 and reach end-of-support on September 8, 2025.

Please migrate your code to use AWS SDK for JavaScript (v3).
For more information, check blog post at https://a.co/cUPnyil
   at emitWarning (/home/mickael/scality/werelogs/node_modules/aws-sdk/lib/maintenance_mode_message.js:38:13)
   at Timeout._onTimeout (/home/mickael/scality/werelogs/node_modules/aws-sdk/lib/maintenance_mode_message.js:46:5)
   at listOnTimeout (node:internal/timers:559:17)
   at processTimers (node:internal/timers:502:7)
Above Warning Date: 2024-06-27T08:53:51.170Z

I'll remove this warnings in components also

@bert-e
Copy link
Contributor

bert-e commented Jun 26, 2024

Hello bourgoismickael,

My role is to assist you with the merge of this
pull request. Please type @bert-e help to get information
on this process, or consult the user documentation.

Available options
name description privileged authored
/after_pull_request Wait for the given pull request id to be merged before continuing with the current one.
/bypass_author_approval Bypass the pull request author's approval
/bypass_build_status Bypass the build and test status
/bypass_commit_size Bypass the check on the size of the changeset TBA
/bypass_incompatible_branch Bypass the check on the source branch prefix
/bypass_jira_check Bypass the Jira issue check
/bypass_peer_approval Bypass the pull request peers' approval
/bypass_leader_approval Bypass the pull request leaders' approval
/approve Instruct Bert-E that the author has approved the pull request. ✍️
/create_pull_requests Allow the creation of integration pull requests.
/create_integration_branches Allow the creation of integration branches.
/no_octopus Prevent Wall-E from doing any octopus merge and use multiple consecutive merge instead
/unanimity Change review acceptance criteria from one reviewer at least to all reviewers
/wait Instruct Bert-E not to run until further notice.
Available commands
name description privileged
/help Print Bert-E's manual in the pull request.
/status Print Bert-E's current status in the pull request TBA
/clear Remove all comments from Bert-E from the history TBA
/retry Re-start a fresh build TBA
/build Re-start a fresh build TBA
/force_reset Delete integration branches & pull requests, and restart merge process from the beginning.
/reset Try to remove integration branches unless there are commits on them which do not appear on the source branch.

Status report is not available.

@BourgoisMickael BourgoisMickael force-pushed the improvement/WRLGS-11-stderr-timestamp branch from 34fef9b to e20f930 Compare June 26, 2024 19:06
@bert-e
Copy link
Contributor

bert-e commented Jun 27, 2024

Request integration branches

Waiting for integration branch creation to be requested by the user.

To request integration branches, please comment on this pull request with the following command:

/create_integration_branches

Alternatively, the /approve and /create_pull_requests commands will automatically
create the integration branches.

@BourgoisMickael
Copy link
Contributor Author

/create_integration_branches

@bert-e
Copy link
Contributor

bert-e commented Jun 28, 2024

Waiting for approval

The following approvals are needed before I can proceed with the merge:

  • the author

  • 2 peers

The following options are set: create_integration_branches

@BourgoisMickael
Copy link
Contributor Author

/approve

@bert-e
Copy link
Contributor

bert-e commented Jun 28, 2024

Build failed

The build for commit did not succeed in branch w/8.1/improvement/WRLGS-11-stderr-timestamp.

The following options are set: approve, create_integration_branches

nyc coverage seems to slow down the process on first run
The slow seems to vary between branches (due to nyc version)
All tags from 7.4.10 and 7.10.1.0 to 7.10.4.10
are all the same commit 23dfe7c
@BourgoisMickael BourgoisMickael force-pushed the improvement/WRLGS-11-stderr-timestamp branch from e20f930 to 4984e5b Compare June 28, 2024 10:01
@BourgoisMickael
Copy link
Contributor Author

/reset

Comment on lines +45 to +54
function catchAndTimestampUncaughtException(
dateFct = defaultTimestamp, exitCode = 1,
) {
process.on('uncaughtException', (err, origin) => {
printErrorWithTimestamp(err, origin, dateFct());
if (exitCode !== null) {
process.nextTick(() => process.exit(exitCode));
}
});
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Would it make sense not to stop the process if we pass a flag? Example: https://github.com/scality/vault2/blob/6a0c2cf3de174f5f339f1379227fbe87b0e99ce7/lib/vaultd.js#L30

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think it should be the default behavior to stop the process.

Most processes don't have any listener on this.
I plan to use simply:

require('werelogs').stderrUtils.catchAndTimestampStderr();

Some processes have, like cloudserver when it does not exit all the time and could end in undefined behavior.

@BourgoisMickael
Copy link
Contributor Author

/force_reset

function printErrorWithTimestamp(
err, origin, date = defaultTimestamp(),
) {
return process.stderr.write(`${date}: ${origin}:\n${err.stack}\n`);
Copy link
Contributor

Choose a reason for hiding this comment

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

If we plan to crash the process, why not logging with fatal level here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Those are stderr logs, there is no Logger to format those logs as json.

I copied what's done there: https://github.com/scality/cloudserver/pull/5406/files#diff-e727e4bdf3657fd1d798edcd6b099d6e092f8573cba266154583a746bba0f346R7

And we decided for now we don't want to change the format completely, we want functions to encapsulate the logic and later if we need to we could change the format in those functions and just bump in all components

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We try not to change the behavior too much for now, we just need to include the timestamp in stderr for the CS

@bert-e
Copy link
Contributor

bert-e commented Jun 28, 2024

Reset complete

I have successfully deleted this pull request's integration branches.

The following options are set: approve, create_integration_branches

@bert-e
Copy link
Contributor

bert-e commented Jun 28, 2024

Conflict

A conflict has been raised during the creation of
integration branch w/8.0/improvement/WRLGS-11-stderr-timestamp with contents from improvement/WRLGS-11-stderr-timestamp
and development/8.0.

I have not created the integration branch.

Here are the steps to resolve this conflict:

 $ git fetch
 $ git checkout -B w/8.0/improvement/WRLGS-11-stderr-timestamp origin/development/8.0
 $ git merge origin/improvement/WRLGS-11-stderr-timestamp
 $ # <intense conflict resolution>
 $ git commit
 $ git push -u origin w/8.0/improvement/WRLGS-11-stderr-timestamp

The following options are set: approve, create_integration_branches

@bert-e
Copy link
Contributor

bert-e commented Jun 28, 2024

Conflict

A conflict has been raised during the creation of
integration branch w/8.1/improvement/WRLGS-11-stderr-timestamp with contents from w/8.0/improvement/WRLGS-11-stderr-timestamp
and development/8.1.

I have not created the integration branch.

Here are the steps to resolve this conflict:

 $ git fetch
 $ git checkout -B w/8.1/improvement/WRLGS-11-stderr-timestamp origin/development/8.1
 $ git merge origin/w/8.0/improvement/WRLGS-11-stderr-timestamp
 $ # <intense conflict resolution>
 $ git commit
 $ git push -u origin w/8.1/improvement/WRLGS-11-stderr-timestamp

The following options are set: approve, create_integration_branches

@scality scality deleted a comment from bert-e Jun 28, 2024
@scality scality deleted a comment from bert-e Jun 28, 2024
@scality scality deleted a comment from bert-e Jun 28, 2024
@scality scality deleted a comment from bert-e Jun 28, 2024
@scality scality deleted a comment from bert-e Jun 28, 2024
@bert-e
Copy link
Contributor

bert-e commented Jun 28, 2024

I have successfully merged the changeset of this pull request
into targetted development branches:

  • ✔️ development/7.10

  • ✔️ development/8.0

  • ✔️ development/8.1

The following branches have NOT changed:

  • development/6.4
  • development/7.4

Please check the status of the associated issue WRLGS-11.

Goodbye bourgoismickael.

The following options are set: approve, create_integration_branches

@bert-e bert-e merged commit 4984e5b into development/7.10 Jun 28, 2024
1 check passed
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.

5 participants