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-13924: provision failover RDS instance #764

Merged
merged 1 commit into from
Jan 26, 2023

Conversation

vladbologa
Copy link
Contributor

@vladbologa vladbologa commented Jan 26, 2023

Description

For high availability, a failover RDS DB instance is created, in a different Availability Zone (AZ).

This PR implements provisioning logic for the failover instance (also for existing Centrals), and makes sure that both instances are deleted when deprovisioning an ACSCS instance.

Note that during ACSCS provisioning, fleetshard does not wait for the failover instance to be completely created, as that would increase our provisioning time.

Checklist (Definition of Done)

  • Unit and integration tests added
  • Added test description under Test manual
  • Evaluated and added CHANGELOG.md entry if required
  • 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.

Test manual

Tested in a local cluster. Verified in the AWS console that the DB was provisioned and that 2 instances were created, and that the Central was able to connect:
INSTALL_OPERATOR=NO MANAGED_DB_ENABLED=TRUE ./dev/env/scripts/up.sh
./scripts/create-central.sh

To test locally, I had to make the DB publicly accessible. For this purpose, I added a new VPC, security group and DB subnet group in dev on AWS.

# 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

@vladbologa vladbologa temporarily deployed to development January 26, 2023 10:05 — with GitHub Actions Inactive
@vladbologa
Copy link
Contributor Author

/test e2e

if err := r.ensureDBInstanceCreated(instanceID, clusterID); err != nil {
return fmt.Errorf("ensuring DB instance %s exists in cluster %s: %w", instanceID, clusterID, err)
}

failoverID := getFailoverInstanceID(databaseID)
if err := r.ensureDBInstanceCreated(failoverID, clusterID); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not 100 sure if it's a blocking operation, but if it is we may want to execute it in a separate goroutine to add some parallelism. Just food of thought for further improvements.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's not blocking, they go in parallel.

if err := r.ensureDBInstanceCreated(failoverID, clusterID); err != nil {
return fmt.Errorf("ensuring failover DB instance %s exists in cluster %s: %w", failoverID, clusterID, err)
}

return r.waitForInstanceToBeAvailable(ctx, instanceID, clusterID)
Copy link
Contributor

Choose a reason for hiding this comment

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

Don't we need to wait for a failover instance to be available too?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We don't need to, because Central only requires the primary one to start (the first one we create is a read/write instance, the second one is a read only instance that is not used except as failover, because Central doesn't support RO instances).

There's the very unlikely scenario that the primary one would fail in those few minutes before the failover one is available, but:

  • I'd rather keep the provisioning time shorter, and
  • there's not much to recover in fresh DB anyway :)

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Jan 26, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: kovayur, 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:

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

@vladbologa vladbologa merged commit 8ee512a into main Jan 26, 2023
@vladbologa vladbologa deleted the vbologa/ROX-13924-provision-failover-RDS-instance branch January 26, 2023 16:06
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