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 system metrics support #97

Closed
wants to merge 3 commits into from

Conversation

Edwinhr716
Copy link
Contributor

@Edwinhr716 Edwinhr716 commented Apr 11, 2024

What type of PR is this?

/kind feature

What this PR does / why we need it

Which issue(s) this PR fixes

Fixes #87

Special notes for your reviewer

Does this PR introduce a user-facing change?

adding recreate_group_times, rolling_update_duration metrics, and replica_ready_status_duration

@k8s-ci-robot k8s-ci-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. kind/feature Categorizes issue or PR as related to a new feature. labels Apr 11, 2024
@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Apr 11, 2024
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: Edwinhr716
Once this PR has been reviewed and has the lgtm label, please assign ahg-g 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 needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Apr 11, 2024
@k8s-ci-robot
Copy link
Contributor

Hi @Edwinhr716. Thanks for your PR.

I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@k8s-ci-robot k8s-ci-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Apr 11, 2024
@kerthcet
Copy link
Contributor

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Apr 12, 2024
@ahg-g
Copy link
Contributor

ahg-g commented Apr 16, 2024

is this ready for review? asking because it is still marked as WIP

@Edwinhr716
Copy link
Contributor Author

Edwinhr716 commented Apr 16, 2024

not yet, currently working on adding a metric for latency for replicas to be scheduled and become ready, and also plan on adding unit tests

@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Apr 16, 2024
@Edwinhr716 Edwinhr716 changed the title [WIP] Adding system metrics support Adding system metrics support Apr 17, 2024
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Apr 17, 2024
@Edwinhr716
Copy link
Contributor Author

Done with most of it, PTAL. Only missing unit test for ReadyReplicaStatus but want to make sure the implementation looks good first

@liurupeng liurupeng requested a review from ahg-g April 17, 2024 22:59
}, []string{"leadername"},
)

replicaReadyStatusDuration = prometheus.NewHistogramVec(
Copy link
Collaborator

Choose a reason for hiding this comment

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

add a comment here about what is the metrics record, like "the latency for a pod group to be ready after creation"

Copy link
Collaborator

Choose a reason for hiding this comment

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

but overall, I start to think about whether it's necessary to have this metrics for now.

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 help attribute of the object describes what it records, but I can add a comment for it as well

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think we need such a metric. The time it takes for the pod to become ready is not a characteristic of the lws controller.


func ReplicaReadyStatus(readyPods []corev1.Pod, startTime metav1.Time) {
for _, pod := range readyPods {
readyTime := podutils.PodReadyConditionLastTransitionTime(pod).Time
Copy link
Collaborator

Choose a reason for hiding this comment

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

when the leader pod is ready, its worker statefulset may not be ready right? the latency here calculates the leader pods' latency to be ready

Copy link
Collaborator

Choose a reason for hiding this comment

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

we may need to pass the worker sts and leader pod as a pair and make sure that latency=worker_sts_ready-leader_pod_created, wdyt

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 LeaderPod is only added into the list that is passed if the worker sts is ready, that is checked here

I guess I'm a bit confused with what the replica latency measures, I thought it was from when the lws object was created/edited to when the replica is ready. So is it from when the leader statefulset is created to when the worker sts is ready?

@@ -569,3 +573,12 @@ func templateUpdated(sts *appsv1.StatefulSet, lws *leaderworkerset.LeaderWorkerS
func replicasUpdated(sts *appsv1.StatefulSet, lws *leaderworkerset.LeaderWorkerSet) bool {
return *sts.Spec.Replicas != *lws.Spec.Replicas
}

func getLastTransitionTime(conditionType string, lws *leaderworkerset.LeaderWorkerSet) metav1.Time {
Copy link
Collaborator

Choose a reason for hiding this comment

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

maybe move this to a util file?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Was thinking about that as well, can create an lws utils file similar to the one that exists for pods, and move this function, templateUpdated and replicasUpdated to it in a different PR.

@@ -389,6 +390,9 @@ func (r *LeaderWorkerSetReconciler) updateConditions(ctx context.Context, lws *l
updateCondition := setCondition(lws, condition)
// if condition changed, record events
if updateCondition {
if updatedCount == int(*lws.Spec.Replicas) {
metrics.ReplicaReadyStatus(readyLeaderPods, getLastTransitionTime(string(leaderworkerset.LeaderWorkerSetProgressing), lws))
Copy link
Collaborator

Choose a reason for hiding this comment

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

the start time here is when the lws just progress, there might be a possibility that the leader pod is not scheduled.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Asked a similar question in other comment: what is the replica latency actually measuring? I thought it was from lws creation to when the replica is ready

}, []string{"hash"},
)

recreateGroupTimes = prometheus.NewCounterVec(
Copy link
Collaborator

Choose a reason for hiding this comment

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

this is not called anywhere else right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, adding it to register it, but waiting on #106 to implement it.

Copy link
Contributor

@ahg-g ahg-g left a comment

Choose a reason for hiding this comment

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

I don't know if we really need to add our own metrics at this stage, I would focus on making sure that we are getting the metrics that controller-runtime publishes by default; see https://book.kubebuilder.io/reference/metrics-reference

Those metrics cover a lot of what we need already for monitoring the health of the operator, like how long a reconcile call takes, and I think the first PR should focus on that only and it should be included in the 0.2.0 release.

}, []string{"leadername"},
)

replicaReadyStatusDuration = prometheus.NewHistogramVec(
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think we need such a metric. The time it takes for the pod to become ready is not a characteristic of the lws controller.

@kerthcet
Copy link
Contributor

+1 to add these metrics later since not part of the 0.2.0.

@liurupeng
Copy link
Collaborator

/hold
As discussed with Edwin, hold the PR for now, thanks @Edwinhr716

@k8s-ci-robot k8s-ci-robot added do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Apr 19, 2024
@k8s-ci-robot
Copy link
Contributor

PR needs rebase.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@liurupeng
Copy link
Collaborator

close for now, @Edwinhr716

@liurupeng liurupeng closed this May 22, 2024
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/feature Categorizes issue or PR as related to a new feature. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. 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.

System metrics support
5 participants