-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Support dynamic node role #3436
Changes from 3 commits
433a196
4cb8dac
2f2df16
4245543
a2fea20
836be1f
5101c9a
6e286c1
8e2f2d8
81d0d60
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -567,10 +567,10 @@ private static Map<String, DiscoveryNodeRole> rolesToMap(final Stream<DiscoveryN | |
private static Map<String, DiscoveryNodeRole> roleMap = rolesToMap(DiscoveryNodeRole.BUILT_IN_ROLES.stream()); | ||
|
||
public static DiscoveryNodeRole getRoleFromRoleName(final String roleName) { | ||
if (roleMap.containsKey(roleName) == false) { | ||
throw new IllegalArgumentException("unknown role [" + roleName + "]"); | ||
if (roleMap.containsKey(roleName)) { | ||
return roleMap.get(roleName); | ||
} | ||
return roleMap.get(roleName); | ||
return new DiscoveryNodeRole.UnknownRole(roleName, roleName, false); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It seems we should not use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks. Good point. As we support dynamic/custom roles, it will be hard to differentiate There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh, I think we should keep
|
||
} | ||
|
||
public static Set<DiscoveryNodeRole> getPossibleRoles() { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
*/ | ||
|
||
package org.opensearch.cluster.node; | ||
|
||
public class DiscoveryNodeRoleGenerator { | ||
|
||
public static DiscoveryNodeRole createUnknownRole(String roleName) { | ||
return new DiscoveryNodeRole.UnknownRole(roleName, roleName, false); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we remove this generator , we need to make the This generator is only for testing. How about we keep this? |
||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While experimenting, run into interesting issue: the role name are case-sensitive, for example:
Are 2 different roles. In general, it was fine, OpenSearch would refuse to start because
Master
was not recognized as a valid role. You may already see where I am going: with the dynamic roles, such set of roles becomes totally valid and confusing:I think we should be a bit more strict now with the way roles are treated and checks should be case-insensitive: in the example above
master
andMaster
should be reduced to same rolemaster
. @ylwu-amzn wdyt?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ylwu-amzn can I have you look over this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The whole case-sensitive thing can be dealt with as a separate issue IMO.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, thanks for reminding. Busy with something else and missed this comment.
@reta that's a great point! I will make the code change to make role name case-insensitive.