Prisma Cloud Compute: How to resolve errors while upgrading 32.01.128 console version to the latest console version
Objective
Some users are experiencing the following error while upgrading their 32.01.128 version console to the latest version
Error (can be seen under console logs): panic: write exception: write errors: [The path 'rules.0.collections' must exist in the document in order to apply array updates.]
The objective of this article is to help users resolve this error and upgrade their self-hosted 32.01.128 version console to the latest version.
Environment
- Prisma Cloud Compute Self-Hosted
- Console version 32.01.128
Procedure
Please follow the following steps in order to fix some broken data in the customer’s MongoDB:
-
Create a backup of the running console.
-
Connect to the Machine where the Console container is running.
-
Run
sudo suto switch to root user. -
Run `cd /var/lib/twistlock` to switch the directory to the twistlock directory.
-
Copy, past and run the following command that will create a script that is called
fixPolicyRulesWithMissingCollecitons.jsecho 'const conn = new Mongo(); const db = conn.getDB("twistlock"); const policyCollection = db.policy; policyCollection.find({}).forEach(policy => { if (policy.hasOwnProperty("rules")) { policy.rules.forEach(rule => { if (!rule.hasOwnProperty("collections")) { rule.collections = []; } }); policyCollection.updateOne( { _id: policy._id }, { $set: { rules: policy.rules } } ); } }); print("Policy collection update completed.");' > fixPolicyRulesWithMissingCollecitons.js -
Verify that the script exist by running
ls. -
Run
docker ps. -
Copy the id of the Console container.
-
Run
docker exec -it <ID_FROM_STEP_8> bashto create a session inside the Console container. -
Run
cd /var/lib/twistlockto change the directory to the twistlock directory. -
Verify that you can see the script that is called
fixPolicyRulesWithMissingCollecitons.jsby runningls. -
Run
mongosh fixPolicyRulesWithMissingCollecitons.js. -
Make sure that you see the message "
Policy collection update completed".that indicates that the script ran successfully. -
After this, upgrade should work and you should be able to upgrade your console to the latest version