fix: generate and persist SECRET_KEY for pulpcore 3.105.13 compatibility - #287
Conversation
pulpcore 3.105.13 removed the insecure SECRET_KEY = "SECRET" default (pulp/pulpcore#7873), causing all galaxy-ng pods to enter CrashLoopBackOff with "The SECRET_KEY setting must not be empty" on startup. Add secret_key_configuration.yml to the common role. On first install it generates a 50-character random key, stores it in a <name>-secret-key Kubernetes Secret with ownerReferences removed (so it survives CR deletion), and merges it into pulp_combined_settings so it lands in /etc/pulp/settings.py as SECRET_KEY. Subsequent reconciliations reuse the stored value. If the user or installer provides secret_key in pulp_settings, that value is used as-is and no Secret is created. Assisted-by: Claude Signed-off-by: Lucas Benedito <lbenedit@redhat.com>
addb743 to
2a3b072
Compare
|
thank you, that's exactly we need 👍 |
Following the awx-operator pattern, store the secret key secret name in the Galaxy CR status so backup/restore can preserve it across reinstalls. Without this, a restore generates a new random SECRET_KEY, invalidating all active Django sessions and breaking the restored instance. Changes: - secret_key_configuration.yml: store secret_key_secret_name fact - galaxy-status/tasks/main.yml: write secretKeySecret to CR status - backup/tasks/secrets.yml: add secretKeySecret to the backup dump list The restore role already handles secrets generically via secrets.yml.j2, so no restore-side changes are needed. Assisted-by: Claude Signed-off-by: Lucas Benedito <lbenedit@redhat.com>
7dc0834 to
3f69eec
Compare
The "Store secret key secret name" task was gated on `pulp_combined_settings.secret_key is not defined`, but the two tasks immediately before it already set that same key. By the time "Store secret key secret name" ran, the condition was always false, so secret_key_secret_name was never set, status.secretKeySecret was never written, and roles/backup/tasks/dump_generated_secret.yml failed with "'dict object' has no attribute 'secretKeySecret'" on every CI job. Capture whether the user supplied a literal secret_key once, into its own fact, before anything mutates pulp_combined_settings, and gate all downstream tasks on that stable fact instead - the same separation of "secret name" from "secret value" already used by db_fields_encryption_configuration.yml. Also declare status.secretKeySecret and the new spec.secret_key_secret override on the Galaxy CRD. Both are new structural-schema properties; without them the Kubernetes API server silently prunes the field on write, so status.secretKeySecret would still never persist even after the logic fix above. secret_key_secret is also now honored as the Secret's name (falling back to the previous <name>-secret-key default), needed so a restored deployment can be pinned back to its original secret name. Signed-off-by: Christian M. Adams <chadams@redhat.com>
The previous commit's intent was for backup/restore to preserve SECRET_KEY across reinstalls, matching db_fields_encryption_secret, admin_password_secret, postgres_configuration_secret and container_token_secret. That linkage was incomplete: the secret name was never recorded on the GalaxyBackup CR's own status, never read back during restore, and never pinned into the restored CR's spec. As a result, SECRET_KEY continuity only survived a restore to the same deployment name. Restoring under a different GalaxyRestore.spec.deployment_name (an explicitly supported flow) would still generate a brand-new random key, invalidating sessions - the exact failure mode this feature exists to prevent. - roles/backup/tasks/init.yml: read secretKeySecret from the live Galaxy CR status, same as the other generated secrets. - roles/backup/tasks/update_status.yml: write it onto the GalaxyBackup CR's own status so restore can find it. - config/crd/bases/galaxy_v1beta1_galaxybackup_crd.yaml: declare the new status field (same structural-schema pruning issue as the Galaxy CRD). - roles/backup/tasks/custom_resource.yml: pin the actual secret name into the backed-up CR spec so a rename-restore still resolves to it. Only done when a secret was actually generated (secret_key_secret can legitimately be absent when pulp_settings.secret_key was provided as a literal value). - roles/restore/tasks/init.yml, roles/restore/tasks/cleanup.yml: read the name back from the GalaxyBackup status and strip its ownerReferences after restore, same as the other generated secrets. Signed-off-by: Christian M. Adams <chadams@redhat.com>
|
Pushed two follow-up commits to get CI green and finish out the backup/restore piece:
That alone wasn't quite enough, though:
CI is running now on the updated branch — will confirm once it's green. |
SUMMARY
pulpcore 3.105.13 removed the insecure
SECRET_KEY = "SECRET"default (pulp/pulpcore#7873), causing all galaxy-ng pods to enterCrashLoopBackOffon startup:The galaxy-operator previously relied on this fallback. This fix adds
secret_key_configuration.ymlto the common role, following the same pattern asdb_fields_encryption_configuration.yml.Behavior:
lookup('password', ...), stores it in a<name>-secret-keyKubernetes Secret withownerReferencesremoved (so it survives CR deletion), and merges it intopulp_combined_settingsso it lands in/etc/pulp/settings.pyasSECRET_KEYpulp_settings.secret_keyis set in the CR spec (e.g. by the AAP installer viahub_secret_key): that value is used as-is and no Secret is createdISSUE TYPE
COMPONENT NAME
STEPS TO REPRODUCE AND EXTRA INFO
Deploy galaxy-operator with
quay.io/ansible/galaxy-ng:latest(any build after 2026-09-01). All api/content/worker pods crash immediately withSECRET_KEY setting must not be empty.