awx-operator
awx-operator copied to clipboard
remove default old PG config
SUMMARY
Removes the use of a default secret name for DB migration.
The existance of a secret named {{ ansible_operator_meta.name }}-old-postgres-configuration causes the operator to force DB migration even if the user did not request a migration.
With this fix, a migration only occurs if the user specifically request a migration by setting the attribute old_postgres_configuration_secret to a non empty value
ISSUE TYPE
- Bug, Docs Fix or other nominal change
ADDITIONAL INFORMATION
@w4hf CI caught an error:
"message": "The task includes an option with an undefined variable. The error was: 'old_pg_config' is undefined. 'old_pg_config' is undefined. 'old_pg_config' is undefined. 'old_pg_config' is undefined\n\n
The error appears to be in '/opt/ansible/roles/installer/tasks/database.yml': line 83, column 7, but may\n
be elsewhere in the file depending on the exact syntax problem.\n\n
The offending line appears to be:\n\n- block:\n
- name: Create Database if no database is specified\n ^ here\n\n
- Failed to retrieve requested object: b'{\"kind\":\"Status\",\"apiVersion\":\"v1\",\"metadata\":{},\"status\":\"Failure\",\"message\":\"statefulsets.apps \\\\\"example-awx-postgres-15\\\\\" not found\",\"reason\":\"NotFound\",\"details\":{\"name\":\"example-awx-postgres-15\",\"group\":\"apps\",\"kind\":\"statefulsets\"},\"code\":404}\\n'",
It's failing on this task here when applying the postgres stateful set yaml:
- https://github.com/ansible/awx-operator/blob/devel/roles/installer/tasks/database.yml#L83-L87
I think we need to improve the jinja2 templating here to something like this for it to work:
{% if old_pg_config is defined
and old_pg_config
and 'resources' in old_pg_config
and old_pg_config['resources']
and 'data' in old_pg_config['resources'][0]
and 'password' in old_pg_config['resources'][0]['data'] %}
- name: PGPASSWORD_OLD
valueFrom:
secretKeyRef:
name: '{{ old_pg_config["resources"][0]["metadata"]["name"] }}'
key: password
{% endif %}