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 Metrics for Running PipelinesRuns at Pipeline and Namespace level #8280

Merged
merged 1 commit into from
Oct 17, 2024

Conversation

pramodbindal
Copy link
Contributor

@pramodbindal pramodbindal commented Sep 19, 2024

Changes

  • Currently metrics shown for Running Pipeline Count is at cluster level.
  • There is no way we can get that metric at namespace or pipeline level.
  • We have added the PipelineRun metric at pipeline and namespace level.
  • Level of PipelineRun Can be configured via ConfigMap. Default is "" . but it can be set to namespace or Pipelinerun.

Submitter Checklist

As the author of this PR, please check off the items in this checklist:

  • Has Docs if any changes are user facing, including updates to minimum requirements e.g. Kubernetes version bumps
  • Has Tests included if any functionality added or changed
  • pre-commit Passed
  • Follows the commit message standard
  • Meets the Tekton contributor standards (including functionality, content, code)
  • Has a kind label. You can add one by adding a comment on this PR that contains /kind <type>. Valid types are bug, cleanup, design, documentation, feature, flake, misc, question, tep
  • Release notes block below has been updated with any user facing changes (API changes, bug fixes, changes requiring upgrade notices or deprecation warnings). See some examples of good release notes.
  • Release notes contains the string "action required" if the change requires additional action from users switching to the new release

Release Notes

NONE

@tekton-robot tekton-robot added the release-note-none Denotes a PR that doesnt merit a release note. label Sep 19, 2024
@tekton-robot
Copy link
Collaborator

Hi @pramodbindal. Thanks for your PR.

I'm waiting for a tektoncd 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.

@tekton-robot tekton-robot added needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Sep 19, 2024
Copy link
Contributor

@khrm khrm left a comment

Choose a reason for hiding this comment

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

/ok-to-test

@tekton-robot tekton-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 Sep 19, 2024
@khrm
Copy link
Contributor

khrm commented Sep 19, 2024

/kind feature

@tekton-robot tekton-robot added the kind/feature Categorizes issue or PR as related to a new feature. label Sep 19, 2024
@khrm
Copy link
Contributor

khrm commented Sep 19, 2024

/test check-pr-has-kind-label

@tekton-robot
Copy link
Collaborator

@khrm: The specified target(s) for /test were not found.
The following commands are available to trigger required jobs:

  • /test pull-tekton-pipeline-alpha-integration-tests
  • /test pull-tekton-pipeline-beta-integration-tests
  • /test pull-tekton-pipeline-build-tests
  • /test pull-tekton-pipeline-integration-tests
  • /test pull-tekton-pipeline-unit-tests

The following commands are available to trigger optional jobs:

  • /test pull-tekton-pipeline-go-coverage

Use /test all to run all jobs.

In response to this:

/test check-pr-has-kind-label

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.

@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage-df to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/apis/config/metrics.go 76.2% 78.3% 2.1
pkg/pipelinerunmetrics/metrics.go 85.4% 83.7% -1.7

@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/apis/config/metrics.go 76.2% 78.3% 2.1
pkg/pipelinerunmetrics/metrics.go 85.4% 83.7% -1.7

@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/apis/config/metrics.go 76.2% 78.3% 2.1
pkg/pipelinerunmetrics/metrics.go 85.4% 83.7% -1.7

@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage-df to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/apis/config/metrics.go 76.2% 78.3% 2.1
pkg/pipelinerunmetrics/metrics.go 85.4% 83.7% -1.7

@pramodbindal
Copy link
Contributor Author

/test pull-tekton-pipeline-build-tests
/test pull-tekton-pipeline-integration-tests

Copy link
Member

@vdemeester vdemeester left a comment

Choose a reason for hiding this comment

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

@pramodbindal can you squash your commits ? Otherwise LGTM.

@pramodbindal
Copy link
Contributor Author

@pramodbindal can you squash your commits ? Otherwise LGTM.

Done

@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/apis/config/metrics.go 76.2% 78.3% 2.1
pkg/pipelinerunmetrics/metrics.go 85.4% 83.7% -1.7

@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage-df to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/apis/config/metrics.go 76.2% 78.3% 2.1
pkg/pipelinerunmetrics/metrics.go 85.4% 83.7% -1.7

Copy link
Member

@vdemeester vdemeester left a comment

Choose a reason for hiding this comment

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

  • We might want to add a release note entry
  • It seems it needs to be rebased ?

@tekton-robot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: vdemeester

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

The pull request process is described 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

@tekton-robot tekton-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Sep 25, 2024
@pramodbindal
Copy link
Contributor Author

@pritidesai @abayer
This PR is Approved by @vdemeester .
Please provide /lgtm tag so I can merge this.

@pramodbindal pramodbindal force-pushed the SRVKP-6184 branch 2 times, most recently from 5c2ef54 to 4a05727 Compare September 26, 2024 11:01
@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/apis/config/metrics.go 76.2% 78.3% 2.1
pkg/pipelinerunmetrics/metrics.go 85.4% 83.7% -1.7

@tekton-robot tekton-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Oct 8, 2024
@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage-df to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/apis/config/metrics.go 76.2% 78.3% 2.1
pkg/pipelinerunmetrics/metrics.go 85.4% 84.0% -1.4

@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/apis/config/metrics.go 76.2% 78.3% 2.1
pkg/pipelinerunmetrics/metrics.go 85.4% 84.0% -1.4

