Skip to content
This repository was archived by the owner on Dec 15, 2022. It is now read-only.
This repository was archived by the owner on Dec 15, 2022. It is now read-only.

User resource does not sync correctly #57

Description

@danielinclouds

What happened?

When applying the below manifest with GCP DatabaseInstance and User resources:

---
apiVersion: v1
data:
  password: cGFzc3dvcmQ=
  username: cm9vdA==
kind: Secret
metadata:
  name: cloudsql-root-example
  namespace: default
type: Opaque

---
apiVersion: sql.gcp.jet.crossplane.io/v1alpha2
kind: DatabaseInstance
metadata:
  name: example
  labels:
    name:      "example"
    projectID: "project-1234"
spec:
  forProvider:
    project: "project-1234"
    databaseVersion: 'MYSQL_5_7'
    deletionProtection: false
    region: 'europe-west2'
    settings:
      - availabilityType: 'ZONAL'
        tier: 'db-f1-micro'
  providerConfigRef:
    name: provider-jet-gcp
  deletionPolicy: Delete

---
apiVersion: sql.gcp.jet.crossplane.io/v1alpha2
kind: User
metadata:
  name: example
  annotations: 
    crossplane.io/external-name: "root"
spec:
  forProvider:
    project: "experimental-project-191516"
    passwordSecretRef:
      key:       "password"
      name:      "cloudsql-root-example"
      namespace: "default"
    instanceSelector:
      matchControllerRef: false
      matchLabels:
        name:      "example"
        projectID: "project-1234"
  providerConfigRef:
    name: provider-jet-gcp
  deletionPolicy: Delete

The User never becomes synced. It is created but it looks like the jet gcp provider is not aware of that and tries to create it again.

$ kubectl get managed
NAME                                                      READY   SYNCED   EXTERNAL-NAME   AGE
databaseinstance.sql.gcp.jet.crossplane.io/example12344   True    True     example12344    27m

NAME                                     READY   SYNCED   EXTERNAL-NAME   AGE
user.sql.gcp.jet.crossplane.io/example   True    False    example12344    3m15s

User events:

Status:
  At Provider:
    Id:  root//example12344
  Conditions:
    Last Transition Time:  2022-04-20T09:37:05Z
    Reason:                Available
    Status:                True
    Type:                  Ready
    Last Transition Time:  2022-04-20T09:37:10Z
    Message:               observe failed: cannot run plan: plan failed: Instance cannot be destroyed: Resource google_sql_user.example has lifecycle.prevent_destroy set, but the plan calls for this resource to be destroyed. To avoid this error and continue with the plan, either disable lifecycle.prevent_destroy or reduce the scope of the plan using the -target flag.: File name: main.tf.json
    Reason:                ReconcileError
    Status:                False
    Type:                  Synced
    Last Transition Time:  2022-04-20T09:36:59Z
    Reason:                Finished
    Status:                True
    Type:                  AsyncOperation
    Last Transition Time:  2022-04-20T09:36:59Z
    Reason:                Success
    Status:                True
    Type:                  LastAsyncOperation
Events:
  Type     Reason                         Age                 From                                                   Message
  ----     ------                         ----                ----                                                   -------
  Normal   CreatedExternalResource        3m20s               managed/sql.gcp.jet.crossplane.io/v1alpha2, kind=user  Successfully requested creation of external resource
  Warning  CannotObserveExternalResource  45s (x8 over 3m3s)  managed/sql.gcp.jet.crossplane.io/v1alpha2, kind=user  cannot run plan: plan failed: Instance cannot be destroyed: Resource google_sql_user.example has lifecycle.prevent_destroy set, but the plan calls for this resource to be destroyed. To avoid this error and continue with the plan, either disable lifecycle.prevent_destroy or reduce the scope of the plan using the -target flag.: File name: main.tf.json

How can we reproduce it?

Apply the file from the issue description. Notice that the values for the project have to be changed.

kubectl apply -f db.yaml

What environment did it happen in?

Crossplane version: v1.7.0
Provider version: v0.3.0-rc.19.g1a65335

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions