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

Add AdmissionController interface #3716

Closed
wants to merge 2 commits into from

Conversation

mitalawachat
Copy link

Signed-off-by: Mital Awachat awachatm@amazon.com

Description

This pull request serves as a starting point for Admission Control. In this pull request we are adding AdmissionController interface which will be fulfilled by concrete implementation in subsequent pull requests as mentioned in design proposal given below.

Issues Resolved

Feature Proposal: #1144
Design Proposal: #3400

Check List

  • [-] New functionality includes testing.
    • [-] All tests pass
  • New functionality has been documented.
    • New functionality has javadoc added
  • Commits are signed per the DCO using --signoff

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.

@mitalawachat mitalawachat requested review from a team and reta as code owners June 27, 2022 18:57
@opensearch-ci-bot
Copy link
Collaborator

✅   Gradle Check success 213ce6b51d023710f8732979a4cebcdce45c02fa
Log 6377

Reports 6377

Copy link
Collaborator

@nknize nknize left a comment

Choose a reason for hiding this comment

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

This interface needs to be included in a PR that implements it and includes some kind of tests. We don't merge PRs for unused interfaces. If this is a merge of a fairly large downstream implementation make sure it's split into smaller incremental PRs.

Also, we'll want to feature flag this so we can let it bake before releasing GA.

* Provides methods for any tracking-object that can be incremented (such as memory size),
* Admission control can be applied if configured limit has been reached.
*/
public interface AdmissionController {
Copy link
Collaborator

@nknize nknize Jun 28, 2022

Choose a reason for hiding this comment

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

Do we intend for plugins to be able to implement this interface? Can we make this package private?

If not please mark this with an appropriate opensearch annotation (@opensearch.internal, @opensearch.experimental, @opensearch.api) to document extensibility restrictions.

Copy link
Author

Choose a reason for hiding this comment

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

This interface needs to be included in a PR that implements it and includes some kind of tests. We don't merge PRs for unused interfaces. If this is a merge of a fairly large downstream implementation make sure it's split into smaller incremental PRs.

Also, we'll want to feature flag this so we can let it bake before releasing GA.

Thanks for the feedback @nknize

I planned to raise implementations as part of next pull-requests to keep scope of each pull-request smaller.

I will update this pull request with other suggested changes.

Copy link
Author

Choose a reason for hiding this comment

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

Do we intend for plugins to be able to implement this interface? Can we make this package private?

Made it package private as it is not intended for plugins to implement this interface.


Also, we'll want to feature flag this so we can let it bake before releasing GA.

Yes, this feature will be behind dynamic setting.

Copy link
Collaborator

@nknize nknize left a comment

Choose a reason for hiding this comment

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

Thanks for including the requested changes. But we do need to include this interface in a PR that implements it and includes some kind of tests. We don't merge PRs with unused interfaces. If this is a merge of a fairly large downstream implementation make sure it's split into smaller incremental PRs. Can you at least include this with some part of a mechanism that uses it?

@getsaurabh02
Copy link
Member

+1 on @nknize on having one of the implementations out before we merge just the interface. However, the only difficulty I see is that if we do as a separate followup PR, it will fail checks since interface is not yet available in the core.

@mitalawachat Can we have one of the smaller implementations added to this same PR. That will help validate the consistency and completeness of the Interface being added.

However, if it consists of bigger chunk of changes and we wish to break them up into multiple followup PRs, we should discuss the possibility of a feature-branch as well.

@github-actions
Copy link
Contributor

Gradle Check (Jenkins) Run Completed with:

@github-actions
Copy link
Contributor

Gradle Check (Jenkins) Run Completed with:

@github-actions
Copy link
Contributor

Gradle Check (Jenkins) Run Completed with:

@github-actions
Copy link
Contributor

Gradle Check (Jenkins) Run Completed with:

@mitalawachat mitalawachat requested a review from nknize July 18, 2022 23:43
Signed-off-by: Mital Awachat <awachatm@amazon.com>
Signed-off-by: Mital Awachat <awachatm@amazon.com>
@github-actions
Copy link
Contributor

Gradle Check (Jenkins) Run Completed with:


@Override
public String toString() {
return "AdmissionControlSetting{" + "name='" + name + '\'' + ", enabled=" + enabled + ", limit=" + limits + '}';
Copy link
Author

Choose a reason for hiding this comment

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

Will fix this along with review comments.

Comment on lines +54 to +65
/**
* @return current value of the rejection count metric tracked by the admission-controller.
*/
long getRejectionCount();

/**
* Adds the rejection count for the controller. Primarily used when copying controller states.
* @param count To add the value of the tracking resource object as the provided count
* @return count/value by which the resource tracking object is updated with.
*/
long addRejectionCount(long count);

Copy link
Collaborator

Choose a reason for hiding this comment

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

Can metric tracking be modelled as a listener

Comment on lines +56 to +60
@Override
public long setInitialQuota(long count) {
usedBytes.set(count);
return usedBytes.get();
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

do we need a reset? or can it called as a part of the constructor

@dreamer-89
Copy link
Member

@mitalawachat : Are you still working on this ?

@psychbot
Copy link
Member

psychbot commented Apr 3, 2023

We can mark this PR as closed as it requires additional discussion if Admission Control needs to be part of core or can it be a separate plugin all together.

@tlfeng tlfeng closed this Apr 5, 2023
*
* @opensearch.internal
*/
class AdmissionControlSetting {
Copy link
Contributor

Choose a reason for hiding this comment

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

We should allow each admission controller to bring their own settings, rather than enforcing this fixed format.

Comment on lines +31 to +64
/**
* Increment the tracking-object with provided value.
* Apply the admission control if threshold is breached.
* Mostly applicable while acquiring the quota.
* Later Releasable is used to decrement the tracking-object with previously acquired value.
*
* @param count value to incrementation the resource racking-object with.
* @return Releasable for tokens acquired from the resource tracking object.
*/
Releasable addBytesAndMaybeBreak(long count);

/**
* Sets the initial used quota for the controller. Primarily used when copying controller states.
* @param count To set the value of the tracking resource object as the provided count
* @return count/value by which the resource tracking object is updated with.
*/
long setInitialQuota(long count);

/**
* @return currently acquired value of the tracking-object being tracked by the admission-controller.
*/
long getUsedQuota();

/**
* @return current value of the rejection count metric tracked by the admission-controller.
*/
long getRejectionCount();

/**
* Adds the rejection count for the controller. Primarily used when copying controller states.
* @param count To add the value of the tracking resource object as the provided count
* @return count/value by which the resource tracking object is updated with.
*/
long addRejectionCount(long count);
Copy link
Contributor

Choose a reason for hiding this comment

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

I feel that these interface methods model each admission controller as a token-bucket, which is not always true. For example, an admission controller which only looks at the node's CPU/memory usage doesn't need to acquire/release any tokens.

* Admission Controllers
*/
public enum Controllers {
REQUEST_SIZE("RequestSize");
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure why this belongs here. We should make admission controllers pluggable.

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.

9 participants