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

Error: cannot diff a database connection with a schema "name_schema" #2592

Closed
sarahdipiero-igenius opened this issue Mar 4, 2024 · 5 comments
Assignees
Labels
operator atlas-operator's issue

Comments

@sarahdipiero-igenius
Copy link

sarahdipiero-igenius commented Mar 4, 2024

Hi,
I am making Atlas operator in Terraform:

resource "helm_release" "atlasgo-operator" {
  name             = "atlasgo-operator"
  repository       = "oci://ghcr.io/ariga/charts"
  chart            = "atlas-operator"
  namespace        = "atlas-operator"
  create_namespace = true
}

and I create a schema (all the variables are double checked):

apiVersion: db.atlasgo.io/v1alpha1
kind: AtlasSchema
metadata:
  name: atlasgoapp
  namespace: atlas-operator
spec:
  credentials:
    scheme: postgres
    host: ${db_host}
    user: ${db_username}
    password: ${db_password}
    database: ${database_name}
    port: 5432
    parameters:
      search_path: ${schema_name}
      sslmode: disable
  schema:
    sql: |
      CREATE TABLE clienti (
        id INT PRIMARY KEY,
        first_name VARCHAR(255) NOT NULL,
        last_name VARCHAR(255) NOT NULL
      );
  policy:
    diff: 
      skip:
        drop_column: true
        drop_table: true
        drop_schema: true   
    lint:
      destructive:
        error: false

but when I terraform plan then apply I have the following errors:

 2024-03-04T11:12:48Z    DEBUG    events    Error: cannot diff a database connection with a schema "name_schema". See: https://atlasgo.io/url    {"type": "Warning", "object": {"kind":"AtlasSchema","namespace":"atlas-operator │
│ ","name":"atlasgoapp","uid":"c048bae6-be1f-4264-bb14-588c09985bcf","apiVersion":"db.atlasgo.io/v1alpha1","resourceVersion":"35175894"}, "reason": "VerifyingFirstRun"}                                                             │
│ 2024-03-04T11:13:20Z    DEBUG    events    Error: cannot diff a database connection with a schema "name_schema". See: https://atlasgo.io/url    {"type": "Warning", "object": {"kind":"AtlasSchema","namespace":"atlas-operator │
│ ","name":"atlasgoapp","uid":"c048bae6-be1f-4264-bb14-588c09985bcf","apiVersion":"db.atlasgo.io/v1alpha1","resourceVersion":"35175894"}, "reason": "TransientErr"}

The database sslmode is prefer but atlas does not support prefer mode (just disable, require, verify-ca and verify-full). I don't know if this could be the cause of this problem. However I tried disable and require and they don't work.

@sarahdipiero-igenius sarahdipiero-igenius changed the title Error: cannot diff a database connection with a schema "new_schema" Error: cannot diff a database connection with a schema "name_schema" Mar 4, 2024
@giautm
Copy link
Member

giautm commented Mar 5, 2024

Hello @sarahdipiero-igenius, can you please share the version of the atlas-operator you're running?

sslmode=prefer is the default value, so you don't need to define it in the connection's parameters - my wild guess. Please, if you can share the screenshot of AtlasSchema when you inspect it from k8s, it will be helpful, please hide any sensitive information like IP/password.

@giautm giautm added the operator atlas-operator's issue label Mar 5, 2024
@sarahdipiero-igenius
Copy link
Author

sarahdipiero-igenius commented Mar 5, 2024

I think you mean this
Screenshot 2024-03-05 alle 11 59 32

@giautm
Copy link
Member

giautm commented Mar 5, 2024

Error: cannot diff a database connection with a schema "name_schema"

I guess this error happened because the dev-db was mismatched config. Can you please share the URL of dev-db? It should include the search_path=name_schema.

@sarahdipiero-igenius
Copy link
Author

Adding search_path in the url it is now working thanks

@giautm
Copy link
Member

giautm commented Mar 5, 2024

Happy to hear it, closing the issue now. But please join our community for further questions if you have.

@giautm giautm closed this as completed Mar 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
operator atlas-operator's issue
Projects
None yet
Development

No branches or pull requests

2 participants