Calico: CRD fails to apply on upgrade - preserveUnknownFields must be false in order to use defaults

Created on 3 Dec 2020  路  7Comments  路  Source: projectcalico/calico

Expected Behavior

No errors while upgrading

Current Behavior

The CustomResourceDefinition "bgppeers.crd.projectcalico.org" is invalid: spec.preserveUnknownFields: Invalid value: true: must be false in order to use defaults in the schema

Possible Solution

Steps to Reproduce (for bugs)

kubectl apply -f calico.yaml --validate
1.
2.
3.
4.

Context

Trying to upgrade calico

Your Environment

Kubernetes with 1 master & 2 workers

  • Calico version
    Upgrade from 3.14.1 to 3.17.0
  • Orchestrator version (e.g. kubernetes, mesos, rkt):
    Kubernetes 1.17.13

  • Operating System and version:
    RHEL 7.5

impachigh kinbug likelihoohigh

Most helpful comment

I ran into the same issue today. Do you already have a recommendation about which of the two solutions is the correct one?

All 7 comments

@bdaoudtdc just want to confirm, you're upgrading from Calico v3.1.4 to v3.1.7 on Kubernetes 1.17? Or do you mean v3.14 to v3.17?

We never released a v3.1.14 or a v3.1.17

If you're using Calico v3.1, I'm not sure that can be expected to work. Calico v3.1.x is _very_ old, and we stopped testing of it around the time of Kubernetes 1.10, which is also quite old.

https://docs.projectcalico.org/archive/v3.1/getting-started/kubernetes/requirements

@bdaoudtdc just want to confirm, you're upgrading from Calico v3.1.4 to v3.1.7 on Kubernetes 1.17? Or do you mean v3.14 to v3.17?

We never released a v3.1.14 or a v3.1.17

If you're using Calico v3.1, I'm not sure that can be expected to work. Calico v3.1.x is _very_ old, and we stopped testing of it around the time of Kubernetes 1.10, which is also quite old.

https://docs.projectcalico.org/archive/v3.1/getting-started/kubernetes/requirements

Sorry this was a typo ... versions adjusted.

Same issue with Kubernetes 1.19.4.

Two possible solutions:

  1. Add preserveUnknownFields: false to the CRD spec:
spec:
  group: crd.projectcalico.org
  names:
    kind: BGPPeer
    listKind: BGPPeerList
    plural: bgppeers
    singular: bgppeer
  scope: Cluster
  preserveUnknownFields: false
[...]
  1. Remove the default value set for spec.keepOriginalNextHop. This is the only default set for any of the CRDs used by Calico in 3.17.

The CRD will apply successfully in both cases.

Thank you .
I added
preserveUnknownFields: false

and it ran OK.

Sounds like we need to be making one of those changes in our CRD manifests, so I'm going to keep this open.

I ran into the same issue today. Do you already have a recommendation about which of the two solutions is the correct one?

In this case it appears that the default value specified in the schema matches the default that would occur anyway due to golang defaulting (i.e., false). So, it should be safe to simply remove the default. https://github.com/projectcalico/libcalico-go/blob/master/lib/apis/v3/bgppeer.go#L78

I still need to wrap my head around the implications of setting preserveUnknownFields: false, and so might be best to hold off on that for now. From a quick look around, though, it seems like we will want to set that eventually in order to use additional defaulting and validation features beyond basic schema validation.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ffilippopoulos picture ffilippopoulos  路  4Comments

mohit5577 picture mohit5577  路  5Comments

mrsherlock88 picture mrsherlock88  路  3Comments

caseydavenport picture caseydavenport  路  6Comments

winromulus picture winromulus  路  3Comments