xcat2 / xcat-core

Code repo for xCAT core packages
Eclipse Public License 1.0
367 stars 172 forks source link

Support for dynamic groups in tables? #3449

Open kcgthb opened 7 years ago

kcgthb commented 7 years ago

Hi,

I'd like to know if there's any plan to support dynamic groups as the "node" attribute in tables, such as nodehm.

We create dynamic groups based on nodes' hardware characteristics, such as manufacturer and model (from the MTM node attribute), and we would like to specify different options for hardware management for each of those groups.

Thanks!

zet809 commented 7 years ago

Hi, @kcgthb , not exactly sure your requirement. How do you create the dynamic groups? Is it work for you to use 'chdef -t group = ...' to specify different attribute for different groups?

samveen commented 7 years ago

@kcgthb If I understand you correctly, is what you want a method to specify attributes on which nodes may be grouped auto-magically? (for example if a node has an attribute switch=VNDC-LSW-00101, then I want it to be part of a group VNRackA1)?

kcgthb commented 7 years ago

Dynamic groups

Well, we do use the "dynamic group" feature of xCAT. It's documented here: https://sourceforge.net/p/xcat/wiki/Node_Group_Support/#creating-a-dynamic-node-group

(I know it's an old page, but the feature still works, and better keep working... :))

We define dynamic groups in the nodegroup table, with entries like this:

#groupname,grouptype,members,membergroups,wherevals,comments,disable
"manuf:supermicro","dynamic","dynamic",,"mtm=~Supermicro",,

So all the nodes with the string "Supermicro" in their MTM attribute will be grouped in the manuf:supermicro group.

For instance, node sh-112-08 is a Supermicro node:

# lsdef -c  sh-112-08 -i mtm
sh-112-08: mtm=Supermicro:SYS-1028GQ-TR

And it's part of the dynamic group manuf:supermicro:

# nodels manuf:supermicro | grep sh-112-08
sh-112-08

Now, back to my original question, I would like to be able to use those dynamic groups as a key in other tables, alongside node names and static group names. For instance, in nodehm, I would like to be able to have:

#node,power,mgt,cons,termserver,termport,conserver,serialport,serialspeed,serialflow,getmac,cmdmapping,consoleondemand,comments,disable
"compute",,"ipmi","ipmi",,,,"0","115200",,,,,,
"manuf:supermicro",,"ipmi","ipmi",,,,"1","115200",,,,,,

where compute is a static group, and manuf:supermicro is a dynamic group.

Right now, the dynamic group entry seems to be silently ignored:

lsdef -c sh-112-08 -i mtm,groups,serialport
sh-112-08: groups=compute
sh-112-08: mtm=Supermicro:SYS-1028GQ-TR
sh-112-08: serialport=0

So my question: are dynamic groups supported a keys in other tables, and if not, what would it take to support them?

Thanks!

samveen commented 7 years ago

Ah. I think I understand the question now. Rephrasing the question: Is it possible to add support for setting inheritable attributes for dynamic groups?

Quoting from http://xcat-docs.readthedocs.io/en/stable/guides/admin-guides/basic_concepts/xcat_object/group.html

In xCAT, the definition of a static group has been extended to include additional attributes that would normally be assigned to individual nodes. When a node is part of a static group definition, it can inherit the attributes assigned to the group. This feature can make it easier to define and manage cluster nodes in that you can generally assign nodes to the appropriate group and then just manage the group definition instead of multiple node definitions. This feature is not supported for dynamic groups.

chenglch commented 7 years ago

Hi @kcgthb , I think dynamic group can be looked as a group tag which help select the nodes which match the condition string in the wherevals column of node group table.

chdef -t group -o consolegroup -d -w consoleondemand=yes
chdef -t group consolegroup cons=ipmi
Error: Can not assign attributes to dynamic node group 'consolegroup'.

Dynamic group do not work like the static group which accept the attribute definition and allow the node inherit the attribute from group. It is just a tag represent a collection of nodes and the node members can be changed automatically if the attribute of node is changed.

chdef consolegroup cons=ipmi
2 object definitions have been created or modified.

The changes take effect on the nodes instead of group.

From your example, manuf:supermicro is ignored as the dynamic group is not defined in the nodelist table like static group. To work around, a new static group can be added for the nodes. Continue the example for dynamic group consolegroup.

chdef -t group staticconsolegroup cons=ipmi serialspeed=115200
chdef consolegroup groups=conpute,staticconsolegroup
lsdef consolegroup -i serialspeed
Object name: s01r1b01
    serialspeed=115200
Object name: s01r1b02
    serialspeed=115200 
tabdump nodelist
#node,groups,status,statustime,appstatus,appstatustime,primarysn,hidden,updatestatus,updatestatustime,zonename,comments,disable
"s01r1b02","conpute,staticconsolegroup",,,,,,,,,,,
"s01r1b01","conpute,staticconsolegroup",,,,,,,,,,,

As the members of dynamic group maybe changed based on the node attribute, xCAT do not update the nodelist table like static group.

samveen commented 7 years ago

@chenglch How do I get a list of dynamic groups that a node qualifies for? That might make your suggested solution easier to work with.

I expect it isn't easily achievable

chenglch commented 7 years ago

@samveen, you are right, I think xcat has not provided a command or a option to find the dynamic groups from node. Maybe we can enhance lsdef <noderange> command to print the information for dynamic groups.

kcgthb commented 7 years ago

@chenglch Thanks for the suggestion. I would obviously prefer not to create any static group for this, because that's the whole point of having dynamic groups in the first place. :)

I understand that xCAT currently doesn't allow setting inheritable attributes for dynamic groups, but I think it would make a great addition. Dynamic groups allow to define sets of nodes based on specific properties, and it would only be natural to be able to define attributes based on those properties.

We routinely add nodes to our HPC cluster, from a large selection of vendors and models. We can't really create static groups for each of them and their properties, and add each node to all those static groups, that's not really manageable. When we add new nodes, we don't need to manually add them to static groups, their manufacturer is automatically inferred from their MTM property, and they get added to the right dynamic group. That's why dynamic groups is a very useful feature for us.

The only missing feature would be to be able to set inheritable properties for those dynamic groups, for instance to define that all Supermicro nodes use ttyS1 for their SoL console, while all Dell nodes use ttyS0.

Could we please consider this as a feature request?


BTW, the only way I found to list dynamic groups a node belongs to is the following highly inefficient loop (get the list of dynamic groups and for each of them, check if the node is in its members):

$ n=nodename
$ for g in $(lsdef -t group -w grouptype=dynamic | awk '{print $1}'); do 
    lsdef -c -t group $g -i members | awk -F= "/$n/ {print \$NF}" | grep -qw $n  &>/dev/null && echo $g
done

There probably are better ways.