Symptoms:
Bundle cleanup script throws the foreign key constraint violation while cleaning up the upgrades entries for the provided bundle id.
Bundle CleanUp logs (/var/log/vmware/vcf/lcm/bundle_cleanup.log) contain the following log snippet:
2022-10-07 23:00:25,682 [INFO] root: Performing cleanup for bundle with IDs : ['aaf7a21c-####-####-####-##########fa']
2022-10-07 23:00:28,938 [ERROR] root: b'ERROR: update or delete on table "upgrade" violates foreign key constraint "FK309gdb4jpsxjg1u3f3jtae5c6" on table "upgrade_plan_upgrade"\n'
2022-10-07 23:00:28,938 [ERROR] root: b'DETAIL: Key (upgrade_id)=(be598aee-####-####-####-##########44) is still referenced from table "upgrade_plan_upgrade".\n'
2022-10-07 23:00:28,939 [ERROR] root: Error: ERROR: update or delete on table "upgrade" violates foreign key constraint "FK309gdb4jpsxjg1u3f3jtae5c6" on table "upgrade_plan_upgrade"
DETAIL: Key (upgrade_id)=(be598aee-f936-402b-8b54-d81ee1915d44) is still referenced from table "upgrade_plan_upgrade".
To workaround the issue, please follow the below mentioned steps:
Download the attached latest bundle cleanup script (bundle_cleanup.py) and update the script in SDDC Manager
Open an SSH session to the SDDC Manager VM and switch to the root user:
Copy the downloaded bundle_cleanup.py to /opt/vmware/vcf/lcm/lcm-app/bin/ replacing the older bundle_cleanup.py script.
Run the following command to change ownership and permissions of the bundle_cleanup.py
> chown vcf_lcm:vcf /opt/vmware/vcf/lcm/lcm-app/bin/bundle_cleanup.py
> chmod 750 /opt/vmware/vcf/lcm/lcm-app/bin/bundle_cleanup.py
> vi +':wq ++ff=unix' /opt/vmware/vcf/lcm/lcm-app/bin/bundle_cleanup.py
The updated bundle cleanup script can now be used to remove any patch bundles. If the patch was enabled using Async Patch tool, the patch can be disabled using the Async Patch tool.