-
Notifications
You must be signed in to change notification settings - Fork 12.1k
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
Plugins: Fix colon in CallResource URL returning an error when creating plugin resource request #79746
Conversation
url.Parse() does not handle the given input correctly when the input contains a colon character. The user will see the following error message when trying to use remote cluster in Elasticsearch: ``` level=warn msg="Failed for create plugin resource request" error="parse \"foo-*,*:foo-*/_mapping\": first path segment in URL cannot contain colon" traceID= ``` As far as I can tell, we only want to set the path here + rawquery so avoid url.Parse() altogether.
@zserge @mildwonkey @idafurjes anyone? |
@grafana/backend-platform could you please review as this will fix issue with Elasticsearch data source and cross-cluster search which is currently broken #79745. |
This PR must be merged before a backport PR will be created. |
1 similar comment
This PR must be merged before a backport PR will be created. |
Hi and thank you for your contribution! From a I have also merged the latest However, if I try to reproduce the original issue described in #79745 (adding an Elasticsearch datasource with
This is because the Elasticsearch plugin itself uses grafana/pkg/tsdb/elasticsearch/elasticsearch.go Lines 210 to 214 in 0cf6b94
So this would need to be changed as well. Alternatively, I would also consider using a POST request instead, and putting the index name in the body rather than in the URL. |
Elastic API expects |
Thanks for testing out and seeing if this helps, I had a hard time running Grafana on my computer so I couldn't test thoroughly if this PR is the only one that needs to be merged for fixing the original problem. 🙇 I am deeply grateful for your work |
Another option could be encoding the index name in base64 so it's url-safe. If we decide to keep the current request, this PR makes sense to me from a |
Can we URL encode the index before making the request or doesn't matter? Don't you have to do that before calling the ES mapping endpoint as well?
Think this make sense, but curious why we used |
I tried encoding with https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURIComponent but it doesn't work and returns the same error
|
I tried
I can add a test case for query params, I tested those manually and they were working fine but a test case is definitely a good idea 👍 |
Was curious and backtracked the introduction of this code from 3,5 years ago and of course by me 5b951c7 #25472 😅 No tests or anything so hard to tell why exactly I added it, but I guess I realized somehow query parameters was not forwarded correctly. grafana/pkg/plugins/backendplugin/manager.go Lines 281 to 292 in c0f3b29
|
I have added more tests to ensure query parameters are forwarded correctly |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@ivanahuckova CI is now passing and we can merge. I don't think this requires backporting (not a critical bugfix), WDYT? |
+1 |
@ivanahuckova PR is now merged. You can now make the required changes in the Elasticsearch plugin to handle colons on the plugin's side 🥳 |
url.Parse() does not handle the given input correctly when the input contains a colon character. The user will see the following error message when trying to use remote cluster in Elasticsearch:
As far as I can tell, we only want to set the path here + rawquery so avoid url.Parse() altogether.
What is this feature?
N/A
Why do we need this feature?
N/A
Who is this feature for?
N/A
Which issue(s) does this PR fix?:
Fixes #79745
Special notes for your reviewer:
Please check that: