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

ROX-16664: backup central encryption key #1296

Merged
merged 4 commits into from
Oct 5, 2023

Conversation

johannes94
Copy link
Contributor

@johannes94 johannes94 commented Sep 22, 2023

Description

Depends on #1285 and #1295 .

This PR add the central-encryption-key secret to the list of secrets that should be backed up in fleetmanagers database. It also adds an E2E test to test all expected secrets get backed up.

Checklist (Definition of Done)

  • Unit and integration tests added
  • Added test description under Test manual
  • Documentation added if necessary (i.e. changes to dev setup, test execution, ...)
  • CI and all relevant tests are passing
  • Add the ticket number to the PR title if available, i.e. ROX-12345: ...
  • Discussed security and business related topics privately. Will move any security and business related topics that arise to private communication channel.
  • Add secret to app-interface Vault or Secrets Manager if necessary
  • RDS changes were e2e tested manually
  • Check AWS limits are reasonable for changes provisioning new resources

Test manual

# Test with local FM, FS and OSD cluster in dev AWS account
# Flip the PubliclyAccessible flag in rds.go

make binary
make db/teardown db/setup db/migrate

./fleet-manager serve --enable-central-external-certificate --dataplane-cluster-config-file ./dev/config/dataplane-cluster-configuration-infractl-osd.yaml --force-leader --central-idp-client-id ""

# Start fleetshard-sync in another terminal
# Prepare environment
export CLUSTER_NAME=local_cluster                 
export MANAGED_DB_ENABLED=true
export AWS_AUTH_HELPER=aws-saml
export CREATE_AUTHPROVIDER=true

./dev/env/scripts/exec_fleetshard_sync.sh

# In another terminal
./scripts/create-central.sh

# Wait for provisioning state and fleetshard first reconciliation
# See that the key was generated and is 32 bytes 
kubectl get secrets -n rhacs-ck6p6969rus49ma6iko0 central-encryption-key -o yaml | yq .data.encryptionKey | base64 -d | base64 -d | wc -c
# Store secret for comparison later on
kubectl get secrets -n rhacs-ck6p6969rus49ma6iko0 central-encryption-key -o yaml | yq .data.encryptionKey > firstKey.txt

# Wait for ready state and creation of routes
# Check fleetshard-sync logs for status report of secrets
# Check that all "central-db-password" "central-tls" and "central-encryption-key" were reported
# search for "Secrets:map[central" to find the message

# Delete the tenant
export OCM_TOKEN=$(ocm token)
export central_id=<your-central-id>

./scripts/fmcurl "rhacs/v1/centrals/$central_id?async=true" -XDELETE -v

# Wait for full deletion, get admin tokens in the meantime
rhoas login --auth-url=https://auth.redhat.com/auth/realms/EmployeeIDP 
export OCM_TOKEN=$(rhoas authtoken)

# Restore from backup
./scripts/fmcurl "rhacs/v1/admin/centrals/$central_id/restore" -XPOST -v 

# Restore should run through successful, after restore get the restored key
# To run tests locally run:
make db/teardown db/setup db/migrate
make ocm/setup OCM_OFFLINE_TOKEN=<ocm-offline-token> OCM_ENV=development
make verify lint binary test test/integration

@johannes94 johannes94 temporarily deployed to development September 22, 2023 10:40 — with GitHub Actions Inactive
@johannes94 johannes94 temporarily deployed to development September 22, 2023 10:40 — with GitHub Actions Inactive
@johannes94 johannes94 temporarily deployed to development September 22, 2023 10:40 — with GitHub Actions Inactive
@johannes94 johannes94 temporarily deployed to development September 22, 2023 12:05 — with GitHub Actions Inactive
@johannes94 johannes94 temporarily deployed to development September 22, 2023 12:05 — with GitHub Actions Inactive
@johannes94 johannes94 temporarily deployed to development September 22, 2023 12:05 — with GitHub Actions Inactive
@johannes94 johannes94 force-pushed the jmalsam/ROX-16664-backup-central-encryption-key branch from 670e332 to a394530 Compare September 22, 2023 14:45
@johannes94 johannes94 temporarily deployed to development September 22, 2023 14:45 — with GitHub Actions Inactive
@johannes94 johannes94 temporarily deployed to development September 22, 2023 14:45 — with GitHub Actions Inactive
@johannes94 johannes94 temporarily deployed to development September 22, 2023 14:45 — with GitHub Actions Inactive
@johannes94 johannes94 temporarily deployed to development September 22, 2023 14:55 — with GitHub Actions Inactive
@johannes94 johannes94 temporarily deployed to development September 22, 2023 14:55 — with GitHub Actions Inactive
@johannes94 johannes94 temporarily deployed to development September 22, 2023 14:55 — with GitHub Actions Inactive
@johannes94 johannes94 force-pushed the jmalsam/ROX-16664-backup-central-encryption-key branch from c1367fe to 29beabe Compare October 2, 2023 08:40
@johannes94 johannes94 temporarily deployed to development October 2, 2023 08:40 — with GitHub Actions Inactive
@johannes94 johannes94 temporarily deployed to development October 2, 2023 08:40 — with GitHub Actions Inactive
@johannes94 johannes94 temporarily deployed to development October 2, 2023 08:40 — with GitHub Actions Inactive
@johannes94 johannes94 requested a review from vladbologa October 2, 2023 08:43
Copy link
Contributor

@vladbologa vladbologa left a comment

Choose a reason for hiding this comment

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

LGTM!

@openshift-ci openshift-ci bot removed the lgtm label Oct 5, 2023
@johannes94 johannes94 temporarily deployed to development October 5, 2023 14:36 — with GitHub Actions Inactive
@johannes94 johannes94 temporarily deployed to development October 5, 2023 14:36 — with GitHub Actions Inactive
@johannes94 johannes94 temporarily deployed to development October 5, 2023 14:36 — with GitHub Actions Inactive
@openshift-ci openshift-ci bot added the lgtm label Oct 5, 2023
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Oct 5, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: johannes94, vladbologa

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 [johannes94,vladbologa]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@johannes94
Copy link
Contributor Author

/retest

@johannes94 johannes94 merged commit 5d50b34 into main Oct 5, 2023
5 checks passed
@johannes94 johannes94 deleted the jmalsam/ROX-16664-backup-central-encryption-key branch October 5, 2023 15:57
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.

2 participants