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

CloudSQLInstance keeps modifying the instance #352

Closed
b4nst opened this issue Aug 11, 2021 · 6 comments · Fixed by #374
Closed

CloudSQLInstance keeps modifying the instance #352

b4nst opened this issue Aug 11, 2021 · 6 comments · Fixed by #374
Labels
bug Something isn't working

Comments

@b4nst
Copy link

b4nst commented Aug 11, 2021

What happened?

I still can see the behavior of #164

How can we reproduce it?

---
apiVersion: database.gcp.crossplane.io/v1beta1
kind: CloudSQLInstance
metadata:
  name: sre-6-db
  namespace: crossplane
spec:
  deletionPolicy: "Orphan"
  forProvider:
    databaseVersion: POSTGRES_11
    region: europe-west1
    settings:
      ipConfiguration:
        ipv4Enabled: false
        privateNetwork: default
      tier: db-custom-1-3840
  writeConnectionSecretToRef:
    name: db-connection
    namespace: default

What environment did it happen in?

  • Crossplane version: v1.3.0
  • Cloud provider or hardware configuration: provider-gcp-controller:v0.17.1
  • K8s Rev: v1.20.8-gke.900

Workaround/Fix

Use full resource URL for spec.forProvider.settings.ipConfiguration.privateNetwork instead of name.

---
apiVersion: database.gcp.crossplane.io/v1beta1
kind: CloudSQLInstance
metadata:
  name: sre-6-db
  namespace: crossplane
spec:
  deletionPolicy: "Orphan"
  forProvider:
    databaseVersion: POSTGRES_11
    region: europe-west1
    settings:
      ipConfiguration:
        ipv4Enabled: false
-       privateNetwork: default
+       privateNetwork: projects/your-project/global/networks/default
      tier: db-custom-1-3840
  writeConnectionSecretToRef:
    name: db-connection
    namespace: default
@b4nst b4nst added the bug Something isn't working label Aug 11, 2021
@astraios
Copy link

astraios commented Sep 9, 2021

Do we have any news about this one?

@turkenh
Copy link
Contributor

turkenh commented Sep 15, 2021

@b4nst I am trying to reproduce the issue on my side, but I cannot create a CloudSQLInstance with the manifest you shared. Getting:

  Warning  CannotCreateExternalResource     3s (x5 over 30s)  managed/cloudsqlinstance.database.gcp.crossplane.io  cannot create new CloudSQL instance: googleapi: Error 400: Invalid request: Incorrect Service Networking config for instance: redacted-project:sre-6-db-hasan-bug352-2:NETWORK_NOT_PEERED., invalid

Tried setting privateNetwork both as default and projects/redacted-project/global/networks/default, but no luck.

When I try to created without privateNetwork field and them attempt to add it with an update, I am observing periodic updates as you mentioned but I believe this is because something wrong with the configuration. I am observing some operation logs saying something went wrong with much details.

So, my question is, do we create your instance with the manifest or attempt to update it like that after creation?
Any hints that could help me to reproduce would be nice.

@b4nst
Copy link
Author

b4nst commented Sep 16, 2021

Hey @turkenh, thanks for working on that! I suspect the issue you're facing is you're lacking private services access. I think you can enable it directly through crossplane, but I did it manually for testing purposes.

Regarding the instance, I'm creating it from scratch with the crossplane manifest.

@turkenh
Copy link
Contributor

turkenh commented Sep 16, 2021

Thanks @b4nst, this did help and I could reproduce on my side.

I also found the problem, which is privateNetwork field indeed expects the resource link for the network (which is indeed documented in the field description) but Google API still accepts VPC network name and convert it to resource link by assuming it is in the same project.

In the next reconcile, Crossplane considers this as a configuration drift, e.g. expecting to be default but it is projects/redacted-project/global/networks/default and triggers an update.

So, to fix the situation, you should use the resource link of VPC instead of its name.

@turkenh
Copy link
Contributor

turkenh commented Sep 16, 2021

It is kind of working as expected (as documented), but we definitely need to improve this for a better UX.

The most straightforward solution would be to return a proper error if privateNetwork field is a resource URL.

turkenh added a commit to turkenh/provider-gcp that referenced this issue Sep 16, 2021
@b4nst
Copy link
Author

b4nst commented Sep 16, 2021

Gotcha, thanks for the details!

turkenh added a commit to turkenh/provider-gcp that referenced this issue Sep 16, 2021
turkenh added a commit to turkenh/provider-gcp that referenced this issue Sep 16, 2021
turkenh added a commit to turkenh/provider-gcp that referenced this issue Sep 20, 2021
Closes crossplane-contrib#352

Signed-off-by: Hasan Turken <[email protected]>
(cherry picked from commit 56aee82)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants