Skip to content

Add regex for syslog timestamp in extract_log#7597

Merged
kellyyeh merged 2 commits intosonic-net:masterfrom
kellyyeh:warm-reboot-kvm
Mar 5, 2023
Merged

Add regex for syslog timestamp in extract_log#7597
kellyyeh merged 2 commits intosonic-net:masterfrom
kellyyeh:warm-reboot-kvm

Conversation

@kellyyeh
Copy link
Contributor

@kellyyeh kellyyeh commented Feb 28, 2023

Description of PR

Summary:
Fixes # (issue)

Type of change

  • Bug fix
  • Testbed and Framework(new/improvement)
  • Test case(new/improvement)

Back port request

  • 201911
  • 202012
  • 202205

Approach

What is the motivation for this PR?

Warm-reboot test is failing at extracting timestamp from syslog

How did you do it?

Add regex for this timestamp format: 2023-02-28T15:42:27.355561+00:00

How did you verify/test it?

Warm reboot test originally failed at preboot when parsing through syslog. Adding the regex fixed the failure.
Ran convert_date with all three formats of syslog timestamp logs

Any platform specific information?

Supported testbed topology if it's a new test case?

Documentation

@wangxin
Copy link
Collaborator

wangxin commented Mar 2, 2023

The pre-commit check detected issues in the files touched by this pull request.
The detected issues may be old or new. For new issues, please try to fix them.

For old issues, it is not mandatory to fix them because they were not caused by this change. It is unfair to blame
author of this pull request. But if you can take extra effort to fix the old issues as well, that would be great!

Detailed pre-commit check results:
trim trailing whitespace.................................................Passed
fix end of files.........................................................Passed
check yaml...........................................(no files to check)Skipped
check for added large files..............................................Passed
check python ast.........................................................Passed
flake8...................................................................Failed
- hook id: flake8
- exit code: 1

ansible/library/extract_log.py:76:1: E402 module level import not at top of file
ansible/library/extract_log.py:77:1: E402 module level import not at top of file
ansible/library/extract_log.py:78:1: E402 module level import not at top of file
ansible/library/extract_log.py:79:1: E402 module level import not at top of file
ansible/library/extract_log.py:80:1: E402 module level import not at top of file
ansible/library/extract_log.py:81:1: E402 module level import not at top of file
ansible/library/extract_log.py:82:1: E402 module level import not at top of file
ansible/library/extract_log.py:83:1: E402 module level import not at top of file
ansible/library/extract_log.py:84:1: E402 module level import not at top of file
ansible/library/extract_log.py:85:1: E402 module level import not at top of file
ansible/library/extract_log.py:86:1: F403 'from ansible.module_utils.basic import *' used; unable to detect undefined names
...
[truncated extra lines, please run pre-commit locally to view full check results]

To run the pre-commit checks locally, you can follow below steps:

  1. Ensure that default python is python3. In sonic-mgmt docker container, default python is python2. You can run
    the check by activating the python3 virtual environment in sonic-mgmt docker container or outside of sonic-mgmt
    docker container.
  2. Ensure that the pre-commit package is installed:
sudo pip install pre-commit
  1. Go to repository root folder
  2. Install the pre-commit hooks:
pre-commit install
  1. Use pre-commit to check staged file:
pre-commit
  1. Alternatively, you can check committed files using:
pre-commit run --from-ref <commit_id> --to-ref <commit_id>

@kellyyeh kellyyeh marked this pull request as ready for review March 3, 2023 03:00
@kellyyeh kellyyeh requested a review from vaibhavhd March 3, 2023 03:00
@kellyyeh kellyyeh changed the title Add regex for kvm syslog timestamp in extract_log Add regex for syslog timestamp in extract_log Mar 3, 2023
else:
return int(ns[0])


Copy link
Contributor

Choose a reason for hiding this comment

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

Minor: two places where line breaks are removed. Double line break is a pip8 suggested format.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated

vaibhavhd
vaibhavhd previously approved these changes Mar 3, 2023
Copy link
Contributor

@vaibhavhd vaibhavhd left a comment

Choose a reason for hiding this comment

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

LGTM. Please mention how this change was tested.

@wangxin
Copy link
Collaborator

wangxin commented Mar 3, 2023

The pre-commit check detected issues in the files touched by this pull request.
The detected issues may be old or new. For new issues, please try to fix them.

For old issues, it is not mandatory to fix them because they were not caused by this change. It is unfair to blame
author of this pull request. But if you can take extra effort to fix the old issues as well, that would be great!

Detailed pre-commit check results:
trim trailing whitespace.................................................Passed
fix end of files.........................................................Passed
check yaml...........................................(no files to check)Skipped
check for added large files..............................................Passed
check python ast.........................................................Passed
flake8...................................................................Failed
- hook id: flake8
- exit code: 1

ansible/library/extract_log.py:76:1: E402 module level import not at top of file
ansible/library/extract_log.py:77:1: E402 module level import not at top of file
ansible/library/extract_log.py:78:1: E402 module level import not at top of file
ansible/library/extract_log.py:79:1: E402 module level import not at top of file
ansible/library/extract_log.py:80:1: E402 module level import not at top of file
ansible/library/extract_log.py:81:1: E402 module level import not at top of file
ansible/library/extract_log.py:82:1: E402 module level import not at top of file
ansible/library/extract_log.py:83:1: E402 module level import not at top of file
ansible/library/extract_log.py:84:1: E402 module level import not at top of file
ansible/library/extract_log.py:85:1: E402 module level import not at top of file
ansible/library/extract_log.py:86:1: F403 'from ansible.module_utils.basic import *' used; unable to detect undefined names
...
[truncated extra lines, please run pre-commit locally to view full check results]

To run the pre-commit checks locally, you can follow below steps:

  1. Ensure that default python is python3. In sonic-mgmt docker container, default python is python2. You can run
    the check by activating the python3 virtual environment in sonic-mgmt docker container or outside of sonic-mgmt
    docker container.
  2. Ensure that the pre-commit package is installed:
sudo pip install pre-commit
  1. Go to repository root folder
  2. Install the pre-commit hooks:
pre-commit install
  1. Use pre-commit to check staged file:
pre-commit
  1. Alternatively, you can check committed files using:
pre-commit run --from-ref <commit_id> --to-ref <commit_id>

@kellyyeh kellyyeh requested a review from vaibhavhd March 3, 2023 23:01
@kellyyeh
Copy link
Contributor Author

kellyyeh commented Mar 3, 2023

LGTM. Please mention how this change was tested.

Updated testing

@mssonicbld
Copy link
Collaborator

Cherry-pick PR to 202205: #8675

mssonicbld pushed a commit to mssonicbld/sonic-mgmt that referenced this pull request Jun 21, 2023
mssonicbld pushed a commit to mssonicbld/sonic-mgmt that referenced this pull request Jun 21, 2023
@mssonicbld
Copy link
Collaborator

Cherry-pick PR to 202012: #8676

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants