Skip to content

Commit c5e5f25

Browse files
committed
Enhancing logic for edition,sid,pdb fetching and logs
1 parent 7bcd33f commit c5e5f25

File tree

2 files changed

+17
-12
lines changed

2 files changed

+17
-12
lines changed

commons/database/utils.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -606,8 +606,8 @@ func GetSidPdbEdition(r client.Reader, config *rest.Config, ctx context.Context,
606606
log.Error(err, err.Error())
607607
return "", "", "", err
608608
}
609-
log.Info(out)
610-
splitstr := strings.Split(strings.TrimSpace(out), ",")
609+
log.Info("GetSidPdbEditionCMD output \n" + out)
610+
splitstr := strings.Split((strings.TrimSpace(out)), ",")
611611
return splitstr[0], splitstr[1], splitstr[2], nil
612612
}
613613
err = errors.New("ready pod name is nil")

controllers/database/singleinstancedatabase_controller.go

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1495,20 +1495,25 @@ func (r *SingleInstanceDatabaseReconciler) createOrReplaceSVC(ctx context.Contex
14951495
extSvc = svc
14961496
}
14971497

1498-
pdbName := strings.ToUpper(m.Spec.Pdbname)
1499-
sid := m.Spec.Sid
1498+
var sid, pdbName string
1499+
var getSidPdbEditionErr error
15001500
if m.Spec.Image.PrebuiltDB {
1501-
r.Log.Info("Initiliazing free database sid, pdb, edition")
1502-
edition := ""
1503-
_, _, edition, err := dbcommons.GetSidPdbEdition(r, r.Config, ctx, ctrl.Request{NamespacedName: types.NamespacedName{Namespace: m.Namespace, Name: m.Name}})
1504-
if err != nil {
1505-
return requeueY, err
1501+
r.Log.Info("Initiliazing database sid, pdb, edition for prebuilt database")
1502+
var edition string
1503+
sid, pdbName, edition, getSidPdbEditionErr = dbcommons.GetSidPdbEdition(r, r.Config, ctx, ctrl.Request{NamespacedName: types.NamespacedName{Namespace: m.Namespace, Name: m.Name}})
1504+
if getSidPdbEditionErr != nil {
1505+
return requeueY, getSidPdbEditionErr
15061506
}
1507+
r.Log.Info("Prebuilt database: %s has SID : %s, PDB : %s, EDITION: %s", m.Name, sid, pdbName, edition)
15071508
m.Status.Edition = cases.Title(language.English).String(edition)
15081509
}
1509-
1510-
r.Log.Info("Setting connect string statues")
1511-
1510+
r.Log.Info("Prebuilt database: %s has SID : %s, PDB : %s, EDITION: %s", m.Name, sid, pdbName)
1511+
if sid == "" {
1512+
sid = strings.ToUpper(m.Spec.Sid)
1513+
}
1514+
if pdbName == "" {
1515+
pdbName = strings.ToUpper(m.Spec.Pdbname)
1516+
}
15121517
if m.Spec.LoadBalancer {
15131518
m.Status.ClusterConnectString = extSvc.Name + "." + extSvc.Namespace + ":" + fmt.Sprint(extSvc.Spec.Ports[1].Port) + "/" + strings.ToUpper(sid)
15141519
if len(extSvc.Status.LoadBalancer.Ingress) > 0 {

0 commit comments

Comments
 (0)