@@ -48,6 +48,8 @@ import (
48
48
49
49
dbapi "github.com/oracle/oracle-database-operator/apis/database/v1alpha1"
50
50
dbcommons "github.com/oracle/oracle-database-operator/commons/database"
51
+ "golang.org/x/text/cases"
52
+ "golang.org/x/text/language"
51
53
52
54
"github.com/go-logr/logr"
53
55
corev1 "k8s.io/api/core/v1"
@@ -130,7 +132,7 @@ func (r *SingleInstanceDatabaseReconciler) Reconcile(ctx context.Context, req ct
130
132
if singleInstanceDatabase .Status .Status == "" {
131
133
singleInstanceDatabase .Status .Status = dbcommons .StatusPending
132
134
if singleInstanceDatabase .Spec .Edition != "" {
133
- singleInstanceDatabase .Status .Edition = strings .Title (singleInstanceDatabase .Spec .Edition )
135
+ singleInstanceDatabase .Status .Edition = cases .Title ( language . English ). String (singleInstanceDatabase .Spec .Edition )
134
136
} else {
135
137
singleInstanceDatabase .Status .Edition = dbcommons .ValueUnavailable
136
138
}
@@ -150,7 +152,7 @@ func (r *SingleInstanceDatabaseReconciler) Reconcile(ctx context.Context, req ct
150
152
return result , nil
151
153
}
152
154
if err != nil {
153
- r .Log .Error (err ,err .Error ())
155
+ r .Log .Error (err , err .Error ())
154
156
return result , err
155
157
}
156
158
@@ -205,8 +207,6 @@ func (r *SingleInstanceDatabaseReconciler) Reconcile(ctx context.Context, req ct
205
207
}
206
208
}
207
209
208
-
209
-
210
210
if strings .ToUpper (singleInstanceDatabase .Status .Role ) == "PRIMARY" {
211
211
212
212
// Update DB config
@@ -236,17 +236,17 @@ func (r *SingleInstanceDatabaseReconciler) Reconcile(ctx context.Context, req ct
236
236
if err != nil {
237
237
return requeueY , err
238
238
}
239
-
240
- databaseOpenMode ,err := dbcommons .GetDatabaseOpenMode (readyPod , r , r .Config , ctx , req , singleInstanceDatabase .Spec .Edition )
241
-
239
+
240
+ databaseOpenMode , err := dbcommons .GetDatabaseOpenMode (readyPod , r , r .Config , ctx , req , singleInstanceDatabase .Spec .Edition )
241
+
242
242
if err != nil {
243
243
r .Log .Error (err , err .Error ())
244
244
return requeueY , err
245
245
}
246
246
r .Log .Info ("DB openMode Output" )
247
247
r .Log .Info (databaseOpenMode )
248
248
if databaseOpenMode == "READ_ONLY" {
249
- out , err := dbcommons .ExecCommand (r , r .Config , readyPod .Name , readyPod .Namespace , "" , ctx , req , false , "bash" , "-c" ,fmt .Sprintf ("echo -e \" %s\" | %s" ,dbcommons .ModifyStdbyDBOpenMode ,dbcommons .SQLPlusCLI ))
249
+ out , err := dbcommons .ExecCommand (r , r .Config , readyPod .Name , readyPod .Namespace , "" , ctx , req , false , "bash" , "-c" , fmt .Sprintf ("echo -e \" %s\" | %s" , dbcommons .ModifyStdbyDBOpenMode , dbcommons .SQLPlusCLI ))
250
250
if err != nil {
251
251
r .Log .Error (err , err .Error ())
252
252
return requeueY , err
@@ -398,7 +398,7 @@ func (r *SingleInstanceDatabaseReconciler) validate(m *dbapi.SingleInstanceDatab
398
398
399
399
// If Express/Free Edition, ensure Replicas=1
400
400
if (m .Spec .Edition == "express" || m .Spec .Edition == "free" ) && m .Spec .Replicas > 1 {
401
- eventMsgs = append (eventMsgs , m .Spec .Edition + " edition supports only one replica" )
401
+ eventMsgs = append (eventMsgs , m .Spec .Edition + " edition supports only one replica" )
402
402
}
403
403
// If no persistence, ensure Replicas=1
404
404
if m .Spec .Persistence .Size == "" && m .Spec .Replicas > 1 {
@@ -422,10 +422,10 @@ func (r *SingleInstanceDatabaseReconciler) validate(m *dbapi.SingleInstanceDatab
422
422
eventMsgs = append (eventMsgs , "cloneFrom cannot be updated" )
423
423
}
424
424
if (m .Spec .Edition == "express" || m .Spec .Edition == "free" ) && m .Spec .CloneFrom != "" {
425
- eventMsgs = append (eventMsgs , "cloning not supported for " + m .Spec .Edition + " edition" )
425
+ eventMsgs = append (eventMsgs , "cloning not supported for " + m .Spec .Edition + " edition" )
426
426
}
427
427
if (m .Spec .Edition == "express" || m .Spec .Edition == "free" ) && m .Spec .PrimaryDatabaseRef != "" && m .Spec .CreateAsStandby {
428
- eventMsgs = append (eventMsgs , "Standby database creation is not supported for " + m .Spec .Edition + " edition" )
428
+ eventMsgs = append (eventMsgs , "Standby database creation is not supported for " + m .Spec .Edition + " edition" )
429
429
}
430
430
if m .Status .OrdsReference != "" && m .Status .Persistence .Size != "" && m .Status .Persistence != m .Spec .Persistence {
431
431
eventMsgs = append (eventMsgs , "uninstall ORDS to change Peristence" )
@@ -1502,7 +1502,7 @@ func (r *SingleInstanceDatabaseReconciler) createOrReplaceSVC(ctx context.Contex
1502
1502
if sid == "" || pdbName == "" || edition == "" {
1503
1503
return requeueN , nil
1504
1504
}
1505
- m .Status .Edition = strings .Title (edition )
1505
+ m .Status .Edition = cases .Title ( language . English ). String (edition )
1506
1506
}
1507
1507
1508
1508
if m .Spec .LoadBalancer {
@@ -2050,27 +2050,26 @@ func (r *SingleInstanceDatabaseReconciler) validateDBReadiness(m *dbapi.SingleIn
2050
2050
m .Status .ReleaseUpdate = version
2051
2051
}
2052
2052
}
2053
- dbMajorVersion , err := strconv .Atoi (strings .Split (m .Status .ReleaseUpdate ,"." )[0 ])
2053
+ dbMajorVersion , err := strconv .Atoi (strings .Split (m .Status .ReleaseUpdate , "." )[0 ])
2054
2054
if err != nil {
2055
2055
r .Log .Error (err , err .Error ())
2056
2056
return requeueY , readyPod , err
2057
2057
}
2058
2058
r .Log .Info ("DB Major Version is " + strconv .Itoa (dbMajorVersion ))
2059
2059
// Validating that free edition of the database is only supported from database 23c onwards
2060
- if ( m .Spec .Edition == "free" && dbMajorVersion < 23 ) {
2061
- r . Log . Info ( " Oracle Database Free is only supported from version 23c onwards")
2062
- r .Recorder .Eventf (m , corev1 .EventTypeWarning , "Spec Error" , "Oracle Database Free is only supported from version 23c onwards" )
2060
+ if m .Spec .Edition == "free" && dbMajorVersion < 23 {
2061
+ errMsg := "the Oracle Database Free is only available from version 23c onwards"
2062
+ r .Recorder .Eventf (m , corev1 .EventTypeWarning , "Spec Error" , errMsg )
2063
2063
m .Status .Status = dbcommons .StatusError
2064
- return requeueN , readyPod , errors .New ("Oracle Database Free is only supported from version 23c onwards" )
2064
+ return requeueN , readyPod , errors .New (errMsg )
2065
2065
}
2066
- // Checking if OEM is supported in the provided Database version
2067
- if ( dbMajorVersion >= 23 ) {
2066
+ // Checking if OEM is supported in the provided Database version
2067
+ if dbMajorVersion >= 23 {
2068
2068
m .Status .OemExpressUrl = dbcommons .ValueUnavailable
2069
2069
} else {
2070
2070
m .Status .OemExpressUrl = oemExpressUrl
2071
2071
}
2072
2072
2073
-
2074
2073
if strings .ToUpper (m .Status .Role ) == "PRIMARY" && m .Status .DatafilesPatched != "true" {
2075
2074
eventReason := "Datapatch Pending"
2076
2075
eventMsg := "datapatch execution pending"
@@ -2647,7 +2646,6 @@ func (r *SingleInstanceDatabaseReconciler) manageSingleInstanceDatabaseDeletion(
2647
2646
m * dbapi.SingleInstanceDatabase ) (ctrl.Result , error ) {
2648
2647
log := r .Log .WithValues ("manageSingleInstanceDatabaseDeletion" , req .NamespacedName )
2649
2648
2650
-
2651
2649
// Check if the SingleInstanceDatabase instance is marked to be deleted, which is
2652
2650
// indicated by the deletion timestamp being set.
2653
2651
isSingleInstanceDatabaseMarkedToBeDeleted := m .GetDeletionTimestamp () != nil
@@ -2704,11 +2702,11 @@ func (r *SingleInstanceDatabaseReconciler) cleanupSingleInstanceDatabase(req ctr
2704
2702
return requeueY , nil
2705
2703
}
2706
2704
2707
- if ( m .Status .DgBrokerConfigured ) {
2705
+ if m .Status .DgBrokerConfigured {
2708
2706
eventReason := "Cannot Delete"
2709
- eventMsg := "Database cannot be deleted as it is present in a DataGuard Broker configuration"
2707
+ eventMsg := "database cannot be deleted as it is present in a DataGuard Broker configuration"
2710
2708
r .Recorder .Eventf (m , corev1 .EventTypeWarning , eventReason , eventReason )
2711
- return requeueY ,errors .New (eventMsg )
2709
+ return requeueY , errors .New (eventMsg )
2712
2710
}
2713
2711
2714
2712
// call deletePods() with zero pods in avaiable and nil readyPod to delete all pods
@@ -2864,7 +2862,7 @@ func ValidatePrimaryDatabaseForStandbyCreation(r *SingleInstanceDatabaseReconcil
2864
2862
log .Info (fmt .Sprintf ("Validating primary database %s configuration..." , primary .Name ))
2865
2863
err = ValidateDatabaseConfiguration (primary )
2866
2864
if err != nil {
2867
- r .Recorder .Eventf (stdby ,corev1 .EventTypeWarning ,"Spec Error" , "all of Archivelog, Flashback and ForceLogging modes are not enabled in the primary database " + primary .Name )
2865
+ r .Recorder .Eventf (stdby , corev1 .EventTypeWarning , "Spec Error" , "all of Archivelog, Flashback and ForceLogging modes are not enabled in the primary database " + primary .Name )
2868
2866
stdby .Status .Status = dbcommons .StatusError
2869
2867
return err
2870
2868
}
0 commit comments