Skip to content
This repository was archived by the owner on Nov 5, 2021. It is now read-only.
This repository was archived by the owner on Nov 5, 2021. It is now read-only.

httpRequestForTarget stripping out port when setting Req.Host #365

Description

@robertcankney

The below probe is trying to connect on port 80 - as evidenced in the below log snippet (internal host names redacted):

probe {
  name: "test-probe"
  type: HTTP
  interval_msec: 15000

  targets {
    # RDS (resource discovery service) targets 
      host_names: "internal_host1,internal_host12,internal_host3,internal_host4"
  }
  
  http_probe {
    resolve_first: true
    relative_url: "/service-bus"
    port: 8080
  }
}

W0214 20:10:26.962758 216 http.go:212] Target:internal_host3, URL:http://internal_ip3:8080/service-bus, http.doHTTPRequest: Get http://internal_host3/service-bus/: dial tcp internal_ip3:80: connect: connection refused

This appears to be due to https://github.com/google/cloudprober/blob/master/probes/http/request.go#L75, which is setting the Req.Host field to the Target.Name (sans port), which is then being used in https://golang.org/src/net/http/client.go#L569 to overwrite the host from the URL, which had the correct port.

Metadata

Metadata

Assignees

Labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions