Skip to content

Scheduler: nil pointer dereference when RequestedToCapacityRatio field is missing in NodeResourcesFitArgs #133346

@flpanbin

Description

@flpanbin

What happened?

When configuring the scheduler's NodeResourcesFitArgs with RequestedToCapacityRatio scoring strategy, if the RequestedToCapacityRatio field is not specified in the configuration, the scheduler will encounter a nil pointer dereference error during validation.

Logs like this:

I0801 10:12:35.433071   19683 serving.go:386] Generated self-signed cert in-memory
W0801 10:12:35.579568   19683 authentication.go:368] No authentication-kubeconfig provided in order to lookup client-ca-file in configmap/extension-apiserver-authentication in kube-system, so client certificate authentication won't work.
W0801 10:12:35.579579   19683 authentication.go:392] No authentication-kubeconfig provided in order to lookup requestheader-client-ca-file in configmap/extension-apiserver-authentication in kube-system, so request-header client certificate authentication won't work.
W0801 10:12:35.579587   19683 authorization.go:193] No authorization-kubeconfig provided, so SubjectAccessReview of authorization tokens won't work.
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x2 addr=0x0 pc=0x103fac068]

What did you expect to happen?

If the RequestedToCapacityRatio field is missing, the scheduler should return a descriptive error message.

How can we reproduce it (as minimally and precisely as possible)?

  1. Create a scheduler configuration with NodeResourcesFitArgs
  2. Set the scoring strategy type to RequestedToCapacityRatio
  3. Omit the RequestedToCapacityRatio field in the configuration
  4. Start the scheduler

Example configuration that triggers the issue:

apiVersion: kubescheduler.config.k8s.io/v1
kind: KubeSchedulerConfiguration
clientConnection:
  kubeconfig: "/Users/bin/.kube/config"
profiles:
- schedulerName: default-scheduler
  plugins:
    score:
      enabled:
      - name: "NodeResourcesFit"
        weight: 100
      disabled:
      - name: "*"
  pluginConfig:
  - name: "NodeResourcesFit"
    args:
      scoringStrategy:
        resources:
        - name: "nvidia.com/gpu"
          weight: 1
        type: RequestedToCapacityRatio

Anything else we need to know?

No response

Kubernetes version

# kubectl version
Client Version: v1.30.4
Kustomize Version: v5.0.4-0.20230601165947-6ce0bf390ce3
Server Version: v1.30.4

Cloud provider

none

OS version

# On Linux:
$ cat /etc/os-release
# paste output here
$ uname -a
# paste output here

# On Windows:
C:\> wmic os get Caption, Version, BuildNumber, OSArchitecture
# paste output here

Install tools

Container runtime (CRI) and version (if applicable)

Related plugins (CNI, CSI, ...) and versions (if applicable)

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/bugCategorizes issue or PR as related to a bug.needs-sigIndicates an issue or PR lacks a `sig/foo` label and requires one.needs-triageIndicates an issue or PR lacks a `triage/foo` label and requires one.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions