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

[BUG] An inconsistent number of audit logs is created when a snapshot is taken. #2169

Open
lukasz-soszynski-eliatra opened this issue Oct 14, 2022 · 1 comment
Labels
bug Something isn't working good first issue These are recommended starting points for newcomers looking to make their first contributions. triaged Issues labeled as 'Triaged' have been reviewed and are deemed actionable.

Comments

@lukasz-soszynski-eliatra
Copy link
Contributor

What is the bug?
A variable number of audit logs is created when a snapshot is taken:

  1. One or two audit logs are created with the category AUTHENTICATED and request path /_snapshot/test-snapshot-repository/snapshot-positive-test
  2. Two or four audit logs are created with the category GRANTED_PRIVILEGES and request type GetSnapshotsRequest

How can one reproduce the bug?
The bug was found during work on integration tests for snapshot features. The easiest way to reproduce the problem is to run the test org.opensearch.security.SearchOperationTest#shouldCreateSnapshot_positive, https://github.com/opensearch-project/security/pull/2153/files#diff-a407f817ee7d41d20775ea3fec31ed0a1fb81230503909a94266e78fe73a07d0R1385

The number of audit logs depends on the test execution order. When only the above test is run from the IDE then always 2 audits AUTHENTICATED/_snapshot/test-snapshot-repository/snapshot-positive-test and 4 GRANTED_PRIVILEGES/GetSnapshotsRequest are created. But when all tests from the class SearchOperationTest are run then depending on the execution order only 1 audits AUTHENTICATED/_snapshot/test-snapshot-repository/snapshot-positive-test and 2 GRANTED_PRIVILEGES/GetSnapshotsRequest are created during test shouldCreateSnapshot_positive.

It is also worth mentioning that after each test snapshot repository is removed if exists.

What is the expected behaviour?
The consistent number of audit logs is created

What is your host/environment?

  • Integration tests

Do you have any screenshots?
no

Do you have any additional context?
To easily tracks the number of audit logs created during tests it is worth assigning DEBUG level to logger org.opensearch.test.framework.audit.AuditLogsRule

@lukasz-soszynski-eliatra lukasz-soszynski-eliatra added bug Something isn't working untriaged Require the attention of the repository maintainers and may need to be prioritized labels Oct 14, 2022
@stephen-crawford stephen-crawford added triaged Issues labeled as 'Triaged' have been reviewed and are deemed actionable. good first issue These are recommended starting points for newcomers looking to make their first contributions. hacktoberfest Global event that encourages people to contribute to open-source. and removed untriaged Require the attention of the repository maintainers and may need to be prioritized labels Oct 17, 2022
@davidlago davidlago removed the hacktoberfest Global event that encourages people to contribute to open-source. label Nov 2, 2022
@MaciejMierzwa
Copy link
Contributor

Hi, it seems like the problem was caused by Awaitility.await() method used in SnapshotSteps.waitForSnapshotCreation()
Default poll interval is 100 miliseconds, if the call wasn't succesfull in this time it would perform another request, increasing number of audit logs.
This task should be solved by: #3602
#3426

stephen-crawford pushed a commit that referenced this issue Dec 14, 2023
### Description
test PR 
### Issues Resolved
- #3426
- #2141
- #2169

Similar to this task:
#1917
From what I've noticed some logs are duplicated on faster machines.
During test creation audit logging results were added based on actual
results produced by tests. Now if there are slower moments where logging
produces non-duplicated logs, those were marked as failed.

