-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Adding sandbox schema #13669
base: main
Are you sure you want to change the base?
Adding sandbox schema #13669
Conversation
Signed-off-by: Kaushal Kumar <ravi.kaushal97@gmail.com>
…odes Signed-off-by: Kaushal Kumar <ravi.kaushal97@gmail.com>
Signed-off-by: Kaushal Kumar <ravi.kaushal97@gmail.com>
Signed-off-by: Kaushal Kumar <ravi.kaushal97@gmail.com>
Signed-off-by: Kaushal Kumar <ravi.kaushal97@gmail.com>
Signed-off-by: Kaushal Kumar <ravi.kaushal97@gmail.com>
Signed-off-by: Kaushal Kumar <ravi.kaushal97@gmail.com>
Signed-off-by: Kaushal Kumar <ravi.kaushal97@gmail.com>
Signed-off-by: Kaushal Kumar <ravi.kaushal97@gmail.com>
Signed-off-by: Kaushal Kumar <ravi.kaushal97@gmail.com>
Signed-off-by: Kaushal Kumar <ravi.kaushal97@gmail.com>
Signed-off-by: Kaushal Kumar <ravi.kaushal97@gmail.com>
Signed-off-by: Kaushal Kumar <ravi.kaushal97@gmail.com>
Signed-off-by: Kaushal Kumar <ravi.kaushal97@gmail.com>
❌ Gradle check result for c7e56f4: FAILURE Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change? |
* { | ||
* "analytics":{ | ||
* "jvm": 0.4, | ||
* "mpde": "enforced", |
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.
nit: typo, spacing. Although, I like this much better than the previous one. Wondering if the key should be name or id?
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.
I think either is fine but I agree _id makes more sense
* Class to define the ResourceLimitGroup schema | ||
* { | ||
* "analytics":{ | ||
* "jvm": 0.4, |
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.
This looks inconsistent with the class attributes below. jvm
should be within resourceLimits?
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.
It is not inconsistent, the resourceLimits in the code are modeled using map but the toXContent
method will just add the attributes of the resource limits plain and simple.
Objects.requireNonNull(_id, "ResourceLimitGroup._id can't be null"); | ||
|
||
if (name.length() > MAX_CHARS_ALLOWED_IN_NAME) { | ||
throw new IllegalArgumentException("ResourceLimitGroup.name shouldn't be more than 50 chars long"); |
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.
nit: can use variable here rather than static constant (50) in case we change this in the future
Objects.requireNonNull(resourceName, "resourceName can't be null"); | ||
Objects.requireNonNull(threshold, "resource value can't be null"); | ||
|
||
if (Double.compare(threshold, 1.0) > 0) { |
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.
nit: do we need a constant for 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.
This is standard comparator return values in cases where first arg in the comparator is greater than second one
|
||
String fieldName = ""; | ||
// Map to hold resources | ||
final Map<String, Object> resourceLimitGroup_ = new HashMap<>(); |
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.
Curious why this naming with "_" suffix here, is this some sort of convention?
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.
No since this is local to the method, I went ahead with this.
} else if (ALLOWED_RESOURCES.contains(fieldName)) { | ||
resourceLimitGroup_.put(fieldName, parser.doubleValue()); | ||
} else { | ||
throw new IllegalArgumentException("unrecognised [field=" + fieldName + " in ResourceLimitGroup"); |
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.
Need to add a closed bracked ]
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.
Good Catch! thanks
@ExperimentalApi | ||
public class ResourceLimitGroupMetadata implements Metadata.Custom { | ||
public static final String TYPE = "resourceLimitGroup"; | ||
private static final ParseField RESOURCE_LIMIT_GROUP_FIELD = new ParseField("resourceLimitGroups"); |
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.
"resourceLimitGroup"
?
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 metadata will contain all the ResourceLimitGroups in the cluster.
Signed-off-by: Kaushal Kumar <ravi.kaushal97@gmail.com>
❌ Gradle check result for bd1f864: FAILURE Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change? |
Signed-off-by: Kaushal Kumar <ravi.kaushal97@gmail.com>
❌ Gradle check result for 9119813: FAILURE Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change? |
* } | ||
*/ | ||
@ExperimentalApi | ||
public class ResourceLimitGroup extends AbstractDiffable<ResourceLimitGroup> implements ToXContentObject { |
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.
Considering name
below signifies a tenant, putting this inside ResourceLimitGroup looks confusing. I think it will help by decoupling tenant and resource logic like below?
class Tenant {
private String tenantName;
private String tenantId;
private List<ResourceLimitGroup> resourceLimitGroups;
// Can be extended with more details later if needed like tenant attributes etc.
}
class ResourceLimitGroup {
String resourceName;
ResourceLimitGroupMode mode;
Double threshold;
// etc etc
}
Let me know what you think.
Description
This change introduces the fundamental construct which we will use to enforce node level resiliency as part of this RFC: #12342.
Related Issues
RFC
Check List
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.