Skip to content

Commit 1054cfc

Browse files
committed
Merge branch 'AbhiK_lb_fix' into 'master'
Showing FQDN of LB if it's ingress IP is not available See merge request rac-docker-dev/oracle-database-operator!216
2 parents 269c466 + a42d805 commit 1054cfc

File tree

2 files changed

+17
-7
lines changed

2 files changed

+17
-7
lines changed

controllers/database/oraclerestdataservice_controller.go

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -855,13 +855,18 @@ func (r *OracleRestDataServiceReconciler) createSVC(ctx context.Context, req ctr
855855
m.Status.ServiceIP = ""
856856
if m.Spec.LoadBalancer {
857857
if len(svc.Status.LoadBalancer.Ingress) > 0 {
858-
m.Status.DatabaseApiUrl = "https://" + svc.Status.LoadBalancer.Ingress[0].IP + ":" +
858+
// 'lbAddress' will contain the Fully Qualified Hostname of the LB. If the hostname is not available it will contain the IP address of the LB
859+
lbAddress := svc.Status.LoadBalancer.Ingress[0].Hostname
860+
if lbAddress == "" {
861+
lbAddress = svc.Status.LoadBalancer.Ingress[0].IP
862+
}
863+
m.Status.DatabaseApiUrl = "https://" + lbAddress + ":" +
859864
fmt.Sprint(svc.Spec.Ports[0].Port) + "/ords/" + n.Status.Pdbname + "/_/db-api/stable/"
860-
m.Status.ServiceIP = svc.Status.LoadBalancer.Ingress[0].IP
861-
m.Status.DatabaseActionsUrl = "https://" + svc.Status.LoadBalancer.Ingress[0].IP + ":" +
865+
m.Status.ServiceIP = lbAddress
866+
m.Status.DatabaseActionsUrl = "https://" + lbAddress + ":" +
862867
fmt.Sprint(svc.Spec.Ports[0].Port) + "/ords/sql-developer"
863868
if m.Status.ApexConfigured {
864-
m.Status.ApxeUrl = "https://" + svc.Status.LoadBalancer.Ingress[0].IP + ":" +
869+
m.Status.ApxeUrl = "https://" + lbAddress + ":" +
865870
fmt.Sprint(svc.Spec.Ports[0].Port) + "/ords/" + n.Status.Pdbname + "/apex"
866871
}
867872
}

controllers/database/singleinstancedatabase_controller.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1090,9 +1090,14 @@ func (r *SingleInstanceDatabaseReconciler) createOrReplaceSVC(ctx context.Contex
10901090
if m.Spec.LoadBalancer {
10911091
m.Status.ClusterConnectString = svc.Name + "." + svc.Namespace + ":" + fmt.Sprint(svc.Spec.Ports[0].Port) + "/" + strings.ToUpper(sid)
10921092
if len(svc.Status.LoadBalancer.Ingress) > 0 {
1093-
m.Status.ConnectString = svc.Status.LoadBalancer.Ingress[0].IP + ":" + fmt.Sprint(svc.Spec.Ports[0].Port) + "/" + strings.ToUpper(sid)
1094-
m.Status.PdbConnectString = svc.Status.LoadBalancer.Ingress[0].IP + ":" + fmt.Sprint(svc.Spec.Ports[0].Port) + "/" + strings.ToUpper(pdbName)
1095-
m.Status.OemExpressUrl = "https://" + svc.Status.LoadBalancer.Ingress[0].IP + ":" + fmt.Sprint(svc.Spec.Ports[1].Port) + "/em"
1093+
// 'lbAddress' will contain the Fully Qualified Hostname of the LB. If the hostname is not available it will contain the IP address of the LB
1094+
lbAddress := svc.Status.LoadBalancer.Ingress[0].Hostname
1095+
if lbAddress == "" {
1096+
lbAddress = svc.Status.LoadBalancer.Ingress[0].IP
1097+
}
1098+
m.Status.ConnectString = lbAddress + ":" + fmt.Sprint(svc.Spec.Ports[0].Port) + "/" + strings.ToUpper(sid)
1099+
m.Status.PdbConnectString = lbAddress + ":" + fmt.Sprint(svc.Spec.Ports[0].Port) + "/" + strings.ToUpper(pdbName)
1100+
m.Status.OemExpressUrl = "https://" + lbAddress + ":" + fmt.Sprint(svc.Spec.Ports[1].Port) + "/em"
10961101
}
10971102
return requeueN, nil
10981103
}

0 commit comments

Comments
 (0)