crossplane-contrib / provider-upjet-gcp

Official GCP Provider for Crossplane by Upbound.
Apache License 2.0
60 stars 61 forks source link

[Bug]: singleton lists as embedded objects conversion fails in case of `Cluster.spec.forProvider.addonsConfig` #548

Open girdharshubham opened 2 weeks ago

girdharshubham commented 2 weeks ago

Is there an existing issue for this?

Affected Resource(s)

Resource MRs required to reproduce the bug

-           apiVersion: container.gcp.upbound.io/v1beta1
+          apiVersion: container.gcp.upbound.io/v1beta2
            kind: Cluster
...
                addonsConfig:
-                - httpLoadBalancing:
-                  - disabled: {{ $.observed.composite.resource.spec.disableHttpLoadBalancing }}
-                - networkPolicyConfig:
-                  - disabled: {{ not $.observed.composite.resource.spec.networkPolicy.enabled }}
+                  httpLoadBalancing:
+                    disabled: {{ $.observed.composite.resource.spec.disableHttpLoadBalancing }}
+                  networkPolicyConfig:
+                   disabled: {{ not $.observed.composite.resource.spec.networkPolicy.enabled }}

Steps to Reproduce

  1. Create v1beta1 cluster with addon configurations for load balancing and network policy config (or multiple addon configurations)
  2. Bump to 1.2.0/1.3.0
  3. kubectl get cluster
    Error from server: conversion webhook for container.gcp.upbound.io/v1beta1, Kind=Cluster failed: cannot convert from the spoke version "v1beta1" to the hub version "v1beta2": cannot apply the PavedConversion for the "google_container_cluster" object: failed to convert the source map in mode "toEmbeddedObject" with source API version "v1beta1", target API version "v1beta2": singleton list, at the field path addonsConfig, must have a length of at most 1 but it has a length of 2

What happened?

Cronjob pods and replicaset pods stopped getting garbage collected on the cluster which prompted me to check api server logs. I found the conversion webhook failing. Release notes don't really specify it as a breaking change. 🤔

Relevant Error Output Snippet

No response

Crossplane Version

1.16

Provider Version

1.3.0

Kubernetes Version

1.27

Kubernetes Distribution

GKE

Additional Info

No response

turkenf commented 3 days ago

Hi @girdharshubham,

Thank you for raising this issue, I cannot reproduce the issue in the Kind cluster with the information given. I'm using the following basic example:

apiVersion: container.gcp.upbound.io/v1beta1
kind: Cluster
metadata:
  annotations:
    meta.upbound.io/example-id: container/v1beta1/cluster
  labels:
    testing.upbound.io/example-name: cluster
  name: cluster
spec:
  forProvider:
    location: europe-north1
    ipAllocationPolicy:
      - {}
    enableAutopilot: true
    enableIntranodeVisibility: true
    deletionProtection: false

Can you please provide us with the full example you used?

girdharshubham commented 3 days ago

I think it happens when you try to provide addonsConfig with more than one addon.

turkenf commented 3 days ago

I think it happens when you try to provide addonsConfig with more than one addon.

Could you please provide us with the full example you used?