rancher / rancher

Complete container management platform
http://rancher.com
Apache License 2.0
22.76k stars 2.91k forks source link

[BUG] Schema Definitions are missing formation for RKE Config on the provisioning cluster #45157

Open MbolotSuse opened 2 months ago

MbolotSuse commented 2 months ago

Rancher Server Setup

Information about the Cluster

User Information

Describe the bug The schema definition for the rkeConfig field of the provisioning.cattle.io.cluster object has no-subfields and an incorrect type.

To Reproduce

  1. Run rancher/rancher:v2.9-head
  2. Retrieve the schemaDefinition for the provisioning cluster ($RANCHER/v1/schemaDefinitions/provisioning.cattle.io.cluster)

Result The response contains the following for the "io.cattle.provisioning.v1.Cluster.spec" definition:

"resourceFields": {
    ...
    "rkeConfig": {
        "type": "string"
    }
},

Expected Result More fields should be present for the rkeConfig object, including the fields identified by kubctl explain clusters.provisioning.cattle.io.spec.rkeConfig:

GROUP:      provisioning.cattle.io
KIND:       Cluster
VERSION:    v1

FIELD: rkeConfig <Object>

DESCRIPTION:
    <empty>
FIELDS:
  additionalManifest    <string>
    <no description>

  chartValues   <Object>
    <no description>

  etcd  <Object>
    <no description>

  etcdSnapshotCreate    <Object>
    <no description>

  etcdSnapshotRestore   <Object>
    <no description>

  infrastructureRef <Object>
    <no description>

  machineGlobalConfig   <Object>
    <no description>

  machinePoolDefaults   <Object>
    <no description>

  machinePools  <[]Object>
    <no description>

  machineSelectorConfig <[]Object>
    <no description>

  machineSelectorFiles  <[]Object>
    <no description>

  networking    <Object>
    <no description>

  provisionGeneration   <integer>
    <no description>

  registries    <Object>
    <no description>

  rotateCertificates    <Object>
    <no description>

  rotateEncryptionKeys  <Object>
    <no description>

  upgradeStrategy   <Object>
    <no description>

Screenshots N/A

Additional context This represents a regression from the 2.8 behavior for schema fields. 2.8 appears to be able to derive this behavior from the CRDs. Steve should aim to have similar behavior.

MbolotSuse commented 1 month ago

Issue Summary

Currently, the schema definitions retrieves the fields available for a resource from the openapi/v2 endpoint, as seen here. When creating a CRD, users can specify the openAPISchema for the type in spec.versions[0].schema.openAPIV3Schema. Since this specification is using the openapi v3 specification, users can specify fields/types here that aren't compatible with the openapi v2. In these cases, the openapi v2 specification will contain only a "type: string" for the type, rather than the required complex field information.

tomleb commented 1 week ago

This is currently blocked on https://github.com/rancher/rancher/pull/45483 because steve is using k8s 1.30 / wrangler v3 but that's not yet in rancher/rancher.