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

Added validation for the new clusters field. #633

Merged
merged 5 commits into from
Apr 12, 2024

Conversation

AWSHurneyt
Copy link
Collaborator

Description

  1. Added validation for the clusters field.
  2. Refactored ClusterMetricsInput validiation to throw 4xx-level CommonUtilsExceptions instead of 5xx-level IllegalArgumentException.

Issues Resolved

[List any issues this PR will resolve]

Check List

  • New functionality includes testing.
    • All tests pass
  • New functionality has been documented.
    • New functionality has javadoc added
  • Commits are signed per the DCO using --signoff

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.

…ut validiation to throw 4xx-level CommonUtilsExceptions instead of 5xx-level IllegalArgumentException.

Signed-off-by: AWSHurneyt <hurneyt@amazon.com>
@AWSHurneyt
Copy link
Collaborator Author

Whitesource finding will be fixed in a separate PR.

Signed-off-by: AWSHurneyt <hurneyt@amazon.com>
Copy link

codecov bot commented Apr 12, 2024

Codecov Report

Attention: Patch coverage is 66.66667% with 20 lines in your changes are missing coverage. Please review.

Project coverage is 73.73%. Comparing base (c05715b) to head (4636569).

❗ Current head 4636569 differs from pull request most recent head 89aef1c. Consider uploading reports for the commit 89aef1c to get more accurate results

Files Patch % Lines
...arch/commons/alerting/util/CommonUtilsException.kt 39.28% 11 Missing and 6 partials ⚠️
...org/opensearch/commons/alerting/util/IndexUtils.kt 0.00% 3 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main     #633      +/-   ##
============================================
- Coverage     73.90%   73.73%   -0.17%     
  Complexity      891      891              
============================================
  Files           133      134       +1     
  Lines          5870     5910      +40     
  Branches        717      726       +9     
============================================
+ Hits           4338     4358      +20     
- Misses         1219     1233      +14     
- Partials        313      319       +6     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Signed-off-by: AWSHurneyt <hurneyt@amazon.com>
Signed-off-by: AWSHurneyt <hurneyt@amazon.com>
Signed-off-by: AWSHurneyt <hurneyt@amazon.com>
@AWSHurneyt AWSHurneyt merged commit abc69cd into opensearch-project:main Apr 12, 2024
8 of 9 checks passed
@opensearch-trigger-bot
Copy link
Contributor

The backport to 2.x failed:

The process '/usr/bin/git' failed with exit code 128

To backport manually, run these commands in your terminal:

# Navigate to the root of your repository
cd $(git rev-parse --show-toplevel)
# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add ../.worktrees/common-utils/backport-2.x 2.x
# Navigate to the new working tree
pushd ../.worktrees/common-utils/backport-2.x
# Create a new branch
git switch --create backport-633-to-2.x
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 abc69cdbaf1de6258db430b1d284e7a3e614c83b
# Push it to GitHub
git push --set-upstream origin backport-633-to-2.x
# Go back to the original working tree
popd
# Delete the working tree
git worktree remove ../.worktrees/common-utils/backport-2.x

Then, create a pull request where the base branch is 2.x and the compare/head branch is backport-633-to-2.x.

@opensearch-trigger-bot
Copy link
Contributor

The backport to 2.12 failed:

The process '/usr/bin/git' failed with exit code 1

To backport manually, run these commands in your terminal:

# Navigate to the root of your repository
cd $(git rev-parse --show-toplevel)
# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add ../.worktrees/common-utils/backport-2.12 2.12
# Navigate to the new working tree
pushd ../.worktrees/common-utils/backport-2.12
# Create a new branch
git switch --create backport-633-to-2.12
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 abc69cdbaf1de6258db430b1d284e7a3e614c83b
# Push it to GitHub
git push --set-upstream origin backport-633-to-2.12
# Go back to the original working tree
popd
# Delete the working tree
git worktree remove ../.worktrees/common-utils/backport-2.12

Then, create a pull request where the base branch is 2.12 and the compare/head branch is backport-633-to-2.12.

