Skip to content
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

[ML] Make GetJobStats work with arbitrary wildcards and groups #36683

Merged
merged 7 commits into from Jan 29, 2019

Conversation

henriquegoncalves98
Copy link
Contributor

@henriquegoncalves98 henriquegoncalves98 commented Dec 16, 2018

Fixing match function to use expandedJobId instead of a single jobid.

Closes #34745

fixing match function to use expandedJobId instead of a single jobid
@cbuescher cbuescher added >bug :ml Machine learning labels Dec 16, 2018
@elasticmachine
Copy link
Collaborator

Pinging @elastic/ml-core

@henriquegoncalves98
Copy link
Contributor Author

henriquegoncalves98 commented Dec 17, 2018

In my commit instead of 'expandedJobsIds[i]' it's expandedJobsIds.get(i). All tests pass with the code submited. P.s:Already made a commit editing the mistake mention above.

Copy link
Member

@benwtrent benwtrent left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure what which tests @davidkyle was mentioning in the issue.

I know we have tests here: https://github.com/elastic/elasticsearch/blob/master/client/rest-high-level/src/test/java/org/elasticsearch/client/MachineLearningIT.java but those are more for ensuring the client acts correctly, not that the job stats are handled appropriately.

@@ -118,7 +118,12 @@ public boolean allowNoJobs() {

@Override
public boolean match(Task task) {
return OpenJobAction.JobTaskMatcher.match(task, jobId);
for(int i = 0; i < expandedJobsIds.size(); i++)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be reduced to a single line using stream().anyMatch

Suggested change
for(int i = 0; i < expandedJobsIds.size(); i++)
return expandedJobsIds.stream().anyMatch(jobId -> OpenJobAction.JobTaskMatcher.match(task, jobId));

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will commit the changes thx for the review!

@benwtrent
Copy link
Member

Jenkins test this please

@droberts195 droberts195 changed the title Closes issue #34745 [ML] Make GetJobStats work with arbitrary wildcards and groups Dec 17, 2018
@benwtrent
Copy link
Member

@up201608320 Thanks for taking a look at this issue. Looking at elasticsearch-ci-2 it seems that there is a yml test that is failing. I found the test failure by selecting the details link, looking at the full console output, and then searching the page for REPRODUCE (case sensitive). That turned up a yml test that is failing.

You can rerun these with:

./gradlew :x-pack:plugin:integTestRunner -Dtests.seed=E912E5024622B77D -Dtests.class=org.elasticsearch.xpack.test.rest.XPackRestIT -Dtests.method="test {p0=ml/job_groups/Test close job API}"

Relevant test is here:

I ran the test locally against master and it passed. So, either your change is causing the failure, or some past commit (that has since been corrected) caused the failure and you need to merge in the latest master into your branch.

Documentation on how the test formatting is here: https://github.com/elastic/elasticsearch/blob/master/rest-api-spec/src/main/resources/rest-api-spec/test/README.asciidoc

From what I can see, it is a simple re-ordering issue.

@davidkyle
Copy link
Member

davidkyle commented Dec 19, 2018

The failing test in job_groups.yml is because the response of GET job stats is not ordered by job id. Compare the 6.x branch https://github.com/elastic/elasticsearch/blob/6.x/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/action/TransportGetJobsStatsAction.java#L163

with master https://github.com/elastic/elasticsearch/blob/master/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/action/TransportGetJobsStatsAction.java#L151 where the call to Collections.sort is missing.

Actually this call is also missing from the master branch https://github.com/elastic/elasticsearch/blob/6.x/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/action/TransportGetJobsStatsAction.java#L100

I assume this change has somehow affected the ordering causing the tests to fail which is good as it has revealed an issue.

As for testing this change a unit test added to GetJobStatsActionRequestTests would be sufficient. There is already one test on the match function testMatch_GivenAll_FailsForNonJobTasks in that class. Note the function expects a Task parameter which implementsOpenJobAction.JobTaskMatcher, use TransportOpenJobAction.JobTask for this

@davidkyle
Copy link
Member

@up201608320 I raised #36841 to fix the ordering of the GET job stats response. Once that is merged please rebase your change on the master branch and the test failure will go away

@droberts195
Copy link
Contributor

@up201608320 #36841 is now merged. If you pull the latest master branch, then merge it into your PR branch then hopefully this PR will pass CI and can be merged.

@droberts195
Copy link
Contributor

Jenkins test this please

@droberts195
Copy link
Contributor

Jenkins run elasticsearch-ci/default-distro

1 similar comment
@droberts195
Copy link
Contributor

Jenkins run elasticsearch-ci/default-distro

@droberts195
Copy link
Contributor

Jenkins test this please

@droberts195
Copy link
Contributor

Jenkins test this please

Copy link
Member

@davidkyle davidkyle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@droberts195 droberts195 merged commit eceb318 into elastic:master Jan 29, 2019
droberts195 pushed a commit that referenced this pull request Jan 29, 2019
The /_ml/anomaly_detectors/{job}/_stats endpoint now
works correctly when {job} is a wildcard or job group.

Closes #34745
@colings86 colings86 removed the v7.0.0 label Feb 7, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants