diff --git a/x-pack/elastic-agent/CHANGELOG.next.asciidoc b/x-pack/elastic-agent/CHANGELOG.next.asciidoc index 12d83e47e507..4f3b2c4dae16 100644 --- a/x-pack/elastic-agent/CHANGELOG.next.asciidoc +++ b/x-pack/elastic-agent/CHANGELOG.next.asciidoc @@ -86,6 +86,7 @@ - Migrate state on upgrade {pull}27825[27825] - Add "_monitoring" suffix to monitoring instance names to remove ambiguity with the status command. {issue}25449[25449] - Ignore ErrNotExists when fixing permissions. {issue}27836[27836] {pull}27846[27846] +- Snapshot artifact lookup will use agent.download proxy settings. {issue}27903[27903] {pull}27904[27904] ==== New features diff --git a/x-pack/elastic-agent/pkg/artifact/download/snapshot/downloader.go b/x-pack/elastic-agent/pkg/artifact/download/snapshot/downloader.go index acf6b32328f9..a08295ba49b6 100644 --- a/x-pack/elastic-agent/pkg/artifact/download/snapshot/downloader.go +++ b/x-pack/elastic-agent/pkg/artifact/download/snapshot/downloader.go @@ -7,9 +7,9 @@ package snapshot import ( "encoding/json" "fmt" - gohttp "net/http" "strings" + "github.com/elastic/beats/v7/libbeat/common/transport/httpcommon" "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/artifact" "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/artifact/download" "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/artifact/download/http" @@ -27,7 +27,7 @@ func NewDownloader(config *artifact.Config, versionOverride string) (download.Do } func snapshotConfig(config *artifact.Config, versionOverride string) (*artifact.Config, error) { - snapshotURI, err := snapshotURI(versionOverride) + snapshotURI, err := snapshotURI(versionOverride, config) if err != nil { return nil, fmt.Errorf("failed to detect remote snapshot repo, proceeding with configured: %v", err) } @@ -43,7 +43,7 @@ func snapshotConfig(config *artifact.Config, versionOverride string) (*artifact. }, nil } -func snapshotURI(versionOverride string) (string, error) { +func snapshotURI(versionOverride string, config *artifact.Config) (string, error) { version := release.Version() if versionOverride != "" { if strings.HasSuffix(versionOverride, "-SNAPSHOT") { @@ -52,8 +52,13 @@ func snapshotURI(versionOverride string) (string, error) { version = versionOverride } + client, err := config.HTTPTransportSettings.Client(httpcommon.WithAPMHTTPInstrumentation()) + if err != nil { + return "", err + } + artifactsURI := fmt.Sprintf("https://artifacts-api.elastic.co/v1/search/%s-SNAPSHOT/elastic-agent", version) - resp, err := gohttp.Get(artifactsURI) + resp, err := client.Get(artifactsURI) if err != nil { return "", err }