@opensearch-trigger-bot
Copy link
Contributor

The backport to 2.13 failed:

The process '/usr/bin/git' failed with exit code 1

To backport manually, run these commands in your terminal:

# Navigate to the root of your repository
cd $(git rev-parse --show-toplevel)
# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add ../.worktrees/common-utils/backport-2.13 2.13
# Navigate to the new working tree
pushd ../.worktrees/common-utils/backport-2.13
# Create a new branch
git switch --create backport-633-to-2.13
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 abc69cdbaf1de6258db430b1d284e7a3e614c83b
# Push it to GitHub
git push --set-upstream origin backport-633-to-2.13
# Go back to the original working tree
popd
# Delete the working tree
git worktree remove ../.worktrees/common-utils/backport-2.13

Then, create a pull request where the base branch is 2.13 and the compare/head branch is backport-633-to-2.13.

AWSHurneyt added a commit to AWSHurneyt/common-utils that referenced this pull request Apr 12, 2024
* Added validation for the clusters field. Refactored ClusterMetricsInput validiation to throw 4xx-level CommonUtilsExceptions instead of 5xx-level IllegalArgumentException.

Signed-off-by: AWSHurneyt <hurneyt@amazon.com>

* Moved some regex from alerting plugin to common utils.

Signed-off-by: AWSHurneyt <hurneyt@amazon.com>

* Moved cluster-based regex to separate file.

Signed-off-by: AWSHurneyt <hurneyt@amazon.com>

* Fixed ktlint error.

Signed-off-by: AWSHurneyt <hurneyt@amazon.com>

* Fixed regex. Moved cluster-related regexes.

Signed-off-by: AWSHurneyt <hurneyt@amazon.com>

---------

Signed-off-by: AWSHurneyt <hurneyt@amazon.com>
AWSHurneyt added a commit to AWSHurneyt/common-utils that referenced this pull request Apr 12, 2024
* Added validation for the clusters field. Refactored ClusterMetricsInput validiation to throw 4xx-level CommonUtilsExceptions instead of 5xx-level IllegalArgumentException.

Signed-off-by: AWSHurneyt <hurneyt@amazon.com>

* Moved some regex from alerting plugin to common utils.

Signed-off-by: AWSHurneyt <hurneyt@amazon.com>

* Moved cluster-based regex to separate file.

Signed-off-by: AWSHurneyt <hurneyt@amazon.com>

* Fixed ktlint error.

Signed-off-by: AWSHurneyt <hurneyt@amazon.com>

* Fixed regex. Moved cluster-related regexes.

Signed-off-by: AWSHurneyt <hurneyt@amazon.com>

---------

Signed-off-by: AWSHurneyt <hurneyt@amazon.com>
AWSHurneyt added a commit to AWSHurneyt/common-utils that referenced this pull request Apr 12, 2024
* Added validation for the clusters field. Refactored ClusterMetricsInput validiation to throw 4xx-level CommonUtilsExceptions instead of 5xx-level IllegalArgumentException.

Signed-off-by: AWSHurneyt <hurneyt@amazon.com>

* Moved some regex from alerting plugin to common utils.

Signed-off-by: AWSHurneyt <hurneyt@amazon.com>

* Moved cluster-based regex to separate file.

Signed-off-by: AWSHurneyt <hurneyt@amazon.com>

* Fixed ktlint error.

Signed-off-by: AWSHurneyt <hurneyt@amazon.com>

* Fixed regex. Moved cluster-related regexes.

Signed-off-by: AWSHurneyt <hurneyt@amazon.com>

---------

Signed-off-by: AWSHurneyt <hurneyt@amazon.com>
eirsep pushed a commit that referenced this pull request Apr 13, 2024
)

