Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tenant Duplication when restoring Databases #859

Merged
merged 1 commit into from Aug 30, 2023

Conversation

MStokluska
Copy link
Contributor

@MStokluska MStokluska commented Aug 17, 2023

Jira: https://issues.redhat.com/browse/THREESCALE-8497

What

Added logic to support restoration from tenant CR when the tenant already exists in the database.

Verification

Pre-reqs

  • OCP/OSD cluster

Steps

  1. Create namespace
oc new-project threescale
  1. Apply CRDs
make install
  1. Create dummy secret
oc apply -f - <<EOF   
---
apiVersion: v1
kind: Secret
metadata:
  creationTimestamp: null
  name: s3-credentials
stringData:
  AWS_ACCESS_KEY_ID: something
  AWS_SECRET_ACCESS_KEY: something
  AWS_BUCKET: something
  AWS_REGION: us-east-1
type: Opaque
EOF
  1. Create APIM (update wildcard domain)
oc create -f - << EOF
apiVersion: apps.3scale.net/v1alpha1
kind: APIManager
metadata:
  name: apimanager-sample
  namespace: threescale
spec:
  system: 
    fileStorage: 
      simpleStorageService: 
        configurationSecretRef: 
          name: s3-credentials
  wildcardDomain: <WILDCARD>

EOF
  1. Run the operator
WATCH_NAMESPACE=threescale make run
  1. Wait for 3scale to fully provision
  2. Login to master portal (only 1 acc under accounts tab should be present)
  3. Create Tenant CR and secret (edit master portal URL before posting)
oc apply -f - <<EOF
---
apiVersion: v1
kind: Secret
metadata:
  name: example-admin-secret
type: Opaque
stringData:
  admin_password: "password"
---
apiVersion: capabilities.3scale.net/v1alpha1
kind: Tenant
metadata:
  name: example-tenant
spec:
  username: admin
  systemMasterUrl: <MASTER PORTAL URL>
  email: admin@example.com
  organizationName: example
  masterCredentialsRef:
    name: system-seed
  passwordCredentialsRef:
    name: example-admin-secret
  tenantSecretRef:
    name: example-tenant-secret
EOF
  1. The tenant CR should get updated with annotation tenantID
  2. Verify you can log in to the tenant portal (ID: admin, PASSWORD: password)
  3. In the CR, change the annotation tenantID value to some random value, the annotation value should get reverted to match the actual status.tenantID
  4. Copy the ObjectMetadata and Spec of tenantCR
  5. Stop the operator
  6. Remove the existing tenant CR + manually remove the finalizer since operator is no longer working and we don't want the tenant to be removed from the db
  7. Create the tenant CR from step 12 - reduce the object metadata that's not necessary (creation timestamp, uid etc, leave the name, annotations and finalizers)
  8. Run the operator again
  9. The tenant CR should get updated with the correct ID and tenant should not be re-created but linked to the existing one (verify in the master portal that you have only 2 tenants)

@MStokluska MStokluska requested a review from a team as a code owner August 17, 2023 11:01
@codeclimate
Copy link

codeclimate bot commented Aug 17, 2023

Code Climate has analyzed commit 8f20dcf and detected 0 issues on this pull request.

View more on Code Climate.

@austincunningham
Copy link
Contributor

👀

@carlkyrillos
Copy link
Contributor

I was unable to verify using the above verification steps because of an issue with the porta client not working with Tenant CRs - this issue is tracked by THREESCALE-10089.

However I was able to verify this PR by first installing 0.11.6 from the marketplace, scaling down the operator, and then running the operator locally, (I also needed to cancel new rollouts for system-app and system-mysql). After that I was able to verify the changes successfully.

/lgtm

Copy link
Contributor

@austincunningham austincunningham left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm
happy with the verification done by Carl

@MStokluska MStokluska merged commit b15925a into 3scale:master Aug 30, 2023
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants