-
Notifications
You must be signed in to change notification settings - Fork 124
Merging ingestmanager client into generic kibana client #210
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
Conversation
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.
Thank you for working on this. Apart from system tests, the part that can be tested only manually is export dashboards
(as it uses the kibana client).
I'm worried about the failed Jenkins job:
[2020-12-30T00:43:26.104Z] Error: error running package system tests: could not complete test run: could not create test policy: could not create policy; API status code = 404; response body = {"statusCode":404,"error":"Not Found","message":"Not Found"}
I wonder if there was something missed during refactoring.
@@ -180,25 +180,25 @@ func (r *runner) run() ([]testrunner.TestResult, error) { | |||
} | |||
|
|||
// Step 2. Configure package (single data stream) via Ingest Manager APIs. | |||
im, err := ingestmanager.NewClient(r.stackSettings.kibana.host, r.stackSettings.elasticsearch.username, r.stackSettings.elasticsearch.password) |
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.
I admit that I didn't analyze the source deeper, but are these Kibana/ES properties still required in stack settings.
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.
Good catch, these are not required any more. Removed in 32fe1b2.
Type: ds.Type, | ||
Dataset: fmt.Sprintf("%s.%s", pkg.Name, ds.Name), | ||
}, | ||
}, | ||
} | ||
|
||
// Add dataStream-level vars | ||
dsVars := ingestmanager.Vars{} | ||
dsVars := kibana.Vars{} |
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.
Thinking loud (nothing to be done immediately): The Vars
structure may look to be a generic one. It may happen in the future that we need to handle another Vars
structure, so some of these structs will require a relevant prefix added to their names.
internal/kibana/policies.go
Outdated
@@ -52,7 +52,7 @@ func (c *Client) CreatePolicy(p Policy) (*Policy, error) { | |||
func (c *Client) DeletePolicy(p Policy) error { | |||
reqBody := `{ "agentPolicyId": "` + p.ID + `" }` | |||
|
|||
statusCode, respBody, err := c.post("agent_policies/delete", []byte(reqBody)) | |||
statusCode, respBody, err := c.post("/api/fleet/agent_policies/delete", []byte(reqBody)) |
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.
What do you think about extracting all URL prefixes to the common place? I know it's an improvement comparing to what we have now.
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.
Sure, but just want to clarify what you mean by URL prefixes: just the /api/fleet
part (and similar prefixes from other API URLs) or something more?
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.
Yes, I meant exactly that: '/api/fleet' or '/api/saved_objects' etc. Just to prevent missing mappings in the future (because they were hidden in multiple places in the source).
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.
Done in 17ab10c.
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.
Changes look good to me. I'm worried about the CI job output that revealed a couple of unknown errors: https://beats-ci.elastic.co/blue/organizations/jenkins/Ingest-manager%2Felastic-package/detail/PR-210/6/pipeline
Would you mind looking at them?
@@ -52,7 +52,7 @@ func (c *Client) CreatePolicy(p Policy) (*Policy, error) { | |||
func (c *Client) DeletePolicy(p Policy) error { | |||
reqBody := `{ "agentPolicyId": "` + p.ID + `" }` | |||
|
|||
statusCode, respBody, err := c.post("agent_policies/delete", []byte(reqBody)) | |||
statusCode, respBody, err := c.post(fmt.Sprintf("%s/agent_policies/delete", FleetAPI), []byte(reqBody)) |
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.
nit: Hm.. I'm wondering if it's not better to extract also the resource part (agent_policies, package_policies) as they appear in multiple places. Once it's changed, I think you can switch from fmt.Sprintf
to a simple concatenation (URL prefix + operation).
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.
I think it's more readable this way, actually. And while the prefixes are more likely to change (due to project name changes, etc.), I think the resource paths are less likely to change. So I would prefer to keep it as-is.
internal/kibana/prefixes.go
Outdated
|
||
const ( | ||
// CoreAPI is the prefix for all Kibana Core API resources. | ||
CoreAPI = "/api/kibana" |
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.
WDYT about renaming it to api.go
or url_prefixes.go
? Prefixes sounds a bit vague.
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.
Done in 93223e5.
It seems to be an unnecessary
You can leave as is or cleanup the test output - up to you :) It means that the problem is:
|
7cb110e
to
7ce568b
Compare
Removed in 7ce568b. |
93223e5
to
f9e7faa
Compare
When the system tests feature was added to
elastic-package
, we created a client to communicate with the Kibana Ingest Manager API,ingestmanager.Client
. Some time later, we created a more general Kibana client to communicate with the Kibana Saved Objects and Dashboard Export APIs,kibana.Client
.It makes sense to combine these two clients into one, as noted in #168 (comment). This PR attempts to do so.