Skip to content

Conversation

@iceiilin
Copy link
Member

Implement full function about deleting nodes and update its related ones based on "relations" field in nodes/ document. It is invoked by ODR-314 (https://hwjiraprd01.corp.emc.com/browse/ODR-314) requiring removing compute nodes in an enclosure when user asks to delete that enclosure node.

Currently there is only (enclosedBy, encloses) relation in node, but it is easily extensible to cover other relations such as (powers, powerBy) or (compute node use dae, dae used by compute node). When deleting one node, RackHD should also delete or update its corresponding nodes in different conditions.

There are 3 types of operations to deal with corresponding (I call it "target node" in code and here) nodes:

  • delete all target nodes.
    e.g. delete enclosure node -> delete compute node as well
  • delete target nodes when it doesn't have other targets in this relation.
    e.g. delete compute node -> delete enclosure node if this enclosure doesn't have other compute node
  • update relation in target node.
    e.g. delete compute node -> update relations in pdu node

This PR covers all cases above. constants.js in on-core defines mapping table and supported target operations. node-api-service in this PR reads this setting and manipulates database. The required nodes will be deleted only after all its target nodes have been processed successfully.

related PR:
RackHD/on-core#55

Choose a reason for hiding this comment

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

'_' is not defined.

@iceiilin
Copy link
Member Author

Codes uses new constants defined in on-core (PR RackHD/on-core#55). The success of unit test depends on it. PR RackHD/on-core#55 would be merged to master first and rerun the test here.

Copy link
Contributor

Choose a reason for hiding this comment

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

what does "ds" mean?

Copy link
Member Author

Choose a reason for hiding this comment

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

DsNodes = downstream nodes, I stated the latter in PR description and the doc for this function.

Copy link
Contributor

Choose a reason for hiding this comment

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

I prefer to use "downstream" instead of the short name "ds" though it is a long word. "ds" is not a conventional abbreviation.

Copy link
Member Author

Choose a reason for hiding this comment

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

I have thought the name a lot before when coding, and got to know from HW engineer that "downstream port" is abbreviated as "DSP", thus I chose the variable name here as it is now (ds). But now it seems that it still brings confusion, changing the function name to "downstream" for clear understanding and keeping the local variable as "ds" for direct use might be good choice.

@iceiilin
Copy link
Member Author

@yyscamper @anhou I rename all "downstream" to "target" node to make it clearer.

Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't be Promise.resolve() ?

Copy link
Contributor

Choose a reason for hiding this comment

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

Should the word "Downstream" be modified as now you have all changed it to "Target"?

@benbp
Copy link
Contributor

benbp commented Jan 5, 2016

I know it's a pain, but could you add a _ = helper.injector.get('_') (and the subsequent var _ at the top) to the nodes-api-spec.js file? I removed _ from the globals exceptions in the .jshintrc, because hound-ci won't let us use a separate spec file for test. Since that's the case, I don't want the linter to treat _ as global in non-test code.

@iceiilin iceiilin force-pushed the bugfix/odr-314-del-encl branch from 788a938 to 99d4827 Compare January 6, 2016 05:36

Choose a reason for hiding this comment

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

'before' is not defined.

@iceiilin
Copy link
Member Author

iceiilin commented Jan 6, 2016

@benbp done for adding local '_' in unittest

@yyscamper
Copy link
Contributor

This should be the top 1 PR with highest number of comment :)
👍

@anhou
Copy link
Member

anhou commented Jan 7, 2016

👍

anhou pushed a commit that referenced this pull request Jan 7, 2016
@anhou anhou merged commit 4eb9cb5 into RackHD:master Jan 7, 2016
@iceiilin iceiilin deleted the bugfix/odr-314-del-encl branch September 4, 2017 07:46
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.

7 participants