@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/apis/config/metrics.go 76.2% 78.3% 2.1
pkg/pipelinerunmetrics/metrics.go 85.4% 84.0% -1.4

@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage-df to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/apis/config/metrics.go 76.2% 78.3% 2.1
pkg/pipelinerunmetrics/metrics.go 85.4% 84.0% -1.4

@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/apis/config/metrics.go 76.2% 78.3% 2.1
pkg/pipelinerunmetrics/metrics.go 85.4% 84.0% -1.4

@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage-df to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/apis/config/metrics.go 76.2% 78.3% 2.1
pkg/pipelinerunmetrics/metrics.go 85.4% 84.0% -1.4

@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage-df to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/apis/config/metrics.go 76.2% 78.3% 2.1
pkg/pipelinerunmetrics/metrics.go 85.4% 84.0% -1.4

@pramodbindal
Copy link
Contributor Author

/retest

@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/apis/config/metrics.go 76.2% 78.3% 2.1
pkg/pipelinerunmetrics/metrics.go 85.4% 84.0% -1.4

@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage-df to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/apis/config/metrics.go 76.2% 78.3% 2.1
pkg/pipelinerunmetrics/metrics.go 85.4% 84.0% -1.4

Copy link
Member

@afrittoli afrittoli left a comment

Choose a reason for hiding this comment

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

Thank you, this looks good!
My only ask is to extend the test to cover the various config options that you introduced, since right now only one out of four options is tested.

Comment on lines +547 to +606
newPipelineRun(corev1.ConditionUnknown, "testns1"),
newPipelineRun(corev1.ConditionUnknown, "testns2"),
newPipelineRun(corev1.ConditionUnknown, "testns2"),
newPipelineRun(corev1.ConditionUnknown, "testns3"),
newPipelineRun(corev1.ConditionUnknown, "testns3"),
newPipelineRun(corev1.ConditionUnknown, "testns3"),
newPipelineRun(corev1.ConditionUnknown, "testns3"),
Copy link
Member

Choose a reason for hiding this comment

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

Thank you for introducing more namespaces. This way the test checks that aggregation is happening at the namespace level. It does not check anymore that the filtering of the completed pipeline runs - is there a reason you removed them?

}
}

ctx = getConfigContextRunningPRLevel("pipeline")
Copy link
Member

Choose a reason for hiding this comment

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

The configuration is set to "pipeline" but all PipelineRuns use the same "anonymous" pipeline, so this setting is not fully tested. What is verified is aggregation at namespace level and the tagging at pipeline level.

pkg/pipelinerunmetrics/metrics.go Show resolved Hide resolved
pkg/pipelinerunmetrics/metrics.go Show resolved Hide resolved
if !pr.IsDone() {
countMap[pipelineRunKey]++
metrics.Record(ctx_, runningPRs.M(float64(countMap[pipelineRunKey])))
Copy link
Member

Choose a reason for hiding this comment

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

As discussed, we'll keep this as it is for now.
I still think that recording once the correct value would be better than recording incremental values, but we can address that separately.

if err := recorder.RunningPipelineRuns(informer.Lister()); err != nil {
t.Errorf("RunningPipelineRuns: %v", err)
}
metricstest.CheckLastValueData(t, "running_pipelineruns", map[string]string{"namespace": "testns", "pipeline": "anonymous"}, 1)
Copy link
Member

Choose a reason for hiding this comment

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

We should have one test per level in this PR. You can easily make this a matrix test with three fields:

  • the list of pipelineruns
  • the config level
  • a list of map[string]string -> int for expected values

@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/apis/config/metrics.go 76.2% 78.3% 2.1
pkg/pipelinerunmetrics/metrics.go 85.4% 86.5% 1.2

@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage-df to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/apis/config/metrics.go 76.2% 78.3% 2.1
pkg/pipelinerunmetrics/metrics.go 85.4% 86.5% 1.2

Copy link
Member

@afrittoli afrittoli 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 adding this and for all the updates!
/lgtm

@tekton-robot tekton-robot added the lgtm Indicates that a PR is ready to be merged. label Oct 17, 2024
@afrittoli
Copy link
Member

/hold cancel

@tekton-robot tekton-robot removed do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. lgtm Indicates that a PR is ready to be merged. labels Oct 17, 2024
We have added the PipelineRun metric at pipeline and namespace level.

Fix Lint Error

Fix Lint Error

Adding Tests for better coverage of different running-pipelinerun use cases.

Fix Lint
@afrittoli
Copy link
Member

/lgtm

@tekton-robot tekton-robot added the lgtm Indicates that a PR is ready to be merged. label Oct 17, 2024
@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage-df to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/apis/config/metrics.go 76.2% 78.3% 2.1
pkg/pipelinerunmetrics/metrics.go 85.4% 86.5% 1.2

@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/apis/config/metrics.go 76.2% 78.3% 2.1
pkg/pipelinerunmetrics/metrics.go 85.4% 86.5% 1.2

@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage-df to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/apis/config/metrics.go 76.2% 78.3% 2.1
pkg/pipelinerunmetrics/metrics.go 85.4% 86.5% 1.2

@tekton-robot tekton-robot merged commit 0350a6e into tektoncd:main Oct 17, 2024
14 checks passed
@pramodbindal pramodbindal deleted the SRVKP-6184 branch October 18, 2024 06:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. kind/feature Categorizes issue or PR as related to a new feature. lgtm Indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. release-note-none Denotes a PR that doesnt merit a release note. 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.

5 participants