Skip to content

Capacity Scheduler View: tolerant node label response parsing#4150

Open
sanrajbandre wants to merge 1 commit into
apache:trunkfrom
sanrajbandre:capacity-scheduler-node-label-response-fix
Open

Capacity Scheduler View: tolerant node label response parsing#4150
sanrajbandre wants to merge 1 commit into
apache:trunkfrom
sanrajbandre:capacity-scheduler-node-label-response-fix

Conversation

@sanrajbandre

Copy link
Copy Markdown
Contributor

Problem

QueueAdapter#getNodeLabels (contrib/views/capacity-scheduler UI) assumes the
ResourceManager node-label response is always a JSON string and selects the
response shape from the stack version. stackVersion >= 2.5 is unreliable
because Number("3.2.0") is NaN, so 3-part versions silently take the legacy
branch and mis-parse labels. It also does not tolerate a nodeLabelsInfo
wrapper, a single nodeLabelInfo object, a legacy nodeLabels object entry, or
string exclusivity.

Fix

Extract normalization into QueueAdapter#parseNodeLabels:

  • parse only when the response is a string; accept an already-parsed object
  • unwrap an optional nodeLabelsInfo wrapper
  • support nodeLabelInfo (array or single object) and legacy nodeLabels
  • coerce exclusivity to a Boolean (true / "true" -> true)
  • derive the shape from the payload, not the stack version

isNodeLabelsConfiguredByRM semantics are unchanged.

Tests

Adds test/unit/adapters/adapters_test.js covering wrapper, JSON string, array,
single-object, legacy string/object, boolean/string exclusivity, malformed JSON,
and empty-response cases.

JIRA

AMBARI-XXXXX — account approval pending; I'll update the title and this link once the key is assigned.

getNodeLabels assumed the ResourceManager node-label response was always a
JSON string and chose the response shape from the stack version. That check
(stackVersion >= 2.5) is unreliable: Number('3.2.0') is NaN, so 3-part
versions silently fell through to the legacy branch.

Extract normalization into QueueAdapter#parseNodeLabels, which:
- parses only when the response is a string; accepts an already-parsed object
- unwraps an optional nodeLabelsInfo wrapper
- supports nodeLabelInfo (array or single object) and legacy nodeLabels
- coerces exclusivity to a Boolean (true / "true" -> true)
- derives the shape from the payload, not the stack version

isNodeLabelsConfiguredByRM semantics are unchanged. Adds unit tests covering
wrapper, JSON string, array, single-object, legacy, boolean/string
exclusivity, malformed JSON, and empty responses.
@francis9527

Copy link
Copy Markdown

https://apache-ambari.com/dist/ambari/3.0.0/rocky9/ 这个不能下载了,有没有其他地址

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants