@@ -618,6 +618,18 @@ func (r *PDBReconciler) createPDB(ctx context.Context, req ctrl.Request, pdb *db
618
618
return err
619
619
}
620
620
621
+ /* Prevent creating an existing pdb */
622
+ err = r .getPDBState (ctx , req , pdb )
623
+ if err != nil {
624
+ if apierrors .IsNotFound (err ) {
625
+ log .Info ("Check PDB not existence completed" , "PDB Name" , pdb .Spec .PDBName )
626
+ }
627
+
628
+ } else {
629
+ log .Info ("Database already exists " , "PDB Name" , pdb .Spec .PDBName )
630
+ return nil
631
+ }
632
+
621
633
values := map [string ]string {
622
634
"method" : "CREATE" ,
623
635
"pdb_name" : pdb .Spec .PDBName ,
@@ -679,6 +691,10 @@ func (r *PDBReconciler) createPDB(ctx context.Context, req ctrl.Request, pdb *db
679
691
/************************************************/
680
692
func (r * PDBReconciler ) clonePDB (ctx context.Context , req ctrl.Request , pdb * dbapi.PDB ) error {
681
693
694
+ if pdb .Spec .PDBName == pdb .Spec .SrcPDBName {
695
+ return nil
696
+ }
697
+
682
698
log := r .Log .WithValues ("clonePDB" , req .NamespacedName )
683
699
684
700
var err error
@@ -688,6 +704,18 @@ func (r *PDBReconciler) clonePDB(ctx context.Context, req ctrl.Request, pdb *dba
688
704
return err
689
705
}
690
706
707
+ /* Prevent cloning an existing pdb */
708
+ err = r .getPDBState (ctx , req , pdb )
709
+ if err != nil {
710
+ if apierrors .IsNotFound (err ) {
711
+ log .Info ("Check PDB not existence completed" , "PDB Name" , pdb .Spec .PDBName )
712
+ }
713
+
714
+ } else {
715
+ log .Info ("Database already exists " , "PDB Name" , pdb .Spec .PDBName )
716
+ return nil
717
+ }
718
+
691
719
values := map [string ]string {
692
720
"method" : "CLONE" ,
693
721
"clonePDBName" : pdb .Spec .PDBName ,
0 commit comments