@@ -7,6 +7,10 @@ import (
77
88// observeCNPGMigration is a protected read-only step, not cutover clearance.
99func observeCNPGMigration (ctx context.Context , c client , target , source string ) (cnpgObservation , error ) {
10+ return observeCNPGMigrationWithRetention (ctx , c , target , source , "" )
11+ }
12+
13+ func observeCNPGMigrationWithRetention (ctx context.Context , c client , target , source , retainedStandby string ) (cnpgObservation , error ) {
1014 var selected cnpgSource
1115 for _ , candidate := range cnpgSources () {
1216 if candidate .Name == target {
@@ -19,14 +23,14 @@ func observeCNPGMigration(ctx context.Context, c client, target, source string)
1923 if err := sourceCurrent (ctx , c .run , source ); err != nil {
2024 return cnpgObservation {}, err
2125 }
22- before , err := c .readCNPGObservation (ctx , selected )
26+ before , err := c .readCNPGObservationWithRetention (ctx , selected , retainedStandby )
2327 if err != nil {
2428 return cnpgObservation {}, err
2529 }
2630 if err = c .readCNPGPhysicalState (ctx , & before ); err != nil {
2731 return cnpgObservation {}, err
2832 }
29- after , err := c .readCNPGObservation (ctx , selected )
33+ after , err := c .readCNPGObservationWithRetention (ctx , selected , retainedStandby )
3034 if err != nil {
3135 return cnpgObservation {}, err
3236 }
@@ -35,7 +39,7 @@ func observeCNPGMigration(ctx context.Context, c client, target, source string)
3539 }
3640 // The final whole-cluster read follows the final SQL process bracket. A
3741 // switchover during the last command must not escape through an older read.
38- final , err := c .readCNPGObservation (ctx , selected )
42+ final , err := c .readCNPGObservationWithRetention (ctx , selected , retainedStandby )
3943 if err != nil {
4044 return cnpgObservation {}, err
4145 }
@@ -51,6 +55,10 @@ func observeCNPGMigration(ctx context.Context, c client, target, source string)
5155
5256// readCNPGObservation obtains an unfiltered complete namespace Pod inventory.
5357func (c client ) readCNPGObservation (ctx context.Context , selected cnpgSource ) (cnpgObservation , error ) {
58+ return c .readCNPGObservationWithRetention (ctx , selected , "" )
59+ }
60+
61+ func (c client ) readCNPGObservationWithRetention (ctx context.Context , selected cnpgSource , retainedStandby string ) (cnpgObservation , error ) {
5462 cluster , err := c .get (ctx , "cluster.postgresql.cnpg.io" , selected .Namespace , selected .Name , false )
5563 if err != nil {
5664 return cnpgObservation {}, err
@@ -63,11 +71,11 @@ func (c client) readCNPGObservation(ctx context.Context, selected cnpgSource) (c
6371 if err != nil {
6472 return cnpgObservation {}, err
6573 }
66- owned , err := healthyCNPGPods (cluster , pods )
74+ owned , err := healthyCNPGPodsWithRetention (cluster , pods , retainedStandby )
6775 if err != nil {
6876 return cnpgObservation {}, err
6977 }
70- return cnpgObservation {Cluster : cluster , Pods : owned , States : map [string ]postgresState {}}, nil
78+ return cnpgObservation {Cluster : cluster , Pods : owned , States : map [string ]postgresState {}, retainedStandby : retainedStandby }, nil
7179}
7280
7381// readCNPGPhysicalState captures the primary barrier before the standbys.
0 commit comments