By submitting this pull request, I confirm that my contribution is made
under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and
signing off your commits, please check
[here](https://github.com/opensearch-project/OpenSearch/blob/main/CONTRIBUTING.md#developer-certificate-of-origin).

---------

Signed-off-by: Maciej Mierzwa <dev.maciej.mierzwa@gmail.com>
Signed-off-by: MaciejMierzwa <dev.maciej.mierzwa@gmail.com>
MaciejMierzwa added a commit to MaciejMierzwa/security that referenced this issue Dec 18, 2023
Search operation test flakiness fix
- opensearch-project#3426
- opensearch-project#2141
- opensearch-project#2169

Similar to this task:
opensearch-project#1917
From what I've noticed some logs are duplicated on faster machines.
During test creation audit logging results were added based on actual
results produced by tests. Now if there are slower moments where logging
produces non-duplicated logs, those were marked as failed.

By submitting this pull request, I confirm that my contribution is made
under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and
signing off your commits, please check
[here](https://github.com/opensearch-project/OpenSearch/blob/main/CONTRIBUTING.md#developer-certificate-of-origin).

---------

Signed-off-by: Maciej Mierzwa <dev.maciej.mierzwa@gmail.com>
Signed-off-by: MaciejMierzwa <dev.maciej.mierzwa@gmail.com>
(cherry picked from commit 9da4a78)
MaciejMierzwa added a commit to MaciejMierzwa/security that referenced this issue Dec 18, 2023
Search operation test flakiness fix
- opensearch-project#3426
- opensearch-project#2141
- opensearch-project#2169

Similar to this task:
opensearch-project#1917
From what I've noticed some logs are duplicated on faster machines.
During test creation audit logging results were added based on actual
results produced by tests. Now if there are slower moments where logging
produces non-duplicated logs, those were marked as failed.

By submitting this pull request, I confirm that my contribution is made
under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and
signing off your commits, please check
[here](https://github.com/opensearch-project/OpenSearch/blob/main/CONTRIBUTING.md#developer-certificate-of-origin).

---------

Signed-off-by: Maciej Mierzwa <dev.maciej.mierzwa@gmail.com>
Signed-off-by: MaciejMierzwa <dev.maciej.mierzwa@gmail.com>
(cherry picked from commit 9da4a78)
Signed-off-by: Maciej Mierzwa <dev.maciej.mierzwa@gmail.com>
MaciejMierzwa added a commit to MaciejMierzwa/security that referenced this issue Dec 18, 2023
Search operation test flakiness fix
- opensearch-project#3426
- opensearch-project#2141
- opensearch-project#2169

Similar to this task:
opensearch-project#1917
From what I've noticed some logs are duplicated on faster machines.
During test creation audit logging results were added based on actual
results produced by tests. Now if there are slower moments where logging
produces non-duplicated logs, those were marked as failed.

By submitting this pull request, I confirm that my contribution is made
under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and
signing off your commits, please check
[here](https://github.com/opensearch-project/OpenSearch/blob/main/CONTRIBUTING.md#developer-certificate-of-origin).

---------

Signed-off-by: Maciej Mierzwa <dev.maciej.mierzwa@gmail.com>
Signed-off-by: MaciejMierzwa <dev.maciej.mierzwa@gmail.com>
(cherry picked from commit 9da4a78)
Signed-off-by: Maciej Mierzwa <dev.maciej.mierzwa@gmail.com>
prabhask5 pushed a commit to prabhask5/opensearch-security that referenced this issue Jan 11, 2024
### Description
test PR
### Issues Resolved
- opensearch-project#3426
- opensearch-project#2141
- opensearch-project#2169

Similar to this task:
opensearch-project#1917
From what I've noticed some logs are duplicated on faster machines.
During test creation audit logging results were added based on actual
results produced by tests. Now if there are slower moments where logging
produces non-duplicated logs, those were marked as failed.

By submitting this pull request, I confirm that my contribution is made
under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and
signing off your commits, please check
[here](https://github.com/opensearch-project/OpenSearch/blob/main/CONTRIBUTING.md#developer-certificate-of-origin).

---------

Signed-off-by: Maciej Mierzwa <dev.maciej.mierzwa@gmail.com>
Signed-off-by: MaciejMierzwa <dev.maciej.mierzwa@gmail.com>
Signed-off-by: Prabhas Kurapati <prabhask@berkeley.edu>
dlin2028 pushed a commit to dlin2028/security that referenced this issue May 1, 2024
### Description
test PR 
### Issues Resolved
- opensearch-project#3426
- opensearch-project#2141
- opensearch-project#2169

Similar to this task:
opensearch-project#1917
From what I've noticed some logs are duplicated on faster machines.
During test creation audit logging results were added based on actual
results produced by tests. Now if there are slower moments where logging
produces non-duplicated logs, those were marked as failed.

By submitting this pull request, I confirm that my contribution is made
under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and
signing off your commits, please check
[here](https://github.com/opensearch-project/OpenSearch/blob/main/CONTRIBUTING.md#developer-certificate-of-origin).

---------

Signed-off-by: Maciej Mierzwa <dev.maciej.mierzwa@gmail.com>
Signed-off-by: MaciejMierzwa <dev.maciej.mierzwa@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue These are recommended starting points for newcomers looking to make their first contributions. triaged Issues labeled as 'Triaged' have been reviewed and are deemed actionable.
Projects
None yet
Development

No branches or pull requests

4 participants