pipecd icon indicating copy to clipboard operation
pipecd copied to clipboard

Failed to plan when there are resources that have multi-API versions on the v0.47.3-rc0

Open ffjlabo opened this issue 1 year ago • 1 comments

What happened:

Failed to plan when the gatekeeper's constraint template that has multi api version on the v0.47.3-rc0.

340704613-1b23754d-3c64-4d7b-867c-f1205d011869_png__1595×362_

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-rc0
  • control-plane version:
  • Others:

ffjlabo avatar Jun 19 '24 07:06 ffjlabo

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 https://github.com/pipe-cd/pipecd/pull/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?)

ffjlabo avatar Jun 19 '24 07:06 ffjlabo

We will fix it later on pipedv1.

ffjlabo avatar Oct 04 '24 08:10 ffjlabo