Skip to content

Commit d8e9e84

Browse files
committed
Merge branch 'AbhiK_tcps_bugfix5' into 'master'
Patching the svc while changing type from LB to NodePort, max cert validity 1yr See merge request rac-docker-dev/oracle-database-operator!229
2 parents f74283c + 8990cbf commit d8e9e84

File tree

7 files changed

+44
-66
lines changed

7 files changed

+44
-66
lines changed

apis/database/v1alpha1/singleinstancedatabase_webhook.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -270,12 +270,12 @@ func (r *SingleInstanceDatabase) ValidateCreate() error {
270270
field.Invalid(field.NewPath("spec").Child("tcpsCertRenewInterval"), r.Spec.TcpsCertRenewInterval,
271271
"Please provide valid string to parse the tcpsCertRenewInterval."))
272272
}
273-
maxLimit, _ := time.ParseDuration("26280h")
273+
maxLimit, _ := time.ParseDuration("8760h")
274274
minLimit, _ := time.ParseDuration("24h")
275275
if duration > maxLimit || duration < minLimit {
276276
allErrs = append(allErrs,
277277
field.Invalid(field.NewPath("spec").Child("tcpsCertRenewInterval"), r.Spec.TcpsCertRenewInterval,
278-
"Please specify tcpsCertRenewInterval in the range: 24h to 26280h"))
278+
"Please specify tcpsCertRenewInterval in the range: 24h to 8760h"))
279279
}
280280
}
281281
if len(allErrs) == 0 {

commons/database/constants.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -501,10 +501,10 @@ const ClientWalletLocation string = "/opt/oracle/oradata/clientWallet/%s"
501501

502502
// Service Patch Payloads
503503
// Three port payload: one OEM express, one TCP and one TCPS port
504-
const ThreePortPayload string = "{\"spec\": { \"ports\": [{\"name\": \"xmldb\", \"port\": 5500, \"protocol\": \"TCP\"},{%s},{%s}]}}"
504+
const ThreePortPayload string = "{\"spec\": { \"type\": \"%s\", \"ports\": [{\"name\": \"xmldb\", \"port\": 5500, \"protocol\": \"TCP\"},{%s},{%s}]}}"
505505

506506
// Two port payload: one OEM express, one TCP/TCPS port
507-
const TwoPortPayload string = "{\"spec\": { \"ports\": [{\"name\": \"xmldb\", \"port\": 5500, \"protocol\": \"TCP\"},{%s}]}}"
507+
const TwoPortPayload string = "{\"spec\": { \"type\": \"%s\", \"ports\": [{\"name\": \"xmldb\", \"port\": 5500, \"protocol\": \"TCP\"},{%s}]}}"
508508

509509
// Payload section for listener port
510510
const LsnrPort string = "\"name\": \"listener\", \"protocol\": \"TCP\", \"port\": %d, \"targetPort\": 1521"

config/crd/bases/database.oracle.com_cdbs.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,6 @@ spec:
6565
spec:
6666
description: CDBSpec defines the desired state of CDB
6767
properties:
68-
TestVariable:
69-
type: string
7068
cdbAdminPwd:
7169
description: Password for the CDB Administrator to manage PDB lifecycle
7270
properties:

config/samples/sidb/singleinstancedatabase.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,10 @@ spec:
4848
enableTCPS: false
4949

5050
## TCPS Certificate Renewal Interval: The time after which TCPS certificate will be renewed if TCPS connections are enabled.
51-
## tcpsCertRenewInterval can be in hours(h), minutes(m) and seconds(s); e.g. 17520h, 8760h etc.
52-
## Maximum value is 26280h (3 years), Minimum value is 24h; Default value is 17520h (2 years)
51+
## tcpsCertRenewInterval can be in hours(h), minutes(m) and seconds(s); e.g. 4380h, 8760h etc.
52+
## Maximum value is 8760h (1 year), Minimum value is 24h; Default value is 8760h (1 year)
5353
## If this field is commented out/removed from the yaml, it will disable the auto-renewal feature for TCPS certificate
54-
tcpsCertRenewInterval: 17520h
54+
tcpsCertRenewInterval: 8760h
5555

5656
## NA if cloning from a SourceDB (cloneFrom is set)
5757
## Specify both sgaSize and pgaSize (in MB) or dont specify both

config/samples/sidb/singleinstancedatabase_tcps.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@ spec:
3535
enableTCPS: true
3636

3737
## TCPS Certificate Renewal Interval: The time after which TCPS certificate will be renewed if TCPS connections are enabled.
38-
## tcpsCertRenewInterval can be in hours(h), minutes(m) and seconds(s); e.g. 17520h, 8760h etc.
39-
## Maximum value is 26280h (3 years), Minimum value is 24h; Default value is 17520h (2 years)
38+
## tcpsCertRenewInterval can be in hours(h), minutes(m) and seconds(s); e.g. 4380h, 8760h etc.
39+
## Maximum value is 8760h (1 year), Minimum value is 24h; Default value is 8760h (1 year)
4040
## If this field is commented out/removed from the yaml, it will disable the auto-renewal feature for TCPS certificate
41-
tcpsCertRenewInterval: 17520h
41+
tcpsCertRenewInterval: 8760h
4242

4343
## Database image details
4444
image:

controllers/database/singleinstancedatabase_controller.go

Lines changed: 32 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1126,57 +1126,37 @@ func (r *SingleInstanceDatabaseReconciler) createOrReplaceSVC(ctx context.Contex
11261126
}
11271127
}
11281128

1129-
deleteSvc := false
11301129
patchSvc := false
1131-
if extSvc.Spec.Type != extSvcType {
1132-
deleteSvc = true
1133-
} else {
1134-
// Conditions to determine whether to patch or not
1135-
if len(extSvc.Spec.Ports) != requiredPorts {
1136-
patchSvc = true
1137-
}
11381130

1139-
if (m.Spec.ListenerPort != 0 && svcPort != targetPorts[1]) || (m.Spec.EnableTCPS && m.Spec.TcpsListenerPort != 0 && tcpsSvcPort != targetPorts[len(targetPorts)-1]) {
1140-
patchSvc = true
1141-
}
1131+
// Conditions to determine whether to patch or not
1132+
if extSvc.Spec.Type != extSvcType || len(extSvc.Spec.Ports) != requiredPorts {
1133+
patchSvc = true
1134+
}
11421135

1143-
if m.Spec.LoadBalancer {
1144-
if m.Spec.EnableTCPS {
1145-
if m.Spec.TcpsListenerPort == 0 && tcpsSvcPort != targetPorts[len(targetPorts)-1] {
1146-
patchSvc = true
1147-
}
1148-
} else {
1149-
if m.Spec.ListenerPort == 0 && svcPort != targetPorts[1] {
1150-
patchSvc = true
1151-
}
1136+
if (m.Spec.ListenerPort != 0 && svcPort != targetPorts[1]) || (m.Spec.EnableTCPS && m.Spec.TcpsListenerPort != 0 && tcpsSvcPort != targetPorts[len(targetPorts)-1]) {
1137+
patchSvc = true
1138+
}
1139+
1140+
if m.Spec.LoadBalancer {
1141+
if m.Spec.EnableTCPS {
1142+
if m.Spec.TcpsListenerPort == 0 && tcpsSvcPort != targetPorts[len(targetPorts)-1] {
1143+
patchSvc = true
11521144
}
11531145
} else {
1154-
if m.Spec.EnableTCPS {
1155-
if m.Spec.TcpsListenerPort == 0 && tcpsSvcPort != extSvc.Spec.Ports[len(targetPorts)-1].TargetPort.IntVal {
1156-
patchSvc = true
1157-
}
1158-
} else {
1159-
if m.Spec.ListenerPort == 0 && svcPort != extSvc.Spec.Ports[1].TargetPort.IntVal {
1160-
patchSvc = true
1161-
}
1146+
if m.Spec.ListenerPort == 0 && svcPort != targetPorts[1] {
1147+
patchSvc = true
11621148
}
11631149
}
1164-
}
1165-
1166-
if deleteSvc {
1167-
// Deleting th service
1168-
log.Info("Deleting service", "name", extSvcName)
1169-
// Setting GracePeriodSeconds to 0 for instant deletion
1170-
delOpts := &client.DeleteOptions{}
1171-
var gracePeriod client.GracePeriodSeconds = 0
1172-
gracePeriod.ApplyToDelete(delOpts)
1173-
1174-
err := r.Delete(ctx, extSvc, delOpts)
1175-
if err != nil {
1176-
r.Log.Error(err, "Failed to delete service", "name", extSvcName)
1177-
return requeueN, err
1150+
} else {
1151+
if m.Spec.EnableTCPS {
1152+
if m.Spec.TcpsListenerPort == 0 && tcpsSvcPort != extSvc.Spec.Ports[len(targetPorts)-1].TargetPort.IntVal {
1153+
patchSvc = true
1154+
}
1155+
} else {
1156+
if m.Spec.ListenerPort == 0 && svcPort != extSvc.Spec.Ports[1].TargetPort.IntVal {
1157+
patchSvc = true
1158+
}
11781159
}
1179-
isExtSvcFound = false
11801160
}
11811161

11821162
if patchSvc {
@@ -1193,29 +1173,29 @@ func (r *SingleInstanceDatabaseReconciler) createOrReplaceSVC(ctx context.Contex
11931173
if m.Spec.LoadBalancer {
11941174
if m.Spec.EnableTCPS {
11951175
if m.Spec.ListenerPort != 0 {
1196-
payload = fmt.Sprintf(dbcommons.ThreePortPayload, fmt.Sprintf(dbcommons.LsnrPort, svcPort), fmt.Sprintf(dbcommons.TcpsPort, tcpsSvcPort))
1176+
payload = fmt.Sprintf(dbcommons.ThreePortPayload, extSvcType, fmt.Sprintf(dbcommons.LsnrPort, svcPort), fmt.Sprintf(dbcommons.TcpsPort, tcpsSvcPort))
11971177
} else {
1198-
payload = fmt.Sprintf(dbcommons.TwoPortPayload, fmt.Sprintf(dbcommons.TcpsPort, tcpsSvcPort))
1178+
payload = fmt.Sprintf(dbcommons.TwoPortPayload, extSvcType, fmt.Sprintf(dbcommons.TcpsPort, tcpsSvcPort))
11991179
}
12001180
} else {
1201-
payload = fmt.Sprintf(dbcommons.TwoPortPayload, fmt.Sprintf(dbcommons.LsnrPort, svcPort))
1181+
payload = fmt.Sprintf(dbcommons.TwoPortPayload, extSvcType, fmt.Sprintf(dbcommons.LsnrPort, svcPort))
12021182
}
12031183
} else {
12041184
if m.Spec.EnableTCPS {
12051185
if m.Spec.ListenerPort != 0 && m.Spec.TcpsListenerPort != 0 {
1206-
payload = fmt.Sprintf(dbcommons.ThreePortPayload, fmt.Sprintf(dbcommons.LsnrNodePort, svcPort), fmt.Sprintf(dbcommons.TcpsNodePort, tcpsSvcPort))
1186+
payload = fmt.Sprintf(dbcommons.ThreePortPayload, extSvcType, fmt.Sprintf(dbcommons.LsnrNodePort, svcPort), fmt.Sprintf(dbcommons.TcpsNodePort, tcpsSvcPort))
12071187
} else if m.Spec.ListenerPort != 0 {
1208-
payload = fmt.Sprintf(dbcommons.ThreePortPayload, fmt.Sprintf(dbcommons.LsnrNodePort, svcPort), fmt.Sprintf(dbcommons.TcpsPort, tcpsSvcPort))
1188+
payload = fmt.Sprintf(dbcommons.ThreePortPayload, extSvcType, fmt.Sprintf(dbcommons.LsnrNodePort, svcPort), fmt.Sprintf(dbcommons.TcpsPort, tcpsSvcPort))
12091189
} else if m.Spec.TcpsListenerPort != 0 {
1210-
payload = fmt.Sprintf(dbcommons.TwoPortPayload, fmt.Sprintf(dbcommons.TcpsNodePort, tcpsSvcPort))
1190+
payload = fmt.Sprintf(dbcommons.TwoPortPayload, extSvcType, fmt.Sprintf(dbcommons.TcpsNodePort, tcpsSvcPort))
12111191
} else {
1212-
payload = fmt.Sprintf(dbcommons.TwoPortPayload, fmt.Sprintf(dbcommons.TcpsPort, tcpsSvcPort))
1192+
payload = fmt.Sprintf(dbcommons.TwoPortPayload, extSvcType, fmt.Sprintf(dbcommons.TcpsPort, tcpsSvcPort))
12131193
}
12141194
} else {
12151195
if m.Spec.ListenerPort != 0 {
1216-
payload = fmt.Sprintf(dbcommons.TwoPortPayload, fmt.Sprintf(dbcommons.LsnrNodePort, svcPort))
1196+
payload = fmt.Sprintf(dbcommons.TwoPortPayload, extSvcType, fmt.Sprintf(dbcommons.LsnrNodePort, svcPort))
12171197
} else {
1218-
payload = fmt.Sprintf(dbcommons.TwoPortPayload, fmt.Sprintf(dbcommons.LsnrPort, svcPort))
1198+
payload = fmt.Sprintf(dbcommons.TwoPortPayload, extSvcType, fmt.Sprintf(dbcommons.LsnrPort, svcPort))
12191199
}
12201200
}
12211201
}

docs/sidb/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -543,8 +543,8 @@ The following steps are required to connect the Database using TCPS:
543543
**NOTE:**
544544
- Only database server authentication is supported (no mTLS).
545545
- When TCPS is enabled, a self-signed certificate is generated and stored inside the wallets. For users' convenience, a client-side wallet is generated and stored at `/opt/oracle/oradata/clientWallet/$ORACLE_SID` location in the pod.
546-
- The self-signed certificate used with TCPS has validity for 2 years. After the certificate is expired, it will be renewed by the `OraOperator` automatically. You need to download the wallet again after the auto-renewal.
547-
- You can set the certificate renew interval with the help of `tcpsCertRenewInterval` field in the **[config/samples/sidb/singleinstancedatabase.yaml](../../config/samples/sidb/singleinstancedatabase.yaml)** file. The minimum accepted value is 24h, and the maximum value is 26280h (3 years). The certificates used with TCPS will automatically be renewed after this interval. If this field is omitted/commented in the yaml file, the certificates will not be renewed automatically.
546+
- The self-signed certificate used with TCPS has validity for 1 year. After the certificate is expired, it will be renewed by the `OraOperator` automatically. You need to download the wallet again after the auto-renewal.
547+
- You can set the certificate renew interval with the help of `tcpsCertRenewInterval` field in the **[config/samples/sidb/singleinstancedatabase.yaml](../../config/samples/sidb/singleinstancedatabase.yaml)** file. The minimum accepted value is 24h, and the maximum value is 8760h (1 year). The certificates used with TCPS will automatically be renewed after this interval. If this field is omitted/commented in the yaml file, the certificates will not be renewed automatically.
548548
- When the certificate gets created/renewed, the `.status.certCreationTimestamp` status variable gets updated accordingly. You can see this timestamp by using the following command:
549549
```bash
550550
kubectl get singleinstancedatabase sidb-sample -o "jsonpath={.status.certCreationTimestamp}"

0 commit comments

Comments
 (0)