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

Cannot delete CloudSqlInstance when there's a failover replica #473

Open
fcrespofastly opened this issue Oct 6, 2022 · 1 comment
Open
Labels
bug Something isn't working

Comments

@fcrespofastly
Copy link

What happened?

When deleting a CloudSQLInstance object with .spec.deletionPolicy: delete and a non empty .spec.failoverReplica, the external resource doesn't get deleted with the error:

 Warning  CannotDeleteExternalResource  4m33s (x8 over 5m47s)  managed/cloudsqlinstance.database.gcp.crossplane.io  cannot delete the CloudSQL instance: googleapi: Error 400: The requested operation is not valid for a replication master instance., errorReplicationMasterInvalidOperation

This means that the failover replica has to be deleted first, and indeed if I do it myself, then both the managed and external resource get deleted.

And as far as I've seen in the code, the gcp provider does not check if there's a failover replica and try to delete that one first:

https://github.com/crossplane-contrib/provider-gcp/blob/master/pkg/controller/database/cloudsql.go#L192-L203

I've tried also to see if there was any similar issue but didn't find any, I'm not sure if I'm doing something wrong. If not, I'm happy to come up with a PR.

How can we reproduce it?

apiVersion: database.gcp.crossplane.io/v1beta1
kind: CloudSQLInstance
metadata:
  name: testdb-mysql-master
spec:
  deletionPolicy: Delete
  providerConfigRef:
    name: default
  forProvider:
    databaseVersion: MYSQL_5_7
    failoverReplica:
      name: testdb-mysql-failover
    region: us-central1
    gceZone: us-central1-a
    instanceType: CLOUD_SQL_INSTANCE
    settings:
      tier: db-custom-4-15360
      backupConfiguration:
        enabled: true
        #pointInTimeRecoveryEnabled: true # Only for postgres
        binaryLogEnabled: true
        startTime: "00:00"
      dataDiskSizeGb: 10
      databaseFlags: []
      ipConfiguration:
        ipv4Enabled: false
        privateNetwork: projects/<project-id>/global/networks/<network>
      storageAutoResize: true
  writeConnectionSecretToRef:
    name: testdb-creds
    namespace: default 

What environment did it happen in?

Crossplane version: v1.6.4 (planning to test with latest soon)
Provider GCP Version: v0.20.0 (planning to test with latest soon)
Kubernetes Version: Client v1.22.0, Server v1.22.12-gke-1200
OS: Container-Optimized OS
Kernel: Linux 5.10.127

@fcrespofastly fcrespofastly added the bug Something isn't working label Oct 6, 2022
@fcrespofastly
Copy link
Author

fcrespofastly commented Oct 6, 2022

Like I mentioned above, happy to work on a PR if needed

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

No branches or pull requests

1 participant