Origin: OpenAPI spec marking optional v1.Route fields as required

Created on 31 Oct 2019  路  20Comments  路  Source: openshift/origin

When using Helm v3-rc.1, which includes OpenAPI validation before executing an install or upgrade, Route objects fail if they're missing optional fields (such as spec.host, status, spec.to.weight).

After raising on the Helm Github (https://github.com/helm/helm/issues/6830), I was pointed to the OKD v3.11 OpenAPI spec which incorrectly lists these fields as Required when, according to the Docs and API, they should be optional.

Version
禄 oc version
oc v3.11.0+0cbc58b
kubernetes v1.11.0+d4cacc0
features: Basic-Auth GSSAPI Kerberos SPNEGO

Server https://okd.example.net:8443
openshift v3.11.0+fef6f83-275
kubernetes v1.11.0+d4cacc0
Steps To Reproduce
  1. Have a Helm Chart that has an OKD Route in the templates/ dir
  2. Using Helm >=v3.beta-5, run helm template ./my-chart-with-route --validate (or helm install ./my-chart-with-route)
  3. See error:
Error: unable to build kubernetes objects from release manifest: error validating "": error validating data: [ValidationError(Route.spec.to): missing required field "weight" in com.github.openshift.api.route.v1.RouteTargetReference, ValidationError(Route.spec): missing required field "host" in com.github.openshift.api.route.v1.RouteSpec, ValidationError(Route): missing required field "status" in com.github.openshift.api.route.v1.Route]
Current Result

OKD v3.11 OpenAPI incorrectly lists some Optional fields as Required.

Expected Result

OKD v3.11 OpenAPI spec should list Required fields as Required and Optional fields as Optional.

Edit:

"v1.RouteSpec": {
  "id": "v1.RouteSpec",
  "description": "...",
  "required": [
    "host", # <--- ?
    "to"
  ],

```yaml
"v1.RouteStatus": {
"id": "v1.RouteStatus",
"description": "...",
"required": [
"ingress" # <-- ?
],

```yaml
"v1.RouteTargetReference": {
  "id": "v1.RouteTargetReference",
  "description": "...",
  "required": [
    "kind",
    "name",
    "weight" # <--- ?
  ],

Most helpful comment

I create a own helper inside _helpers.tpl

{{- define "chart.helmRouteFix" -}}
status:
  ingress:
    - host: ""
{{- end -}}

and at the end of a route I include the helper:

...
  to:
    kind: Service
    name: {{ template "chart.fullname" $ }}-keycloak
    weight: 100
{{ include "chart.helmRouteFix" $ }}

It reduce the amount of waste to a minimum

All 20 comments

This is causing a blocker for using any Helm version >=v3.beta-5, including the recent RC versions and any future versions of Helm v3 (at least until Helm v3.1.0 which will allow you to disable OpenAPI Validation https://github.com/helm/helm/pull/6819)

Now that Helm v3.0.0 has been tagged and released, this bug is preventing anyone using OKD from upgrading to Helm 3.

There are IMHO more resources with fields that shouldn't be marked as required, for example:

   "v1.BuildConfig": {
    "required": [
     "spec",
     "status"  # <--- ???
    ],

or

  "v1.BuildConfigSpec": {
    "required": [
     "triggers",
     "strategy",
     "nodeSelector"  # <--- ???
    ],

Got the the similar error:

Error: unable to build kubernetes objects from release manifest: error validating "": error validating data: [ValidationError(BuildConfig.spec): missing required field "nodeSelector" in com.github.openshift.api.build.v1.BuildConfigSpec, ValidationError(BuildConfig.status): missing required field "lastVersion" in com.github.openshift.api.build.v1.BuildConfigStatus]
helm.go:76: [debug] error validating "": error validating data: [ValidationError(BuildConfig.spec): missing required field "nodeSelector" in com.github.openshift.api.build.v1.BuildConfigSpec, ValidationError(BuildConfig.status): missing required field "lastVersion" in com.github.openshift.api.build.v1.BuildConfigStatus]

I am also seeing the same with helm@3, any plans of yet on this one?

helm.go:76: [debug] error validating "": error validating data: ValidationError(Route): missing required field "status" in [...]

FWIW I was able to move forward by stubbing out a junk status object

status:
  ingress:
    - conditions:
      - lastTransitionTime: "2019-12-06T03:24:58Z"
        status: "True"
        type: Admitted
      host: <host>
      routerCanonicalHostname: <host>
      routerName: default
      wildcardPolicy: None

I create a own helper inside _helpers.tpl

{{- define "chart.helmRouteFix" -}}
status:
  ingress:
    - host: ""
{{- end -}}

and at the end of a route I include the helper:

...
  to:
    kind: Service
    name: {{ template "chart.fullname" $ }}-keycloak
    weight: 100
{{ include "chart.helmRouteFix" $ }}

It reduce the amount of waste to a minimum

Error: unable to build kubernetes objects from release manifest: error validating "": error validating data: ValidationError(Route): missing required field "status" in com.github.openshift.api.route.v1. Route

$ oc version
oc v3.11.0+0cbc58b
kubernetes v1.11.0+d4cacc0
features: Basic-Auth SSPI Kerberos SPNEGO

Server https://ilocxxx-xxxx.xxxx.xxxx.com:8443
openshift v3.11.98
kubernetes v1.11.0+d4cacc0

$ helm version
version.BuildInfo{Version:"v3.1.1", GitCommit:"afe70585407b420d0097d07b21c47dc511525ac8", GitTreeState:"clean", GoVersion:"go1.13.8"}

If people want to be completely minimalist, this is the minimal status definition that complies with the route spec:

{{- define "chart.helmRouteFix" -}}
status:
  ingress: []
{{- end -}}

Issues go stale after 90d of inactivity.

Mark the issue as fresh by commenting /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.
Exclude this issue from closing by commenting /lifecycle frozen.

If this issue is safe to close now please do so with /close.

/lifecycle stale

/remove-lifecycle stale

Issues go stale after 90d of inactivity.

Mark the issue as fresh by commenting /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.
Exclude this issue from closing by commenting /lifecycle frozen.

If this issue is safe to close now please do so with /close.

/lifecycle stale

/remove-lifecycle stale

/lifecycle frozen

/remove-lifecycle frozen

The above workarounds are not useful if Helm chart is being used with a gitops tools such as ArgoCD. It continuously want to reconcile the status section as it changes after deployment. It makes ArgoCD not to be usable with Openshift resources. Disabling validation is not a good idea as it might break other things in future.

@m-yosefpor

The latest version of Openshift 3.11 should mark this field as optional

References:

@jkroepke We are using Openshift 3.10. Any chance that it could be back ported to that version?

I guess no unless you want to build openshift from source. 3.10 is out of support. But an upgrade 3.11 should not be a problem.

Was this page helpful?
0 / 5 - 0 ratings