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

feat: Use HEAD request to check if es_visibility index exists #585

Merged
merged 4 commits into from
Oct 17, 2024

Conversation

VLZZZ
Copy link
Contributor

@VLZZZ VLZZZ commented Oct 8, 2024

What was changed

curl is now using HEAD request to ensure index existence and will result in 200/404 depending on the the result.
I decided to propose HEAD instead of GET as I believe we don't need all of the output GET /index will produce. See Context below.

Context
Both Elasticsearch and Opensearch support the following requests types to validate index existence:

  1. GET /index - ES docs | OS docs

    ~ curl -X GET --fail --user "$ES_USER:$ES_PWD" $ES_SCHEME://$ES_HOST:$ES_PORT/$ES_VISIBILITY_INDEX                                                                                                                                          
    
    {"temporal_visibility_v1_dev":{"aliases":{},"mappings":{"dynamic":"false","properties": .......... [OUTPUT TRIMMED]
    
  2. HEAD /index - ES docs | OS docs

     ~  curl --head --fail --user "$ES_USER:$ES_PWD" $ES_SCHEME://$ES_HOST:$ES_PORT/$ES_VISIBILITY_INDEX                                                                                                                                      
     
    HTTP/2 200
    date: Mon, 07 Oct 2024 11:12:50 GMT
    content-type: application/json; charset=UTF-8
    content-length: 1499
    access-control-allow-origin: *
    

Why?

Please see #583

Checklist

  1. Closes [Bug] Failed to validate ES index due to PUT request usage #583

  2. How was this tested:

  • Ensured that curl embedded in the admintools support --head arg properly
  • Tested locally
  1. Any docs updates needed?
    No

@VLZZZ VLZZZ requested a review from a team as a code owner October 8, 2024 09:07
@robholland
Copy link
Contributor

The request isn't to check existence, it's trigger creation of an index based on the template we just added on the line before. I imagine the issue is that during an upgrade we get a 400 error because the index already exists. Changing it to run head first and then PUT if that returns 404 would probably work.

@VLZZZ
Copy link
Contributor Author

VLZZZ commented Oct 8, 2024

@robholland You're right, I didn’t notice at all that the template is first added and then an index is created from the template.

I'll now update my PR to something like
curl --head --fail xxx || template && PUT index as you proposed

@VLZZZ
Copy link
Contributor Author

VLZZZ commented Oct 15, 2024

Hey, @robholland just checkin'
Do I need to rebase on master or we're good to proceed?
Also I see that lint-test is failing but as far as I see it's not related to my changes?

@robholland
Copy link
Contributor

Yes please rebase on master to get the CI fix, the error is indeed not your code.

@robholland robholland merged commit c862ed8 into temporalio:main Oct 17, 2024
3 checks passed
@quajones quajones mentioned this pull request Oct 24, 2024
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.

[Bug] Failed to validate ES index due to PUT request usage
2 participants