Skip to content

Commit 2367ada

Browse files
committed
Merge branch 'mmalvezz' into 'master'
Correct clone/create defect See merge request rac-docker-dev/oracle-database-operator!237
2 parents 7df3fbf + d686e19 commit 2367ada

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

controllers/database/pdb_controller.go

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -618,6 +618,18 @@ func (r *PDBReconciler) createPDB(ctx context.Context, req ctrl.Request, pdb *db
618618
return err
619619
}
620620

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+
621633
values := map[string]string{
622634
"method": "CREATE",
623635
"pdb_name": pdb.Spec.PDBName,
@@ -679,6 +691,10 @@ func (r *PDBReconciler) createPDB(ctx context.Context, req ctrl.Request, pdb *db
679691
/************************************************/
680692
func (r *PDBReconciler) clonePDB(ctx context.Context, req ctrl.Request, pdb *dbapi.PDB) error {
681693

694+
if pdb.Spec.PDBName == pdb.Spec.SrcPDBName {
695+
return nil
696+
}
697+
682698
log := r.Log.WithValues("clonePDB", req.NamespacedName)
683699

684700
var err error
@@ -688,6 +704,18 @@ func (r *PDBReconciler) clonePDB(ctx context.Context, req ctrl.Request, pdb *dba
688704
return err
689705
}
690706

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+
691719
values := map[string]string{
692720
"method": "CLONE",
693721
"clonePDBName": pdb.Spec.PDBName,

0 commit comments

Comments
 (0)