* Added validation for the new clusters field. (#633)

* Added validation for the clusters field. Refactored ClusterMetricsInput validiation to throw 4xx-level CommonUtilsExceptions instead of 5xx-level IllegalArgumentException.

Signed-off-by: AWSHurneyt <hurneyt@amazon.com>

* Moved some regex from alerting plugin to common utils.

Signed-off-by: AWSHurneyt <hurneyt@amazon.com>

* Moved cluster-based regex to separate file.

Signed-off-by: AWSHurneyt <hurneyt@amazon.com>

* Fixed ktlint error.

Signed-off-by: AWSHurneyt <hurneyt@amazon.com>

* Fixed regex. Moved cluster-related regexes.

Signed-off-by: AWSHurneyt <hurneyt@amazon.com>

---------

Signed-off-by: AWSHurneyt <hurneyt@amazon.com>

* Removed CommonUtilsException. Team decided IllegalArgumentExceptions should be caught in the plugins themselves.

Signed-off-by: AWSHurneyt <hurneyt@amazon.com>

---------

Signed-off-by: AWSHurneyt <hurneyt@amazon.com>
opensearch-trigger-bot bot pushed a commit that referenced this pull request Apr 13, 2024
)

* Added validation for the new clusters field. (#633)

* Added validation for the clusters field. Refactored ClusterMetricsInput validiation to throw 4xx-level CommonUtilsExceptions instead of 5xx-level IllegalArgumentException.

Signed-off-by: AWSHurneyt <hurneyt@amazon.com>

* Moved some regex from alerting plugin to common utils.

Signed-off-by: AWSHurneyt <hurneyt@amazon.com>

* Moved cluster-based regex to separate file.

Signed-off-by: AWSHurneyt <hurneyt@amazon.com>

* Fixed ktlint error.

Signed-off-by: AWSHurneyt <hurneyt@amazon.com>

* Fixed regex. Moved cluster-related regexes.

Signed-off-by: AWSHurneyt <hurneyt@amazon.com>

---------

Signed-off-by: AWSHurneyt <hurneyt@amazon.com>

* Removed CommonUtilsException. Team decided IllegalArgumentExceptions should be caught in the plugins themselves.

Signed-off-by: AWSHurneyt <hurneyt@amazon.com>

---------

Signed-off-by: AWSHurneyt <hurneyt@amazon.com>
(cherry picked from commit 4e81d64)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
opensearch-trigger-bot bot pushed a commit that referenced this pull request Apr 13, 2024
)

* Added validation for the new clusters field. (#633)

* Added validation for the clusters field. Refactored ClusterMetricsInput validiation to throw 4xx-level CommonUtilsExceptions instead of 5xx-level IllegalArgumentException.

Signed-off-by: AWSHurneyt <hurneyt@amazon.com>

* Moved some regex from alerting plugin to common utils.

Signed-off-by: AWSHurneyt <hurneyt@amazon.com>

* Moved cluster-based regex to separate file.

Signed-off-by: AWSHurneyt <hurneyt@amazon.com>

* Fixed ktlint error.

Signed-off-by: AWSHurneyt <hurneyt@amazon.com>

* Fixed regex. Moved cluster-related regexes.

Signed-off-by: AWSHurneyt <hurneyt@amazon.com>

---------

Signed-off-by: AWSHurneyt <hurneyt@amazon.com>

* Removed CommonUtilsException. Team decided IllegalArgumentExceptions should be caught in the plugins themselves.

Signed-off-by: AWSHurneyt <hurneyt@amazon.com>

---------

Signed-off-by: AWSHurneyt <hurneyt@amazon.com>
(cherry picked from commit 4e81d64)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
AWSHurneyt pushed a commit that referenced this pull request Apr 13, 2024
) (#641)

* Added validation for the new clusters field. (#633)

* Added validation for the clusters field. Refactored ClusterMetricsInput validiation to throw 4xx-level CommonUtilsExceptions instead of 5xx-level IllegalArgumentException.



* Moved some regex from alerting plugin to common utils.



* Moved cluster-based regex to separate file.



* Fixed ktlint error.



* Fixed regex. Moved cluster-related regexes.



---------



* Removed CommonUtilsException. Team decided IllegalArgumentExceptions should be caught in the plugins themselves.



---------


(cherry picked from commit 4e81d64)

Signed-off-by: AWSHurneyt <hurneyt@amazon.com>
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
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.

3 participants