@@ -18,6 +18,7 @@ import (
1818 mysqldb "github.com/percona/percona-server-mysql-operator/pkg/db"
1919 "github.com/percona/percona-server-mysql-operator/pkg/k8s"
2020 "github.com/percona/percona-server-mysql-operator/pkg/naming"
21+ "github.com/percona/percona-server-mysql-operator/pkg/xtrabackup"
2122)
2223
2324const (
@@ -130,7 +131,12 @@ func checkReadinessAsync(ctx context.Context) error {
130131 case replStatus == mysqldb .ReplicationStatusActive && ! readOnly :
131132 return errors .New ("replica is not read only" )
132133 case replStatus == mysqldb .ReplicationStatusStopped :
133- return errors .New ("replication is stopped" )
134+ // If replication is stopped, check if it is because of a running backup
135+ if running , err := isBackupRunning (ctx ); err != nil {
136+ return errors .Wrap (err , "check backup running" )
137+ } else if ! running {
138+ return errors .New ("replication is stopped" )
139+ }
134140 }
135141 return nil
136142}
@@ -327,3 +333,16 @@ func fileExists(name string) (bool, error) {
327333 }
328334 return true , nil
329335}
336+
337+ func isBackupRunning (ctx context.Context ) (bool , error ) {
338+ backupsEnabled := os .Getenv (naming .EnvBackupsEnabled )
339+ if backupsEnabled != "true" {
340+ return false , nil
341+ }
342+ sc := xtrabackup .NewSidecarClient ("localhost" )
343+ bcp , err := sc .GetRunningBackupConfig (ctx )
344+ if err != nil {
345+ return false , errors .Wrap (err , "get running backup config" )
346+ }
347+ return bcp != nil , nil
348+ }
0 commit comments