Skip to content

Commit

Permalink
[ML] Modernize ML node detection
Browse files Browse the repository at this point in the history
Where possible we should now detect ML nodes by looking
for the ML node role rather than an attribute.

Sadly this is not possible in the YAML tests, as the
syntax doesn't support asserting that a list contains
a particular item without asserting on the entire list
contents. So in the YAML case we need to look for the
ml.machine_memory node attribute, as this is reliably
set on ML nodes but not other types of nodes.

After elastic#79622 is merged this closes elastic#79518
  • Loading branch information
droberts195 committed Oct 21, 2021
1 parent 1621c86 commit abf73e4
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 7 deletions.
1 change: 0 additions & 1 deletion x-pack/plugin/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ tasks.named("yamlRestTestV7CompatTransform").configure{ task ->
task.skipTest("vectors/50_vector_stats/Usage stats on vector fields", "not supported for compatibility")
task.skipTest("roles/30_prohibited_role_query/Test use prohibited query inside role query", "put role request with a term lookup (deprecated) and type. Requires validation in REST layer")
task.skipTest("ml/jobs_crud/Test create job with delimited format", "removing undocumented functionality")
task.skipTest("ml/jobs_get_stats/Test get job stats after uploading data prompting the creation of some stats", "https://github.com/elastic/elasticsearch/issues/79518")
task.skipTest("ml/datafeeds_crud/Test update datafeed to point to missing job", "behaviour change #44752 - not allowing to update datafeed job_id")
task.skipTest("ml/datafeeds_crud/Test update datafeed to point to different job", "behaviour change #44752 - not allowing to update datafeed job_id")
task.skipTest("ml/datafeeds_crud/Test update datafeed to point to job already attached to another datafeed", "behaviour change #44752 - not allowing to update datafeed job_id")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -619,12 +619,7 @@ public MachineLearning(Settings settings, Path configPath) {
protected XPackLicenseState getLicenseState() { return XPackPlugin.getSharedLicenseState(); }

public static boolean isMlNode(DiscoveryNode node) {
Map<String, String> nodeAttributes = node.getAttributes();
try {
return Long.parseLong(nodeAttributes.get(MACHINE_MEMORY_NODE_ATTR)) > 0;
} catch (NumberFormatException e) {
return false;
}
return node.getRoles().contains(DiscoveryNodeRole.ML_ROLE);
}

public List<Setting<?>> getSettings() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ setup:
- match: { jobs.0.state: opened }
- is_true: jobs.0.node.name
- is_true: jobs.0.node.transport_address
- is_true: jobs.0.node.attributes.ml\.machine_memory
- is_true: jobs.0.open_time
- match: { jobs.0.timing_stats.job_id: job-stats-test }
- match: { jobs.0.timing_stats.bucket_count: 1 } # Records are 1h apart and bucket span is 1h so 1 bucket is produced
Expand Down

0 comments on commit abf73e4

Please sign in to comment.