Check if underlying storage pair is used by another clusterpair
Hold deletion of clusterpair if another clusterpair exists which is using
same storagepair
@@ -218,7 +218,24 @@ func getClusterPairSchedulerStatus(clusterPairName string, namespace string) (st
}
func (c *ClusterPairController) cleanup(clusterPair *stork_api.ClusterPair) error {
+ skipDelete := false
if clusterPair.Status.RemoteStorageID != "" {
+ // verify if any other cluster pair using the same RemoteStorageID
+ cpList, err := storkops.Instance().ListClusterPairs("")
+ if err != nil {
+ return err
+ }
+ for _, cp := range cpList.Items {
+ // No need to handle current reconciled clusterpair
+ // Since clusterPair will have deleteTimeStamp set and will be ignored
+ if cp.Status.RemoteStorageID == clusterPair.Status.RemoteStorageID &&
+ cp.DeletionTimestamp == nil {
+ skipDelete = true
+ break
+ }
+ }
+ }
+ if !skipDelete {
return c.volDriver.DeletePair(clusterPair)
}
return nil
