Skip to content

Commit

Permalink
Fix Fleet Kubernetes recipe and ES auth E2E failures (elastic#4944)
Browse files Browse the repository at this point in the history
* Unwrap ES client error before checking for APIError

* Pin Kubernetes integration to avoid new default for k8s proxy input setting

* PR fixes

* PR fixes
  • Loading branch information
david-kow authored Oct 13, 2021
1 parent 151a359 commit 3ef180c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ spec:
xpack.fleet.agents.fleet_server.hosts: ["https://fleet-server-agent-http.default.svc:8220"]
xpack.fleet.packages:
- name: kubernetes
version: latest
# pinning this version as the next one introduced a kube-proxy host setting default that breaks this recipe,
# see https://github.com/elastic/integrations/pull/1565 for more details
version: 0.14.0
xpack.fleet.agentPolicies:
- name: Default Fleet Server on ECK policy
is_default_fleet_server: true
Expand Down
13 changes: 7 additions & 6 deletions test/e2e/es/auth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ package es
import (
"bytes"
"context"
"errors"
"fmt"
"net/http"
"testing"
Expand Down Expand Up @@ -211,12 +212,12 @@ func postDocument(es esv1.Elasticsearch, k *test.K8sClient, user esclient.BasicA
return err
}
resp, err := esClient.Request(context.Background(), req)
if err != nil {
// the client wraps unexpected status codes in an APIError, but still returns the correct resp
// we want to ignore APIErrors here
if _, isWrappedAPIErr := err.(*esclient.APIError); !isWrappedAPIErr {
return err
}

// The client double wraps unexpected status codes in an fmt.wrapError and esclient.APIError,
// but still returns the correct resp. We want to ignore APIErrors here.
var apiError *esclient.APIError
if !errors.As(err, &apiError) {
return err
}
defer resp.Body.Close()
if resp.StatusCode != expectedStatusCode {
Expand Down

0 comments on commit 3ef180c

Please sign in to comment.