Skip to content

Commit a22970d

Browse files
author
abhisbyk
committed
Added port change validation, status to Updating while enabling/disabling tcps
Signed-off-by: abhisbyk <[email protected]>
1 parent 4e13046 commit a22970d

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

apis/database/v1alpha1/singleinstancedatabase_webhook.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,10 @@ func (r *SingleInstanceDatabase) ValidateUpdate(oldRuntimeObject runtime.Object)
297297
allErrs = append(allErrs,
298298
field.Forbidden(field.NewPath("spec").Child("persistence"), "uninstall ORDS to change Persistence"))
299299
}
300+
if old.Status.IsTcpsEnabled && old.Status.TcpsPort != r.Spec.TcpsPort {
301+
allErrs = append(allErrs,
302+
field.Forbidden(field.NewPath("spec").Child("tcpsPort"), "cannot change TCPS port, please disable TCPS first then enable it with newly desired port"))
303+
}
300304
if len(allErrs) == 0 {
301305
return nil
302306
}

controllers/database/singleinstancedatabase_controller.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1763,6 +1763,9 @@ func (r *SingleInstanceDatabaseReconciler) configTcps(m *dbapi.SingleInstanceDat
17631763
eventReason := "Configuring TCPS"
17641764
if m.Spec.EnableTCPS && !m.Status.IsTcpsEnabled {
17651765
// Enable TCPS
1766+
m.Status.Status = dbcommons.StatusUpdating
1767+
r.Status().Update(ctx, m)
1768+
17661769
eventMsg := "Enabling TCPS in the database..."
17671770
r.Recorder.Eventf(m, corev1.EventTypeNormal, eventReason, eventMsg)
17681771

@@ -1777,6 +1780,7 @@ func (r *SingleInstanceDatabaseReconciler) configTcps(m *dbapi.SingleInstanceDat
17771780
// Updating the Status and publishing the event
17781781
m.Status.CertCreationTimestamp = time.Now().Format(time.RFC3339)
17791782
m.Status.IsTcpsEnabled = true
1783+
m.Status.TcpsPort = m.Spec.TcpsPort
17801784
r.Status().Update(ctx, m)
17811785

17821786
eventMsg = "TCPS Enabled."
@@ -1787,6 +1791,9 @@ func (r *SingleInstanceDatabaseReconciler) configTcps(m *dbapi.SingleInstanceDat
17871791

17881792
} else if !m.Spec.EnableTCPS && m.Status.IsTcpsEnabled {
17891793
// Disable TCPS
1794+
m.Status.Status = dbcommons.StatusUpdating
1795+
r.Status().Update(ctx, m)
1796+
17901797
eventMsg := "Disabling TCPS in the database..."
17911798
r.Recorder.Eventf(m, corev1.EventTypeNormal, eventReason, eventMsg)
17921799

@@ -1799,6 +1806,7 @@ func (r *SingleInstanceDatabaseReconciler) configTcps(m *dbapi.SingleInstanceDat
17991806

18001807
// Updating the Status and publishing the event
18011808
m.Status.CertCreationTimestamp = ""
1809+
m.Status.TcpsPort = 0
18021810
m.Status.IsTcpsEnabled = false
18031811
r.Status().Update(ctx, m)
18041812

@@ -1812,6 +1820,9 @@ func (r *SingleInstanceDatabaseReconciler) configTcps(m *dbapi.SingleInstanceDat
18121820
duration := time.Since(certCreationTimestamp)
18131821
allowdDuration, _ := time.ParseDuration("26000h")
18141822
if duration > allowdDuration {
1823+
m.Status.Status = dbcommons.StatusUpdating
1824+
r.Status().Update(ctx, m)
1825+
18151826
_, err := dbcommons.ExecCommand(r, r.Config, readyPod.Name, readyPod.Namespace, "",
18161827
ctx, req, false, "bash", "-c", fmt.Sprintf(dbcommons.EnableTcpsCMD, m.Spec.TcpsPort))
18171828
if err != nil {

0 commit comments

Comments
 (0)