IBM / ibm-common-service-operator

Operator to install IBM Common Services
https://www.ibm.com/support/knowledgecenter/SSHKN6/kc_welcome_cs.html
Apache License 2.0
19 stars 67 forks source link

specify data copied over in preload data script #2095

Closed bluzarraga closed 1 month ago

bluzarraga commented 1 month ago

In older environments where metering data still exists, it is possible for the restore job to fail trying to restore metering data when it is not covered by the preload script. This failure happens because of how the preload data script works. This script creates a dummy mongo in the target namespace. By default, this mongo is stood up with the oauth db and the platform db. the ouath data is copied over via secrets and configmaps that are copied over from the original namespace to the target namespace so those values don't need to be restored. This leaves the plaftform db data. When mongo starts up, it automatically creates this db inside mongo. This does not happen by default for metering so there is no metering db.

What does this mean? This means when we run the mongorestore command, oauth and platform db data can be written to the new mongo in the target namespace but metering cannot. Mongorestore does not create dbs that do not exist, it only writes to existing dbs. This results in a createIndexError during mongorestore causing the mongo-restore job (and then the preload data script as a whole) to fail. We only care about bringing over the platform db data (since this script is run specifically for 4.x upgrades and metering was deprecated before then).

How does this pr fix this problem? This pr changes the mongorestore command to only restore the platform db and nothing else. It will only try to write data to the platform db which should not be problematic. The addition of the --drop flag will also prevent the duplicate key error messages. This is also the exact command we use for our BR and what we have advised CPD to use.

bluzarraga commented 1 month ago

would also need to merge these changes into scripts-adopter branch so CP4BA can pick it up

bluzarraga commented 1 month ago

Took a little tweaking but its ready

ibm-ci-bot commented 1 month ago

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: bluzarraga, Daniel-Fan

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files: - ~~[OWNERS](https://github.com/IBM/ibm-common-service-operator/blob/scripts-dev/OWNERS)~~ [Daniel-Fan,bluzarraga] Approvers can indicate their approval by writing `/approve` in a comment Approvers can cancel approval by writing `/approve cancel` in a comment