@@ -197,22 +197,22 @@ func (r *SingleInstanceDatabaseReconciler) Reconcile(ctx context.Context, req ct
197197 }
198198 }
199199
200- // Configure TCPS
201- result , err = r .configTcps (singleInstanceDatabase , readyPod , ctx , req )
200+ // Update DB config
201+ result , err = r .updateDBConfig (singleInstanceDatabase , readyPod , ctx , req )
202202 if result .Requeue {
203203 r .Log .Info ("Reconcile queued" )
204204 return result , nil
205205 }
206206
207- // Update DB config
208- result , err = r .updateDBConfig (singleInstanceDatabase , readyPod , ctx , req )
207+ // Update Init Parameters
208+ result , err = r .updateInitParameters (singleInstanceDatabase , readyPod , ctx , req )
209209 if result .Requeue {
210210 r .Log .Info ("Reconcile queued" )
211211 return result , nil
212212 }
213213
214- // Update Init Parameters
215- result , err = r .updateInitParameters (singleInstanceDatabase , readyPod , ctx , req )
214+ // Configure TCPS
215+ result , err = r .configTcps (singleInstanceDatabase , readyPod , ctx , req )
216216 if result .Requeue {
217217 r .Log .Info ("Reconcile queued" )
218218 return result , nil
@@ -1114,7 +1114,7 @@ func (r *SingleInstanceDatabaseReconciler) createOrReplaceSVC(ctx context.Contex
11141114 extSvcPort = extSvc .Spec .Ports [1 ].NodePort
11151115 }
11161116
1117- if extSvc .Spec .Type != extSvcType || extSvcPort != svcPort || extSvc .Spec .Ports [1 ].TargetPort .IntVal != extSvcTargetPort {
1117+ if extSvc .Spec .Type != extSvcType || ( m . Spec . ServicePort != 0 && extSvcPort != svcPort ) || extSvc .Spec .Ports [1 ].TargetPort .IntVal != extSvcTargetPort {
11181118 // Deleting th service
11191119 log .Info ("Deleting service" , "name" , extSvcName )
11201120 err := r .Delete (ctx , extSvc )
@@ -1794,16 +1794,15 @@ func (r *SingleInstanceDatabaseReconciler) updateClientWallet(m *dbapi.SingleIns
17941794 port = extSvc .Spec .Ports [1 ].NodePort
17951795 }
17961796 }
1797- if host != "" && host != m .Status .DbHostname && port != int32 (m .Status .DbPort ) {
1798- _ , err := dbcommons .ExecCommand (r , r .Config , readyPod .Name , readyPod .Namespace , "" ,
1799- ctx , req , false , "bash" , "-c" , fmt .Sprintf (dbcommons .ClientWalletUpdate , host , port ))
1800- if err != nil {
1801- r .Log .Error (err , err .Error ())
1802- return err
1803- }
1804- m .Status .DbHostname = host
1805- m .Status .DbPort = int (port )
1797+
1798+ r .Log .Info ("Updating the client wallet..." )
1799+ _ , err := dbcommons .ExecCommand (r , r .Config , readyPod .Name , readyPod .Namespace , "" ,
1800+ ctx , req , false , "bash" , "-c" , fmt .Sprintf (dbcommons .ClientWalletUpdate , host , port ))
1801+ if err != nil {
1802+ r .Log .Error (err , err .Error ())
1803+ return err
18061804 }
1805+
18071806 } else {
18081807 r .Log .Info ("Unable to get the service while updating the clientWallet" , "Service.Namespace" , extSvc .Namespace , "Service.Name" , extSvcName )
18091808 return getExtSvcErr
@@ -1842,8 +1841,9 @@ func (r *SingleInstanceDatabaseReconciler) configTcps(m *dbapi.SingleInstanceDat
18421841 eventMsg = "TCPS Enabled."
18431842 r .Recorder .Eventf (m , corev1 .EventTypeNormal , eventReason , eventMsg )
18441843
1845- // 26040h = 1085 days
1846- futureRequeue = ctrl.Result {Requeue : true , RequeueAfter : func () time.Duration { requeueDuration , _ := time .ParseDuration ("26040h" ); return requeueDuration }()}
1844+ requeueDuration , _ := time .ParseDuration (m .Spec .CertRenewDuration )
1845+ requeueDuration += func () time.Duration { requeueDuration , _ := time .ParseDuration ("1s" ); return requeueDuration }()
1846+ futureRequeue = ctrl.Result {Requeue : true , RequeueAfter : requeueDuration }
18471847
18481848 // update clientWallet
18491849 err = r .updateClientWallet (m , readyPod , ctx , req )
@@ -1879,7 +1879,7 @@ func (r *SingleInstanceDatabaseReconciler) configTcps(m *dbapi.SingleInstanceDat
18791879 // Certificates are renewed when 10 days remain for certs expiry
18801880 certCreationTimestamp , _ := time .Parse (time .RFC3339 , m .Status .CertCreationTimestamp )
18811881 duration := time .Since (certCreationTimestamp )
1882- allowdDuration , _ := time .ParseDuration ("26000h" )
1882+ allowdDuration , _ := time .ParseDuration (m . Spec . CertRenewDuration )
18831883 if duration > allowdDuration {
18841884 m .Status .Status = dbcommons .StatusUpdating
18851885 r .Status ().Update (ctx , m )
@@ -1898,8 +1898,16 @@ func (r *SingleInstanceDatabaseReconciler) configTcps(m *dbapi.SingleInstanceDat
18981898 eventMsg := "TCPS Certificates Renewed at time %s,"
18991899 r .Recorder .Eventf (m , corev1 .EventTypeNormal , eventReason , eventMsg , time .Now ().Format (time .RFC3339 ))
19001900
1901- // 26040h = 1085 days
1902- futureRequeue = ctrl.Result {Requeue : true , RequeueAfter : func () time.Duration { requeueDuration , _ := time .ParseDuration ("26040h" ); return requeueDuration }()}
1901+ requeueDuration , _ := time .ParseDuration (m .Spec .CertRenewDuration )
1902+ requeueDuration += func () time.Duration { requeueDuration , _ := time .ParseDuration ("1s" ); return requeueDuration }()
1903+ futureRequeue = ctrl.Result {Requeue : true , RequeueAfter : requeueDuration }
1904+ }
1905+ if m .Status .CertRenewDuration != m .Spec .CertRenewDuration {
1906+ requeueDuration , _ := time .ParseDuration (m .Spec .CertRenewDuration )
1907+ requeueDuration += func () time.Duration { requeueDuration , _ := time .ParseDuration ("1s" ); return requeueDuration }()
1908+ futureRequeue = ctrl.Result {Requeue : true , RequeueAfter : requeueDuration }
1909+
1910+ m .Status .CertRenewDuration = m .Spec .CertRenewDuration
19031911 }
19041912 // update clientWallet
19051913 err := r .updateClientWallet (m , readyPod , ctx , req )
0 commit comments