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

[Feature] Enable prometheus metrics for local queues #2516

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

Conversation

varshaprasad96
Copy link
Member

What type of PR is this?

/kind feature
/kind documentation

What this PR does / why we need it:

This PR introduces an enhancement to enable collection of prometheus metrics for local queues.

Addresses issue: #1833

Which issue(s) this PR fixes:

Fixes # Partially #1833

Special notes for your reviewer:

Does this PR introduce a user-facing change?

NA

@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. kind/feature Categorizes issue or PR as related to a new feature. kind/documentation Categorizes issue or PR as related to documentation. labels Jul 2, 2024
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: varshaprasad96
Once this PR has been reviewed and has the lgtm label, please assign mimowo for approval. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Jul 2, 2024
This PR introduces an enhancement to enable collection of
prometheus metrics for local queues.

Addresses issue: kubernetes-sigs#1833

Signed-off-by: Varsha Prasad Narsing <varshaprasad96@gmail.com>
@k8s-ci-robot k8s-ci-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Jul 2, 2024
Copy link

netlify bot commented Jul 2, 2024

Deploy Preview for kubernetes-sigs-kueue canceled.

Name Link
🔨 Latest commit 15ef983
🔍 Latest deploy log https://app.netlify.com/sites/kubernetes-sigs-kueue/deploys/66963e842fe97000086a426f

@varshaprasad96
Copy link
Member Author

@astefanutti @alculquicondor @tenzen-y Could you please take a look at the proposal and provide your inputs. Thank you!

@alculquicondor
Copy link
Contributor

/assign @PBundyra

@PBundyra
Copy link
Contributor

PBundyra commented Jul 8, 2024

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jul 8, 2024
@k8s-ci-robot
Copy link
Contributor

LGTM label has been added.

Git tree hash: b3460149244f8070ae015034e8bba83771759ecc

@PBundyra
Copy link
Contributor

PBundyra commented Jul 8, 2024

/hold

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jul 8, 2024
@alculquicondor
Copy link
Contributor

is this ready for a pass from approvers?

@PBundyra
Copy link
Contributor

PBundyra commented Jul 9, 2024

is this ready for a pass from approvers?

Yes

@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jul 10, 2024
@k8s-ci-robot
Copy link
Contributor

New changes are detected. LGTM label has been removed.

Comment on lines 34 to 37
because they are global and cannot be filtered by namespaces. Furthermore, accessing cluster-scoped metrics
in secured Prometheus instances is generally restricted to cluster admin users with cluster level permissions across all namespaces and
tenants. This restriction makes it challenging for batch users to obtain the specific metrics they need for effective workload
management and to gain insights into their workloads within their limited scope of access.
Copy link
Contributor

Choose a reason for hiding this comment

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

Could this KEP also specify how we will prevent users with insufficient permission accessing metrics they shouldn't be able to?

Copy link
Contributor

Choose a reason for hiding this comment

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

If this proposal is not suggesting how to prevent access from namespaces that shouldn't have the permission, then I would remove this phrase.

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree, maybe we could narrow the scope of this KEP @varshaprasad96 ? At first glance managing permissions seems to be challenging, or it would require external mechanism

Copy link
Member Author

@varshaprasad96 varshaprasad96 Jul 12, 2024

Choose a reason for hiding this comment

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

Sorry for the late reply! I've been considering various options, and it's clear that publishing local queue metrics in each namespace could lead to complications. This approach would require multiple endpoints with respective Service Monitors or, if using a single central Service Monitor, we would need the correct RBAC setup to allow client access. The centralised approach could still poses some issues, such as namespace admins potentially being able to view metrics from other namespaces if not provided with right SA.

One potential solution for cluster admins is to scaffold out a Service Monitor (SM) with metrics labeling for specific namespaces from the same service endpoint. This would enable a common service endpoint for all local queues. Admins could then provide a service account with right RBAC to specific batch user, restricting their access to that particular service monitor.

However, this solution is difficult to implement in Kueue right away by figuring out the right set of scaffolds, and seems to be the responsibility of the cluster admin. This could probably be a customisation which can be documented for now.

That being said, given the complexity, this topic may probably warrant a further brainstorming and deserves a separate KEP. For now, I'll remove this reference and update it to indicate that for this iteration metrics will be exported in the controller namespace, alongside cluster queue metrics, at the same endpoint. Does that sound reasonable?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes it does.

You can remove the per-namespace topic from the motivation and add a note in non-goals.

keps/1833-metrics-for-local-queue/kep.yaml Show resolved Hide resolved
keps/1833-metrics-for-local-queue/kep.yaml Outdated Show resolved Hide resolved
keps/1833-metrics-for-local-queue/README.md Outdated Show resolved Hide resolved
keps/1833-metrics-for-local-queue/README.md Outdated Show resolved Hide resolved
keps/1833-metrics-for-local-queue/README.md Outdated Show resolved Hide resolved
keps/1833-metrics-for-local-queue/README.md Outdated Show resolved Hide resolved
keps/1833-metrics-for-local-queue/README.md Outdated Show resolved Hide resolved
Comment on lines 108 to 111
NamespaceSelector *metav1.LabelSelector `json:"namespaceSelector,omitempty"`

// QueueSelector can be used to choose the local queues that need metrics to be collected.
QueueSelector *metav1.LabelSelector `json:"queueSelector,omitempty"`
Copy link
Member

Choose a reason for hiding this comment

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

What happens if the below situations?

  1. only namespeceSelector is specified
  2. only localQueueSelector is specified
  3. both namespaceSelector and localQueueSelector are specified

Copy link
Member Author

@varshaprasad96 varshaprasad96 Jul 12, 2024

Choose a reason for hiding this comment

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

Had a predicate based filtering kind of approach for this case.

  1. Only NS selector: All LocalQueues in the specific namespaces are selected. If it's nil, all the local queues across all namespaces are considered.
  2. LocalQueue selector: Local queues's matching the labels are selected across all namespaces. If not, all the local queues across namespaces are considered.
  3. If both are specified: Both the selectors are applied to local queues (logical AND).

Had a Venn diagram in mind :)) Please let me know if I'm missing anything.

Copy link
Member Author

Choose a reason for hiding this comment

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

Have added a configuration table for this knob in the KEP.


In the first iteration, following are the list of metrics that would contain information on Local Queue statuses:

| Metrics Name | Prometheus Type | Description |
Copy link
Member

Choose a reason for hiding this comment

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

A part of the clusterqueue metrics is imported here like local_queue_status. Is there any reason that you want to drop a few metrics rather than clusterqueue ones?

Copy link
Member Author

Choose a reason for hiding this comment

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

Updated the list to contain all the local_queue relevant ones. One additional metric is the local_queue_wait_time_seconds which is a sum of admission and reserved wait time.

This commit addresses reviews by adding additional metrics
for local queue.

Signed-off-by: Varsha Prasad Narsing <varshaprasad96@gmail.com>
@varshaprasad96
Copy link
Member Author

@PBundyra @alculquicondor @tenzen-y I've updated the proposal based on the reviews. Please take a look when you get a chance. Thank you!

Comment on lines +119 to +120
| True | - | Specified | All LocalQueues matching the label selector have metrics enabled. |
| True | - | Specified | All LocalQueues matching the label selector have metrics enabled. |
Copy link
Contributor

Choose a reason for hiding this comment

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

Duplicated

| local_queue_admission_wait_time_seconds | Histogram | The time from when a workload got the quota reservation until admission in local queue. |
| local_queue_reserved_wait_time_seconds | Histogram | The time between a workload was created or re-queued until it got quota reservation in local queue. |
| local_queue_wait_time_seconds | Histogram | Time taken to accept the resources from cluster queue. |
| local_admission_checks_wait_time_seconds | Histogram | The time from when a workload got the quota reservation until admission. |
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you please clarify the differences between local_queue_admission_wait_time_seconds and local_admission_checks_wait_time_seconds? Maybe local_queue_admission_wait_time_seconds could describe time from creating (or requeueing) a Workload until admission - similarly to the clusterqueue metrics. In that case it would cover the local_queue_wait_time_seconds metric usage.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. kind/documentation Categorizes issue or PR as related to documentation. kind/feature Categorizes issue or PR as related to a new feature. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants