Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 1, 2025

What type of PR is this?

Bug fix (cherry-pick)

What this PR does / why we need it:

Manual cherry-pick of #4731 to release-1.13 branch.

Scheduler panics with nil pointer dereference when started without --enable-metrics=true. The k8s scheduler framework plugins unconditionally access k8smetrics.Goroutines, which was only initialized inside the metrics-enabled conditional block.

Change: Move metrics.InitKubeSchedulerRelatedMetrics() outside the conditional block so k8smetrics.Goroutines is always initialized:

// Before: only initialized when metrics enabled
if opt.EnableMetrics || opt.EnablePprof {
    metrics.InitKubeSchedulerRelatedMetrics()
    go startMetricsServer(opt)
}

// After: always initialize required metrics
metrics.InitKubeSchedulerRelatedMetrics()

if opt.EnableMetrics || opt.EnablePprof {
    go startMetricsServer(opt)
}

Which issue(s) this PR fixes:

Fixes #4729

Special notes for your reviewer:

The panic occurs in k8s.io/kubernetes/pkg/scheduler/framework/parallelize.Parallelizer.Until when calling Goroutines.WithLabelValues() on nil. This metric must be initialized regardless of whether metrics export is enabled.

Does this PR introduce a user-facing change?

Fix scheduler panic when starting without --enable-metrics=true flag
Original prompt

This section details on the original issue you should resolve

<issue_title>[release-1.13] Fix scheduler panic when metrics are disabled</issue_title>
<issue_description>Manual cherrypick required.

#4731 failed to apply on top of branch "release-1.13":

Patch is empty.
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".

```</issue_description>

## Comments on the Issue (you are @copilot in this section)

<comments>
</comments>


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

@volcano-sh-bot volcano-sh-bot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Dec 1, 2025
Move InitKubeSchedulerRelatedMetrics() outside the EnableMetrics/EnablePprof
conditional block to ensure k8smetrics.Goroutines is always initialized.
This prevents panic when scheduler starts without --enable-metrics=true.

Fixes #4729 (cherry-pick from #4731 to release-1.13)

Co-authored-by: JesseStutler <38534065+JesseStutler@users.noreply.github.com>
@volcano-sh-bot volcano-sh-bot added do-not-merge/invalid-commit-message Indicates that a PR should not merge because it has an invalid commit message. labels Dec 1, 2025
Copilot AI changed the title [WIP] Fix scheduler panic when metrics are disabled in release-1.13 [release-1.13] Fix scheduler panic when metrics are disabled Dec 1, 2025
@volcano-sh-bot
Copy link
Contributor

Keywords which can automatically close issues and at(@) or hashtag(#) mentions are not allowed in commit messages.

The list of commits with invalid commit messages:

  • 468dea3 Fix scheduler panic when metrics are disabled
Details

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. I understand the commands that are listed here.

Copilot AI requested a review from JesseStutler December 1, 2025 02:32
@JesseStutler JesseStutler marked this pull request as ready for review December 9, 2025 06:46
Copilot AI review requested due to automatic review settings December 9, 2025 06:46
@volcano-sh-bot volcano-sh-bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Dec 9, 2025
@JesseStutler
Copy link
Member

/approve
/lgtm

@volcano-sh-bot volcano-sh-bot added the lgtm Indicates that a PR is ready to be merged. label Dec 9, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR is a manual cherry-pick of #4731 to the release-1.13 branch, fixing a nil pointer dereference panic that occurs when the volcano scheduler starts without the --enable-metrics=true flag. The Kubernetes scheduler framework plugins unconditionally access k8smetrics.Goroutines, which was previously only initialized inside a conditional block.

Key changes:

  • Move metrics.InitKubeSchedulerRelatedMetrics() outside the metrics/pprof conditional block to ensure it always executes
  • Add explanatory comment documenting why this initialization must always occur

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@JesseStutler JesseStutler removed the do-not-merge/invalid-commit-message Indicates that a PR should not merge because it has an invalid commit message. label Dec 10, 2025
@JesseStutler
Copy link
Member

/approve

@volcano-sh-bot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

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

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

Details 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

@JesseStutler JesseStutler merged commit 78e359c into release-1.13 Dec 10, 2025
33 of 35 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm Indicates that a PR is ready to be merged. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants