Skip to content

Conversation

@jhrv
Copy link

@jhrv jhrv commented Feb 12, 2026

Problem

Migration fails when the source Cloud SQL instance has any of these features enabled (#240):

  • High Availability (HA)
  • Point-in-Time Recovery (PITR)

Root cause

DefineInstance() uses DeepCopy() to copy the source instance spec to the target. This copies all settings, including HA and PITR. The target instance is then created with these settings via the helper app.

During setup, DMS calls demoteTargetInstance() to convert the target to a read replica. This fails because:

  • A DMS-managed replica cannot have PITR enabled (DMS controls the WAL stream)
  • HA (availability type REGIONAL) is incompatible with being demoted to a DMS replica

Fix

Three changes in instance.go:

  1. CreateInstance() – After calling DefineInstance(), strip HA and PITR from the helper app spec before creating the target instance. This prevents GCP from creating an instance with incompatible settings.

  2. PrepareTargetInstance() – Also explicitly disable PITR (pointInTimeRecoveryEnabled = false) and set availabilityType = ZONAL on the CNRM spec as a safety net.

  3. ValidateSourceInstance() – Log clear warnings when the source has HA or PITR enabled, explaining they will be temporarily disabled during migration.

Re-enabling after migration

After promotion, UpdateApplicationInstance() applies the original app spec (which still has HA/PITR enabled) via naiserator reconciliation, so these features are automatically re-enabled on the target instance.

What about audit logging?

Issue #240 also mentions audit logging. The cloudsql.enable_pgaudit database flag would also be copied via DeepCopy(), but it is less clear whether this actually breaks DMS migration. This may need further investigation/testing.

Fixes #240

/cc @mortenlj

DMS migration fails when the source instance has High Availability or
Point-in-Time Recovery enabled, because these settings are copied to
the target via DeepCopy() in DefineInstance(). The target is then
demoted to a read replica by DMS, which is incompatible with HA and PITR.

Changes:
- Strip HA and PITR from helper app spec in CreateInstance()
- Disable PITR and set availability to ZONAL in PrepareTargetInstance()
- Add warnings in ValidateSourceInstance() about temporarily disabled features

After promotion, HA and PITR are automatically re-enabled when
UpdateApplicationInstance() applies the original app spec (which still
has these settings) via naiserator reconciliation.

Fixes #240
@jhrv jhrv self-assigned this Feb 12, 2026
@jhrv jhrv requested a review from mortenlj February 12, 2026 14:23
Copy link
Member

@mortenlj mortenlj left a comment

Choose a reason for hiding this comment

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

👍

Instead of relying on implicit re-enabling through naiserator
reconciliation, explicitly restore AvailabilityType, backup and PITR
settings from the source instance onto the target CNRM spec in
UpdateTargetInstanceAfterPromotion().

This makes the restore visible in logs and less fragile.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Migration doesn't work when certain features are enabled

2 participants