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

Add a "cluster curl" tool #1046

Merged

Conversation

mikaylathompson
Copy link
Collaborator

@mikaylathompson mikaylathompson commented Oct 2, 2024

Description

This adds a curl-like command to our cli, called clusters rest-call. The user specifies which cluster and then a path, and it makes a call and returns the result.

(.venv) sh-5.2# console clusters curl target_cluster _cat/indices
green  open .opensearch-observability    ZZV9G4p_QbW9Z4IMzis0cw 1 0  0 0   208b   208b
green  open .plugins-ml-config           4-zA4PGQSG2Phx_hm8H1Ng 1 0  1 0  3.9kb  3.9kb
yellow open security-auditlog-2024.10.04 yZhCHEXUScOmmn4BipEWeg 1 1  3 0   50kb   50kb
yellow open new-index                    xunLH4XMRXqhiKS0viY0IQ 1 1  3 0  8.4kb  8.4kb
green  open .opendistro_security         gxQ9wlmkQHCvJKodmavnRA 1 0 10 0 78.3kb 78.3kb

(.venv) sh-5.2# 
(.venv) sh-5.2# 
(.venv) sh-5.2# 
(.venv) sh-5.2# console clusters curl target_cluster /
{
  "name" : "13d4b5b49ff8",
  "cluster_name" : "docker-cluster",
  "cluster_uuid" : "B-TtUe80Svu5NiPISo_47A",
  "version" : {
    "distribution" : "opensearch",
    "number" : "2.15.0",
    "build_type" : "tar",
    "build_hash" : "61dbcd0795c9bfe9b81e5762175414bc38bbcadf",
    "build_date" : "2024-06-20T03:27:32.562036890Z",
    "build_snapshot" : false,
    "lucene_version" : "9.10.0",
    "minimum_wire_compatibility_version" : "7.10.0",
    "minimum_index_compatibility_version" : "7.0.0"
  },
  "tagline" : "The OpenSearch Project: https://opensearch.org/"
}

(.venv) sh-5.2# 
(.venv) sh-5.2# 
(.venv) sh-5.2# 
(.venv) sh-5.2# console clusters curl -XPOST target_cluster /new-index-2/_doc --json '{"id": 3, "number": 10}'
{"_index":"new-index-2","_id":"tCzFbJIBO46AuR2VLwFV","_version":1,"result":"created","_shards":{"total":2,"successful":1,"failed":0},"_seq_no":0,"_primary_term":1}
(.venv) sh-5.2#

Issues Resolved

https://opensearch.atlassian.net/browse/MIGRATIONS-2047

Testing

Adding now.

Check List

  • New functionality includes testing
    • All tests pass, including unit test, integration test and doctest
  • New functionality has been documented
  • 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.

Signed-off-by: Mikayla Thompson <[email protected]>
Copy link

codecov bot commented Oct 2, 2024

Codecov Report

Attention: Patch coverage is 97.43590% with 1 line in your changes missing coverage. Please review.

Project coverage is 80.60%. Comparing base (5015220) to head (8d0e534).
Report is 21 commits behind head on main.

Files with missing lines Patch % Lines
...rationConsole/lib/console_link/console_link/cli.py 97.43% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main    #1046      +/-   ##
============================================
+ Coverage     80.57%   80.60%   +0.03%     
  Complexity     2736     2736              
============================================
  Files           365      365              
  Lines         13611    13653      +42     
  Branches        941      941              
============================================
+ Hits          10967    11005      +38     
- Misses         2067     2071       +4     
  Partials        577      577              
Flag Coverage Δ
gradle-test 78.59% <ø> (-0.03%) ⬇️
python-test 90.24% <97.43%> (+0.13%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

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

Signed-off-by: Mikayla Thompson <[email protected]>
"--config-file", default="/etc/migration_services.yaml", help="Path to config file"
)
@click.option('-v', '--verbose', count=True, help="Verbosity level. Default is warn, -v is info, -vv is debug.")
@click.option('-X', '--request', default='GET', help="HTTP method to use",
Copy link
Collaborator

Choose a reason for hiding this comment

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

--request is a bit confusing. Is that what curl (or anything else) uses? 'Verb' or 'method' are common labels

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is what curl uses

install_requires=["console_link", "Click"],
entry_points={
"console_scripts": [
"ccurl = cli:cli",
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'd choose another name other than curl as the root name. With curl, a user might think that they can use --verbose to trace activity, append a binary file, set cookies, etc. This is useful by itself. It doesn't need to try to replace or compete with curl.

Signed-off-by: Mikayla Thompson <[email protected]>
Signed-off-by: Mikayla Thompson <[email protected]>
@mikaylathompson mikaylathompson merged commit cdf697e into opensearch-project:main Oct 9, 2024
14 checks passed
@mikaylathompson mikaylathompson deleted the cluster-curl-tool branch October 9, 2024 15:26
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.

3 participants