Failed to plan when there are resources that have multi-API versions on the v0.47.3-rc0
ffjlabo opened this issue · 2 comments
What happened:
Failed to plan when the gatekeeper's constraint template that has multi api version on the v0.47.3-rc0.

What you expected to happen:
It would be nice to plan the deployment.
How to reproduce it:
- Prepare Gatekeeper
- Apply 2 ConstraintTemplate of templates.gatekeeper.sh/v1beta1 on the old version’s piped and then update the piped to the v0.47.3-rc0
/constraint-template/
- app.pipecd.yaml
- k8srequiredlabels_template.yaml
- k8suniquelabel_template.yaml <- delete
- Delete one of the resources
Environment:
piped
version: v0.47.3-rc0control-plane
version:- Others:
Why this happened
When checking the resource ConstraintTemplate templates.gatekeeper.sh/v1beta1
, it fails because it is considered as not found.
This is related to the fix for #4916
Currently, piped checks whether the resource is cluster-scoped or not by using the resource info from the actual cluster.
The resource info is based on the preferred version which is determined by each resource.
ref: https://pkg.go.dev/k8s.io/client-go/discovery#DiscoveryClient.ServerPreferredResources
Gatekeeper allows us to use templates.gatekeeper.sh/v1beta1
or templates.gatekeeper.sh/v1
.
And use templates.gatekeeper.sh/v1 as preferred apiVersion.
It might be good to use the preferred version for the resource key.
But we need to get info about the preferred version to use (e.g. how to create it?)
We will fix it later on pipedv1.