ansible / awx-operator

An Ansible AWX operator for Kubernetes built with Operator SDK and Ansible. 🤖
https://www.github.com/ansible/awx
Apache License 2.0
1.26k stars 631 forks source link

Wrong database configuration created for credentials.py #313

Open Seb0042 opened 3 years ago

Seb0042 commented 3 years ago
ISSUE TYPE
SUMMARY

AWX containers can't connect to the database because the name of the database server has an additional carriage return.

ENVIRONMENT

Filing an awx-postgresql-configuration as asked, like this:

data:
  database: awx
  host: mydbservice.db-namespace.svc.my-cluster
  password: awx
  port: 5432
  type: unmanaged
  username: awx

Of course all the fields are b64 encoded.

EXPECTED RESULTS

I expect that the secret awx-app-credentials contains value for the credentials.py that will be configured as entered in the postgresql secret.

DATABASES = {
    'default': {
        'ATOMIC_REQUESTS': True,
        'ENGINE': 'awx.main.db.profiled_pg',
        'NAME': "awx",
        'USER': "awx",
        'PASSWORD': "awx",
        'HOST': 'mydbservice.db-namespace.svc.my-cluster',
        'PORT': "5432",
        'OPTIONS': { 'sslmode': 'prefer',
                     'sslrootcert': '/etc/pki/tls/certs/ca-bundle.crt',
        },
    }
}
ACTUAL RESULTS

The line for the HOST is not well formated, I have an unexpected carriage return at the end of the HOST line. I have this result :

DATABASES = {
    'default': {
        'ATOMIC_REQUESTS': True,
        'ENGINE': 'awx.main.db.profiled_pg',
        'NAME': "awx",
        'USER': "awx",
        'PASSWORD': "awx",
        'HOST': 'mydbservice.db-namespace.svc.my-cluster
',
        'PORT': "5432",
        'OPTIONS': { 'sslmode': 'prefer',
                     'sslrootcert': '/etc/pki/tls/certs/ca-bundle.crt',
        },
    }
}
tchellomello commented 3 years ago

@Seb0042 could you please provide the output for the command below:

kubectl get secret awx-postgresql-configuration -o jsonpath="{.data.host}" | base64 --decode
Seb0042 commented 3 years ago

Hi,

Data is anonymized here but it is the same form (respect of the - and . in the name): mydbservice.db-namespace.svc.my-cluster

Seb0042 commented 3 years ago

If I put the ip address of the service it works, but still fails with the name.
I event tried by creating the base64 data with an "echo -n xxx | base64 -w 0".