Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CRD fails to apply on upgrade - preserveUnknownFields must be false in order to use defaults #4237

Closed
bdaoudtdc opened this issue Dec 2, 2020 · 7 comments

Comments

@bdaoudtdc
Copy link

bdaoudtdc commented Dec 2, 2020

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

@caseydavenport
Copy link
Member

@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 bdaoudtdc changed the title Error when upgrading to 3.1.17 Error when upgrading to 3.17.0 Dec 3, 2020
@bdaoudtdc
Copy link
Author

@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.

@eirikrye
Copy link

eirikrye commented Dec 3, 2020

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.

@bdaoudtdc
Copy link
Author

Thank you .
I added
preserveUnknownFields: false

and it ran OK.

@caseydavenport
Copy link
Member

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

@caseydavenport caseydavenport reopened this Dec 3, 2020
@caseydavenport caseydavenport changed the title Error when upgrading to 3.17.0 CRD fails to apply on upgrade - preserveUnknownFields must be false in order to use defaults Dec 3, 2020
@TheKangaroo
Copy link

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

@caseydavenport
Copy link
Member

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.

lwr20 added a commit to projectcalico/libcalico-go that referenced this issue Dec 16, 2020
lwr20 added a commit to lwr20/libcalico-go that referenced this issue Dec 21, 2020
caseydavenport pushed a commit to projectcalico/libcalico-go that referenced this issue Dec 21, 2020
* Remove bgppeer KeepOriginalNextHop default

Attempts to fix projectcalico/calico#4237

* Update bgppeers CRD
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants