Skip to content

Fix diagnostic requests when scheme is not included in host#4765

Merged
jsoriano merged 2 commits intoelastic:mainfrom
jsoriano:es-diagnostic-protocol
Apr 7, 2025
Merged

Fix diagnostic requests when scheme is not included in host#4765
jsoriano merged 2 commits intoelastic:mainfrom
jsoriano:es-diagnostic-protocol

Conversation

@jsoriano
Copy link
Member

@jsoriano jsoriano commented Apr 3, 2025

What is the problem this PR solves?

Hosts in the Elasticsearch output are usually set without their scheme, in that case DiagRequests was not correctly parsing the URL, and errors like the following ones appear in the fleet-server-output-request.txt file in diagnostics:

2025/03/12 13:02:45.560990 No TLS settings
2025/03/12 13:02:45.560994 Proxy disable=false url=<nil>
2025/03/12 13:02:45.561027 Request 0 to somehost:2143 starting
2025/03/12 13:02:45.561049 request 0 error: unsupported protocol scheme "somehost"
Unable to transform host "127.0.0.1:37603" to url.URL: parse "127.0.0.1:37603": first path segment in URL cannot contain colon
error: 0 requests

How does this PR solve the problem?

Instead of parsing the URL and try to add the scheme later, use the makeURL helper, that already takes these cases into account.

How to test this PR locally

Check fleet-server diagnostics.

Design Checklist

  • I have ensured my design is stateless and will work when multiple fleet-server instances are behind a load balancer.
  • I have or intend to scale test my changes, ensuring it will work reliably with 100K+ agents connected.
  • I have included fail safe mechanisms to limit the load on fleet-server: rate limiting, circuit breakers, caching, load shedding, etc.

Checklist

  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have made corresponding change to the default configuration files
  • I have added tests that prove my fix is effective or that my feature works
  • I have added an entry in ./changelog/fragments using the changelog tool
Hosts in the elasticsearch output are usually set without their scheme,
in that case DiagRequests was not correctly parsing the URL.

Use the makeURL helper to build the URL to use for the diagnostics.
@jsoriano jsoriano self-assigned this Apr 3, 2025
@jsoriano jsoriano requested a review from a team as a code owner April 3, 2025 15:00
@mergify
Copy link
Contributor

mergify bot commented Apr 3, 2025

This pull request does not have a backport label. Could you fix it @jsoriano? 🙏
To fixup this pull request, you need to add the backport labels for the needed
branches, such as:

  • backport-./d./d is the label to automatically backport to the 8./d branch. /d is the digit
  • backport-active-all is the label that automatically backports to all active branches.
  • backport-active-8 is the label that automatically backports to all active minor branches for the 8 major.
  • backport-active-9 is the label that automatically backports to all active minor branches for the 9 major.
@jsoriano jsoriano added backport-8.18 Automated backport to the 8.18 branch backport-9.0 Automated backport to the 9.0 branch backport-active-9 Automated backport with mergify to all the active 9.[0-9]+ branches backport-active-8 Automated backport with mergify to all the active 8.[0-9]+ branches and removed backport-8.18 Automated backport to the 8.18 branch backport-9.0 Automated backport to the 9.0 branch labels Apr 3, 2025
@pierrehilbert pierrehilbert added the Team:Elastic-Agent-Control-Plane Label for the Agent Control Plane team label Apr 4, 2025
@jsoriano jsoriano merged commit eceaa42 into elastic:main Apr 7, 2025
9 checks passed
@jsoriano jsoriano deleted the es-diagnostic-protocol branch April 7, 2025 16:18
mergify bot pushed a commit that referenced this pull request Apr 7, 2025
Hosts in the elasticsearch output are usually set without their scheme,
in that case DiagRequests was not correctly parsing the URL.

Use the makeURL helper to build the URL to use for the diagnostics.

(cherry picked from commit eceaa42)
mergify bot pushed a commit that referenced this pull request Apr 7, 2025
Hosts in the elasticsearch output are usually set without their scheme,
in that case DiagRequests was not correctly parsing the URL.

Use the makeURL helper to build the URL to use for the diagnostics.

(cherry picked from commit eceaa42)
mergify bot pushed a commit that referenced this pull request Apr 7, 2025
Hosts in the elasticsearch output are usually set without their scheme,
in that case DiagRequests was not correctly parsing the URL.

Use the makeURL helper to build the URL to use for the diagnostics.

(cherry picked from commit eceaa42)
mergify bot pushed a commit that referenced this pull request Apr 7, 2025
Hosts in the elasticsearch output are usually set without their scheme,
in that case DiagRequests was not correctly parsing the URL.

Use the makeURL helper to build the URL to use for the diagnostics.

(cherry picked from commit eceaa42)
jsoriano added a commit that referenced this pull request Apr 8, 2025
…4771)

Hosts in the elasticsearch output are usually set without their scheme,
in that case DiagRequests was not correctly parsing the URL.

Use the makeURL helper to build the URL to use for the diagnostics.

(cherry picked from commit eceaa42)

Co-authored-by: Jaime Soriano Pastor <jaime.soriano@elastic.co>
jsoriano added a commit that referenced this pull request Apr 8, 2025
…4772)

Hosts in the elasticsearch output are usually set without their scheme,
in that case DiagRequests was not correctly parsing the URL.

Use the makeURL helper to build the URL to use for the diagnostics.

(cherry picked from commit eceaa42)

Co-authored-by: Jaime Soriano Pastor <jaime.soriano@elastic.co>
jsoriano added a commit that referenced this pull request Apr 8, 2025
…4773)

Hosts in the elasticsearch output are usually set without their scheme,
in that case DiagRequests was not correctly parsing the URL.

Use the makeURL helper to build the URL to use for the diagnostics.

(cherry picked from commit eceaa42)

Co-authored-by: Jaime Soriano Pastor <jaime.soriano@elastic.co>
jsoriano added a commit that referenced this pull request Apr 15, 2025
…4774)

Hosts in the elasticsearch output are usually set without their scheme,
in that case DiagRequests was not correctly parsing the URL.

Use the makeURL helper to build the URL to use for the diagnostics.

(cherry picked from commit eceaa42)

Co-authored-by: Jaime Soriano Pastor <jaime.soriano@elastic.co>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport-active-8 Automated backport with mergify to all the active 8.[0-9]+ branches backport-active-9 Automated backport with mergify to all the active 9.[0-9]+ branches Team:Elastic-Agent-Control-Plane Label for the Agent Control Plane team

3 participants