Skip to content
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

Open
wants to merge 16 commits into
base: main
Choose a base branch
from

Conversation

kaushalmahi12
Copy link
Contributor

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

  • New functionality includes testing.
    • All tests pass
  • New functionality has been documented.
    • New functionality has javadoc added
  • API changes companion pull request created.
  • Failing checks are inspected and point to the corresponding known issue(s) (See: Troubleshooting Failing Builds)
  • Commits are signed per the DCO using --signoff
  • Commit changes are listed out in CHANGELOG.md file (See: Changelog)
  • Public documentation issue/PR created

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.

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>
Copy link
Contributor

❌ 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",
Copy link
Contributor

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?

Copy link
Contributor Author

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,
Copy link
Contributor

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?

Copy link
Contributor Author

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");
Copy link
Contributor

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) {
Copy link
Contributor

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?

Copy link
Contributor Author

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<>();
Copy link
Contributor

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?

Copy link
Contributor Author

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");
Copy link
Contributor

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 ]

Copy link
Contributor Author

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");
Copy link
Contributor

Choose a reason for hiding this comment

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

"resourceLimitGroup" ?

Copy link
Contributor Author

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>
Copy link
Contributor

❌ 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>
Copy link
Contributor

❌ 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 {
Copy link
Contributor

@sgup432 sgup432 May 28, 2024

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.

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.

None yet

4 participants