Skip to content

Commit 7120d8d

Browse files
committed
Merge branch 'idesai_bug_fix' into 'master'
Bug Fixes DG and SIDB controllers See merge request rac-docker-dev/oracle-database-operator!253
2 parents 3930f51 + 04c0c0f commit 7120d8d

File tree

3 files changed

+73
-6
lines changed

3 files changed

+73
-6
lines changed

apis/database/v1alpha1/singleinstancedatabase_webhook.go

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ package v1alpha1
4040

4141
import (
4242
"strings"
43-
"time"
43+
"time"
44+
"strconv"
4445

4546
dbcommons "github.com/oracle/oracle-database-operator/commons/database"
4647

@@ -360,6 +361,43 @@ func (r *SingleInstanceDatabase) ValidateUpdate(oldRuntimeObject runtime.Object)
360361
if !ok {
361362
return nil
362363
}
364+
365+
if (old.Status.Role != dbcommons.ValueUnavailable && old.Status.Role != "PRIMARY") {
366+
// Restriciting Patching of secondary databases archiveLog, forceLog, flashBack
367+
statusArchiveLog, _ := strconv.ParseBool(old.Status.ArchiveLog)
368+
if statusArchiveLog != r.Spec.ArchiveLog {
369+
allErrs = append(allErrs,
370+
field.Forbidden(field.NewPath("spec").Child("archiveLog"), "cannot be changed"))
371+
}
372+
statusFlashBack, _ := strconv.ParseBool(old.Status.FlashBack)
373+
if statusFlashBack != r.Spec.FlashBack {
374+
allErrs = append(allErrs,
375+
field.Forbidden(field.NewPath("spec").Child("flashBack"), "cannot be changed"))
376+
}
377+
statusForceLogging, _ := strconv.ParseBool(old.Status.ForceLogging)
378+
if statusForceLogging != r.Spec.ForceLogging {
379+
allErrs = append(allErrs,
380+
field.Forbidden(field.NewPath("spec").Child("forceLog"), "cannot be changed"))
381+
}
382+
// Restriciting Patching of secondary databases InitParams
383+
if old.Status.InitParams.SgaTarget != r.Spec.InitParams.SgaTarget {
384+
allErrs = append(allErrs,
385+
field.Forbidden(field.NewPath("spec").Child("InitParams").Child("sgaTarget"), "cannot be changed"))
386+
}
387+
if old.Status.InitParams.PgaAggregateTarget != r.Spec.InitParams.PgaAggregateTarget {
388+
allErrs = append(allErrs,
389+
field.Forbidden(field.NewPath("spec").Child("InitParams").Child("pgaAggregateTarget"), "cannot be changed"))
390+
}
391+
if old.Status.InitParams.CpuCount != r.Spec.InitParams.CpuCount {
392+
allErrs = append(allErrs,
393+
field.Forbidden(field.NewPath("spec").Child("InitParams").Child("cpuCount"), "cannot be changed"))
394+
}
395+
if old.Status.InitParams.Processes != r.Spec.InitParams.Processes {
396+
allErrs = append(allErrs,
397+
field.Forbidden(field.NewPath("spec").Child("InitParams").Child("processes"), "cannot be changed"))
398+
}
399+
}
400+
363401
if old.Status.DatafilesCreated == "true" && (old.Status.PrebuiltDB != r.Spec.Image.PrebuiltDB) {
364402
allErrs = append(allErrs,
365403
field.Forbidden(field.NewPath("spec").Child("image").Child("prebuiltDB"), "cannot be changed"))

controllers/database/singleinstancedatabase_controller.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,10 @@ func (r *SingleInstanceDatabaseReconciler) Reconcile(ctx context.Context, req ct
205205
}
206206
}
207207

208+
209+
208210
if strings.ToUpper(singleInstanceDatabase.Status.Role) == "PRIMARY" {
211+
209212
// Update DB config
210213
result, err = r.updateDBConfig(singleInstanceDatabase, readyPod, ctx, req)
211214
if result.Requeue {
@@ -644,7 +647,7 @@ func (r *SingleInstanceDatabaseReconciler) instantiatePodSpec(m *dbapi.SingleIns
644647
VolumeSource: corev1.VolumeSource{
645648
Secret: &corev1.SecretVolumeSource{
646649
SecretName: m.Spec.AdminPassword.SecretName,
647-
Optional: func() *bool { i := (m.Spec.Edition != "express"); return &i }(),
650+
Optional: func() *bool { i := (m.Spec.Edition != "express" && m.Spec.Edition != "free"); return &i }(),
648651
Items: []corev1.KeyToPath{{
649652
Key: m.Spec.AdminPassword.SecretKey,
650653
Path: "oracle_pwd",
@@ -777,7 +780,7 @@ func (r *SingleInstanceDatabaseReconciler) instantiatePodSpec(m *dbapi.SingleIns
777780
Name: "datamount",
778781
})
779782
}
780-
if m.Spec.Edition == "express" || m.Spec.Image.PrebuiltDB {
783+
if m.Spec.Edition == "express" || m.Spec.Edition == "free" || m.Spec.Image.PrebuiltDB {
781784
// mounts pwd as secrets for express edition
782785
// or prebuilt db
783786
mounts = append(mounts, corev1.VolumeMount{
@@ -2855,6 +2858,7 @@ func ValidatePrimaryDatabaseForStandbyCreation(r *SingleInstanceDatabaseReconcil
28552858
log.Info(fmt.Sprintf("Validating primary database %s configuration...", primary.Name))
28562859
err = ValidateDatabaseConfiguration(primary)
28572860
if err != nil {
2861+
r.Recorder.Eventf(stdby,corev1.EventTypeWarning,"Spec Error", "all of Archivelog, Flashback and ForceLogging modes are not enabled in the primary database " + primary.Name)
28582862
stdby.Status.Status = dbcommons.StatusError
28592863
return err
28602864
}

docs/sidb/README.md

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ Oracle Database Operator for Kubernetes (`OraOperator`) includes the Single Inst
88
* [New Database](#new-database)
99
* [Pre-built Database](#pre-built-database)
1010
* [XE Database](#xe-database)
11+
* [Free Database](#free-database)
1112
* [Connecting to Database](#connecting-to-database)
1213
* [Database Persistence (Storage) Configuration Options](#database-persistence-storage-configuration-options)
1314
* [Dynamic Persistence](#dynamic-persistence)
@@ -205,8 +206,21 @@ This command pulls the XE image uploaded on the [Oracle Container Registry](http
205206
- For XE database, only single replica mode (i.e. `replicas: 1`) is supported.
206207
- For XE database, you **cannot change** the init parameters i.e. `cpuCount, processes, sgaTarget or pgaAggregateTarget`.
207208
209+
#### Free Database
210+
To provision new Oracle Database Free database, use the sample **[config/samples/sidb/singleinstancedatabase_free.yaml](../../config/samples/sidb/singleinstancedatabase_free.yaml)** file. For example:
211+
212+
kubectl apply -f singleinstancedatabase_free.yaml
213+
214+
This command pulls the Free image uploaded on the [Oracle Container Registry](https://container-registry.oracle.com/).
215+
216+
**NOTE:**
217+
- Provisioning Oracle Database Free is supported for release 23c (23.2.0) and later releases.
218+
- For Free database, only single replica mode (i.e. `replicas: 1`) is supported.
219+
- For Free database, you **cannot change** the init parameters i.e. `cpuCount, processes, sgaTarget or pgaAggregateTarget`.
220+
- Oracle Enterprise Manager is not supported from release 23c and later release.
221+
208222
#### Additional Information
209-
You are required to specify the database admin password secret in the corresponding YAML file. The default values mentioned in the `adminPassword.secretName` fields of [singleinstancedatabase_create.yaml](../../config/samples/sidb/singleinstancedatabase_create.yaml), [singleinstancedatabase_prebuiltdb.yaml](../../config/samples/sidb/singleinstancedatabase_prebuiltdb.yaml) and [singleinstancedatabase_express.yaml](../../config/samples/sidb/singleinstancedatabase_express.yaml) files are `db-admin-secret`, `prebuiltdb-admin-secret`, and `xedb-admin-secret` respectively. You can create these secrets manually by using the sample command mentioned in the [Template YAML](#template-yaml) section. Alternatively, you can create these secrets by filling the passwords in the **[singleinstancedatabase_secrets.yaml](../../config/samples/sidb/singleinstancedatabase_secrets.yaml)** file and applying it using the command below:
223+
You are required to specify the database admin password secret in the corresponding YAML file. The default values mentioned in the `adminPassword.secretName` fields of [singleinstancedatabase_create.yaml](../../config/samples/sidb/singleinstancedatabase_create.yaml), [singleinstancedatabase_prebuiltdb.yaml](../../config/samples/sidb/singleinstancedatabase_prebuiltdb.yaml), [singleinstancedatabase_express.yaml](../../config/samples/sidb/singleinstancedatabase_express.yaml) and [singleinstancedatabse_free.yaml](../../config/samples/sidb/singleinstancedatabase_free.yaml) files are `db-admin-secret`, `prebuiltdb-admin-secret`, `xedb-admin-secret` and `free-admin-secret` respectively. You can create these secrets manually by using the sample command mentioned in the [Template YAML](#template-yaml) section. Alternatively, you can create these secrets by filling the passwords in the **[singleinstancedatabase_secrets.yaml](../../config/samples/sidb/singleinstancedatabase_secrets.yaml)** file and applying it using the command below:
210224
211225
```bash
212226
kubectl apply -f singleinstancedatabase_secrets.yaml
@@ -580,7 +594,7 @@ Before creating a standby, ArchiveLog, FlashBack, and ForceLog on primary Single
580594
To create a standby database, edit and apply the sample yaml file [config/samples/sidb/singleinstancedatabase_standby.yaml](../../config/samples/sidb/singleinstancedatabase_standby.yaml).
581595

582596
**NOTE:**
583-
- The `adminPassword` field of the above [config/samples/sidb/singleinstancedatabase_standby.yaml](../../config/samples/sidb/singleinstancedatabase_standby.yaml) contains an admin password secret of the primary database ref for Standby Database creation. This secret gets deleted after the database pod becomes ready for security reasons.
597+
- The `adminPassword` field of the above [config/samples/sidb/singleinstancedatabase_standby.yaml](../../config/samples/sidb/singleinstancedatabase_standby.yaml) contains an admin password secret of the primary database ref for Standby Database creation. This secret will get deleted after the database pod becomes ready if the `keepSecret` attribute of `adminPassword` field is set to `false`. By default `keepSecret` is set to `true`.
584598
- Mention referred primary database in `.spec.primaryDatabaseRef` in the yaml file.
585599
- `.spec.createAsStandby` field of the yaml file should be true.
586600
- Database configuration like `Archivelog`, `FlashBack`, `ForceLog`, `TCPS connections` are not supported for standby database.
@@ -757,7 +771,18 @@ $ kubectl delete dataguardbroker dgbroker-sample
757771

758772
**NOTE :** You can only delete DataGuard broker when role of `.spec.primaryDatabaseRef` is PRIMARY
759773

760-
### Delete a standby database with dataguard broker configured
774+
### Patch primary and standby databases in dataguard configuration
775+
776+
Databases (both primary and standby) running in you cluster and managed by the Oracle Database operator can be patched or rolled back between release updates of the same major release. While patching databases configured with the dataguard broker you need to first patch the Primary database followed by seconday/standby databases in any order.
777+
778+
To patch an existing database, edit and apply the **[config/samples/sidb/singleinstancedatabase_patch.yaml](../../config/samples/sidb/singleinstancedatabase_patch.yaml)** file of the database resource/object either by specifying a new release update for image attributes, or by running the following command:
779+
780+
```sh
781+
kubectl --type=merge -p '{"spec":{"image":{"pullFrom":"patched-image:tag","pullSecrets":"pull-secret"}}}' patch singleinstancedatabase <database-name>
782+
783+
```
784+
785+
### Delete a database in dataguard configuration
761786

762787
To delete a standby database in a dataguard configuration, delete the dataguardbroker resource first followed by the standby database
763788

0 commit comments

Comments
 (0)