Skip to content

[2.9.0][BUG][Steve] Steve server will panic if the cluster hosted NonStructuralSchema crds #46213

@orangedeng

Description

@orangedeng

Rancher Server Setup

  • Rancher version: v2.9-head
  • Installation option (Docker install/Helm Chart): N/A
  • Proxy/Cert Details: N/A

Cluster version:

  • v1.26.3-aliyun.1

Related Steve version: https://github.com/rancher/steve/tree/47871606146c436849dabf0a7ed7cd9dd3356817

As title, the steve server will panic with following errors:

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x60dd9f5]

goroutine 907 [running]:
github.com/rancher/steve/pkg/schema/definitions.listGVKModels({0x6b9c288, 0xc001d6b228}, 0xc00244cf80, {0x4ec7dae8, 0xc0002eb380})
        /Users/dengyuxing/gopath/pkg/mod/github.com/rancher/steve@v0.0.0-20240709130809-47871606146c/pkg/schema/definitions/handler.go:226 +0x5b5
github.com/rancher/steve/pkg/schema/definitions.(*SchemaDefinitionHandler).Refresh(0xc000866240)
        /Users/dengyuxing/gopath/pkg/mod/github.com/rancher/steve@v0.0.0-20240709130809-47871606146c/pkg/schema/definitions/handler.go:107 +0x17a
github.com/rancher/steve/pkg/debounce.(*DebounceableRefresher).RefreshAfter.func1()
        /Users/dengyuxing/gopath/pkg/mod/github.com/rancher/steve@v0.0.0-20240709130809-47871606146c/pkg/debounce/refresher.go:49 +0x106
created by github.com/rancher/steve/pkg/debounce.(*DebounceableRefresher).RefreshAfter in goroutine 962
        /Users/dengyuxing/gopath/pkg/mod/github.com/rancher/steve@v0.0.0-20240709130809-47871606146c/pkg/debounce/refresher.go:38 +0x13b
exit status 2

The crd is not validated because it's created in 1.20.x via API group apiextensions.k8s.io/v1beta1 which didn't require spec.validation back in the days. And the cluster got upgraded to v1.26.* but the crd remains.

The panic code is here https://github.com/rancher/steve/blob/master/pkg/schema/definitions/handler.go#L226, which might need to check for condition NonStructuralSchema is true or versions[].schema is nil.

Related crds:

apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
  creationTimestamp: "2022-02-07T06:04:24Z"
  generation: 1
  name: globaljobs.jobs.aliyun.com
  resourceVersion: "6696734787"
  uid: ba580245-14a1-41bd-ac8c-6a13c1cd5f30
spec:
  conversion:
    strategy: None
  group: jobs.aliyun.com
  names:
    kind: GlobalJob
    listKind: GlobalJobList
    plural: globaljobs
    shortNames:
    - globaljob
    singular: globaljob
  preserveUnknownFields: true
  scope: Namespaced
  versions:
  - name: v1alpha1
    served: true
    storage: true
status:
  acceptedNames:
    kind: GlobalJob
    listKind: GlobalJobList
    plural: globaljobs
    shortNames:
    - globaljob
    singular: globaljob
  conditions:
  - lastTransitionTime: "2022-02-07T06:04:24Z"
    message: no conflicts found
    reason: NoConflicts
    status: "True"
    type: NamesAccepted
  - lastTransitionTime: "2022-02-07T06:04:24Z"
    message: the initial names have been accepted
    reason: InitialNamesAccepted
    status: "True"
    type: Established
  - lastTransitionTime: "2022-02-07T06:12:29Z"
    message: 'spec.preserveUnknownFields: Invalid value: true: must be false'
    reason: Violations
    status: "True"
    type: NonStructuralSchema
  storedVersions:
  - v1alpha1

Metadata

Metadata

Labels

QA/Lkind/bugIssues that are defects reported by users or that we know have reached a real releasepriority/0status/release-blockerteam/frameworksthe team that is responsible for frameworks, projects, webhook, and other various areas

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions