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: use contextal logging #813

Merged

Conversation

googs1025
Copy link
Member

@googs1025 googs1025 commented Oct 29, 2024

What type of PR is this?

What this PR does / why we need it:

  • use contextal logging

Due to the large scope, I may only be able to complete part of the plugins work in this PR.

  • coscheduling
  • capacityscheduling
  • networkaware
  • sysched

Which issue(s) this PR fixes:

Fixes # part of #743

Special notes for your reviewer:

Does this PR introduce a user-facing change?

None

@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. do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Oct 29, 2024
Copy link

netlify bot commented Oct 29, 2024

Deploy Preview for kubernetes-sigs-scheduler-plugins canceled.

Name Link
🔨 Latest commit 59a8b1c
🔍 Latest deploy log https://app.netlify.com/sites/kubernetes-sigs-scheduler-plugins/deploys/6727661fae0a670008b69a0d

@k8s-ci-robot k8s-ci-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Oct 29, 2024
@googs1025 googs1025 force-pushed the feature/contextual_logging branch 2 times, most recently from 111a6b2 to 1742b15 Compare October 30, 2024 05:30
@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 Oct 30, 2024
@googs1025
Copy link
Member Author

/kind feature

@k8s-ci-robot k8s-ci-robot added kind/feature Categorizes issue or PR as related to a new feature. release-note-none Denotes a PR that doesn't merit a release note. and removed do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. labels Oct 30, 2024
@@ -211,6 +213,8 @@ func (pgMgr *PodGroupManager) PreFilter(ctx context.Context, pod *corev1.Pod) er

// Permit permits a pod to run, if the minMember match, it would send a signal to chan.
func (pgMgr *PodGroupManager) Permit(ctx context.Context, state *framework.CycleState, pod *corev1.Pod) Status {
lh := klog.FromContext(ctx)
Copy link
Member Author

Choose a reason for hiding this comment

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

klog.FromContext(ctx)
When using klog.FromContext(ctx), do I need to add WithValues ​​to give it more information? 🤔

klog.FromContext(ctx).WithValues("PodGroupManager", "Unreserve")

Copy link
Contributor

Choose a reason for hiding this comment

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

When using klog.FromContext(ctx), do I need to add WithValues ​​to give it more information?

It'd depend IMO. In this case, I suppose you're trying to distinguish the contexts how the downstream CalculateAssignedPods() is called by? If so, it makes sense to add a extra WithValues: place a Permit context here, and a PostFilter in another place.

klog.FromContext(ctx).WithValues("PodGroupManager", "Unreserve")

I may make it more general:

WithValues("Phase", "Permit")

@googs1025 googs1025 changed the title [WIP] feature: use contextal logging feature: use contextal logging Nov 2, 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 Nov 2, 2024
@k8s-ci-robot k8s-ci-robot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Nov 2, 2024
Copy link
Contributor

@Huang-Wei Huang-Wei 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 the PR @googs1025 !

One question: do you plan to work on some script to enforce contextual logging into CI? (I may assume we may leverage from k/k)

@@ -211,6 +213,8 @@ func (pgMgr *PodGroupManager) PreFilter(ctx context.Context, pod *corev1.Pod) er

// Permit permits a pod to run, if the minMember match, it would send a signal to chan.
func (pgMgr *PodGroupManager) Permit(ctx context.Context, state *framework.CycleState, pod *corev1.Pod) Status {
lh := klog.FromContext(ctx)
Copy link
Contributor

Choose a reason for hiding this comment

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

When using klog.FromContext(ctx), do I need to add WithValues ​​to give it more information?

It'd depend IMO. In this case, I suppose you're trying to distinguish the contexts how the downstream CalculateAssignedPods() is called by? If so, it makes sense to add a extra WithValues: place a Permit context here, and a PostFilter in another place.

klog.FromContext(ctx).WithValues("PodGroupManager", "Unreserve")

I may make it more general:

WithValues("Phase", "Permit")

pkg/coscheduling/core/core.go Outdated Show resolved Hide resolved
@googs1025
Copy link
Member Author

Thanks for the PR @googs1025 !

One question: do you plan to work on some script to enforce contextual logging into CI? (I may assume we may leverage from k/k)

Ok, this is something I need to look into, I'm not familiar with this part of the script. If you could point me to some help, that would be great :)

Copy link
Contributor

@Huang-Wei Huang-Wei left a comment

Choose a reason for hiding this comment

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

/lgtm
/approve

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

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: googs1025, Huang-Wei

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

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Nov 3, 2024
@k8s-ci-robot k8s-ci-robot merged commit aadfeeb into kubernetes-sigs:master Nov 3, 2024
10 checks passed
@Huang-Wei
Copy link
Contributor

When migrating to structural logging, we composed a script hack/verify-structured-logging.sh to enforce it - which was based on k8s.io/klog/hack/tools/logcheck.

For contextual logging, we may proceed with a similar approach.

fali007 added a commit to fali007/scheduler-plugins that referenced this pull request Nov 6, 2024
commit 3d63730
Merge: dc97958 56323b7
Author: Kubernetes Prow Robot <[email protected]>
Date:   Tue Nov 5 06:35:28 2024 +0000

    Merge pull request kubernetes-sigs#822 from Huang-Wei/update-helm-index

    update helm chart index to include version 0.30.6

commit 56323b7
Author: Wei Huang <[email protected]>
Date:   Sun Nov 3 16:24:33 2024 -0800

    update helm chart index to include version 0.30.6

commit dc97958
Merge: aadfeeb b254cef
Author: Kubernetes Prow Robot <[email protected]>
Date:   Mon Nov 4 00:15:27 2024 +0000

    Merge pull request kubernetes-sigs#820 from Huang-Wei/0.30-doc-update

    doc update for v0.30.6

commit b254cef
Author: Wei Huang <[email protected]>
Date:   Sun Nov 3 15:55:38 2024 -0800

    doc update for v0.30.6

commit aadfeeb
Merge: 44370e5 59a8b1c
Author: Kubernetes Prow Robot <[email protected]>
Date:   Sun Nov 3 18:43:27 2024 +0000

    Merge pull request kubernetes-sigs#813 from googs1025/feature/contextual_logging

    feature: use contextal logging

commit 59a8b1c
Author: googs1025 <[email protected]>
Date:   Tue Oct 29 13:28:33 2024 +0800

    feature: use contextal logging

commit 44370e5
Merge: ecc6093 da60eee
Author: Kubernetes Prow Robot <[email protected]>
Date:   Sat Nov 2 19:11:32 2024 +0000

    Merge pull request kubernetes-sigs#817 from Huang-Wei/bump-k8s-v1.30.6

    bump k8s deps to v1.30.6

commit ecc6093
Merge: 1cda746 6ad9aab
Author: Kubernetes Prow Robot <[email protected]>
Date:   Sat Nov 2 19:11:26 2024 +0000

    Merge pull request kubernetes-sigs#805 from odeinjul/patch-1

    fix: fix wrong PreemptionToleration policy example

commit 1cda746
Merge: fb31908 e9b0097
Author: Kubernetes Prow Robot <[email protected]>
Date:   Sat Nov 2 18:45:26 2024 +0000

    Merge pull request kubernetes-sigs#802 from EladDolev/helm_resources

    allow resources to be configured in Helm chart

commit da60eee
Author: Wei Huang <[email protected]>
Date:   Sat Nov 2 11:28:05 2024 -0700

    vendor/

commit dd2d026
Author: Wei Huang <[email protected]>
Date:   Sat Nov 2 11:27:52 2024 -0700

    go module changes

commit fb31908
Merge: 9497a4e fd14d64
Author: Kubernetes Prow Robot <[email protected]>
Date:   Thu Oct 31 18:37:27 2024 +0000

    Merge pull request kubernetes-sigs#814 from blend/scheduler-command

    Allow specifying the scheduler container entrypoint in the helm chart

commit 9497a4e
Merge: bb56af1 57333b5
Author: Kubernetes Prow Robot <[email protected]>
Date:   Thu Oct 31 07:59:25 2024 +0000

    Merge pull request kubernetes-sigs#815 from blend/fix-leader-election

    Fix leader election config in the helm chart

commit 57333b5
Author: Chotiwat Chawannakul <[email protected]>
Date:   Wed Oct 30 18:02:27 2024 -0700

    fix rbac

commit 665f1ba
Author: Chotiwat Chawannakul <[email protected]>
Date:   Wed Oct 30 17:19:04 2024 -0700

    fix leader election config

commit fd14d64
Author: Chotiwat Chawannakul <[email protected]>
Date:   Mon Oct 28 18:42:10 2024 -0700

    allow specifying the scheduler container entrypoint in the helm chart

commit 6ad9aab
Author: Odeinjul <[email protected]>
Date:   Mon Sep 30 17:41:18 2024 -0500

    fix: fix wrong PreemptionToleration policy example

commit e9b0097
Author: Elad Dolev <[email protected]>
Date:   Mon Sep 23 15:52:42 2024 +0300

    allow resources to be configured in Helm chart

    Signed-off-by: Elad Dolev <[email protected]>
fali007 added a commit to fali007/scheduler-plugins that referenced this pull request Nov 6, 2024
commit e29810d
Author: Felix George <[email protected]>
Date:   Tue Nov 5 15:56:06 2024 +0530

    Added changes to fix code review comments

    Signed-off-by: Felix George <[email protected]>

commit 243d9bb
Merge: 7f8f12d 3d63730
Author: Felix <[email protected]>
Date:   Tue Nov 5 15:07:52 2024 +0530

    Merge branch 'kubernetes-sigs:master' into master

commit 3d63730
Merge: dc97958 56323b7
Author: Kubernetes Prow Robot <[email protected]>
Date:   Tue Nov 5 06:35:28 2024 +0000

    Merge pull request kubernetes-sigs#822 from Huang-Wei/update-helm-index

    update helm chart index to include version 0.30.6

commit 7f8f12d
Author: Felix George <[email protected]>
Date:   Tue Nov 5 09:02:22 2024 +0530

    Formatting changes

    Signed-off-by: Felix George <[email protected]>

commit 287f005
Author: Krishnasuri Narayanam <[email protected]>
Date:   Mon Nov 4 16:20:17 2024 +0530

    integration test case for PEAKS plugin

    Signed-off-by: Krishnasuri Narayanam <[email protected]>

commit 3924f0a
Author: Krishnasuri Narayanam <[email protected]>
Date:   Mon Nov 4 16:02:14 2024 +0530

    unit and integration test cases for PEAKS plugin

    Signed-off-by: Krishnasuri Narayanam <[email protected]>

commit 56323b7
Author: Wei Huang <[email protected]>
Date:   Sun Nov 3 16:24:33 2024 -0800

    update helm chart index to include version 0.30.6

commit dc97958
Merge: aadfeeb b254cef
Author: Kubernetes Prow Robot <[email protected]>
Date:   Mon Nov 4 00:15:27 2024 +0000

    Merge pull request kubernetes-sigs#820 from Huang-Wei/0.30-doc-update

    doc update for v0.30.6

commit b254cef
Author: Wei Huang <[email protected]>
Date:   Sun Nov 3 15:55:38 2024 -0800

    doc update for v0.30.6

commit aadfeeb
Merge: 44370e5 59a8b1c
Author: Kubernetes Prow Robot <[email protected]>
Date:   Sun Nov 3 18:43:27 2024 +0000

    Merge pull request kubernetes-sigs#813 from googs1025/feature/contextual_logging

    feature: use contextal logging

commit 59a8b1c
Author: googs1025 <[email protected]>
Date:   Tue Oct 29 13:28:33 2024 +0800

    feature: use contextal logging

commit 44370e5
Merge: ecc6093 da60eee
Author: Kubernetes Prow Robot <[email protected]>
Date:   Sat Nov 2 19:11:32 2024 +0000

    Merge pull request kubernetes-sigs#817 from Huang-Wei/bump-k8s-v1.30.6

    bump k8s deps to v1.30.6

commit ecc6093
Merge: 1cda746 6ad9aab
Author: Kubernetes Prow Robot <[email protected]>
Date:   Sat Nov 2 19:11:26 2024 +0000

    Merge pull request kubernetes-sigs#805 from odeinjul/patch-1

    fix: fix wrong PreemptionToleration policy example

commit 1cda746
Merge: fb31908 e9b0097
Author: Kubernetes Prow Robot <[email protected]>
Date:   Sat Nov 2 18:45:26 2024 +0000

    Merge pull request kubernetes-sigs#802 from EladDolev/helm_resources

    allow resources to be configured in Helm chart

commit da60eee
Author: Wei Huang <[email protected]>
Date:   Sat Nov 2 11:28:05 2024 -0700

    vendor/

commit dd2d026
Author: Wei Huang <[email protected]>
Date:   Sat Nov 2 11:27:52 2024 -0700

    go module changes

commit fb31908
Merge: 9497a4e fd14d64
Author: Kubernetes Prow Robot <[email protected]>
Date:   Thu Oct 31 18:37:27 2024 +0000

    Merge pull request kubernetes-sigs#814 from blend/scheduler-command

    Allow specifying the scheduler container entrypoint in the helm chart

commit 9497a4e
Merge: bb56af1 57333b5
Author: Kubernetes Prow Robot <[email protected]>
Date:   Thu Oct 31 07:59:25 2024 +0000

    Merge pull request kubernetes-sigs#815 from blend/fix-leader-election

    Fix leader election config in the helm chart

commit 57333b5
Author: Chotiwat Chawannakul <[email protected]>
Date:   Wed Oct 30 18:02:27 2024 -0700

    fix rbac

commit 665f1ba
Author: Chotiwat Chawannakul <[email protected]>
Date:   Wed Oct 30 17:19:04 2024 -0700

    fix leader election config

commit fd14d64
Author: Chotiwat Chawannakul <[email protected]>
Date:   Mon Oct 28 18:42:10 2024 -0700

    allow specifying the scheduler container entrypoint in the helm chart

commit 6ad9aab
Author: Odeinjul <[email protected]>
Date:   Mon Sep 30 17:41:18 2024 -0500

    fix: fix wrong PreemptionToleration policy example

commit e9b0097
Author: Elad Dolev <[email protected]>
Date:   Mon Sep 23 15:52:42 2024 +0300

    allow resources to be configured in Helm chart

    Signed-off-by: Elad Dolev <[email protected]>
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. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/feature Categorizes issue or PR as related to a new feature. lgtm "Looks good to me", indicates that a PR is ready to be merged. release-note-none Denotes a PR that doesn't merit a release note. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants