12
12
import com .yugabyte .yw .common .certmgmt .CertConfigType ;
13
13
import com .yugabyte .yw .models .CertificateInfo ;
14
14
import com .yugabyte .yw .models .Universe ;
15
+ import io .swagger .annotations .ApiModelProperty ;
15
16
import java .util .UUID ;
16
17
import play .mvc .Http ;
17
18
import play .mvc .Http .Status ;
@@ -24,10 +25,9 @@ public class TlsToggleParams extends UpgradeTaskParams {
24
25
public boolean enableClientToNodeEncrypt = false ;
25
26
public boolean allowInsecure = true ;
26
27
27
- // below fields are already inherited from UniverseDefinitionTaskParams
28
- // public UUID rootCA = null;
29
- // public UUID clientRootCA = null;
30
- // public Boolean rootAndClientRootCASame = null;
28
+ // Do not include in swagger.
29
+ @ ApiModelProperty (hidden = true )
30
+ public int nodeToNodeChange = 0 ;
31
31
32
32
public TlsToggleParams () {}
33
33
@@ -43,101 +43,102 @@ public TlsToggleParams(
43
43
44
44
@ Override
45
45
public void verifyParams (Universe universe , boolean isFirstTry ) {
46
- super .verifyParams (universe , isFirstTry );
47
-
48
- UniverseDefinitionTaskParams universeDetails = universe .getUniverseDetails ();
49
- UserIntent userIntent = universeDetails .getPrimaryCluster ().userIntent ;
50
- boolean existingEnableClientToNodeEncrypt = userIntent .enableClientToNodeEncrypt ;
51
- boolean existingEnableNodeToNodeEncrypt = userIntent .enableNodeToNodeEncrypt ;
52
- UUID existingRootCA = universeDetails .rootCA ;
53
- UUID existingClientRootCA = universeDetails .getClientRootCA ();
54
-
55
- // Due to a bug, temporarily disable rolling upgrade for TLS toggle.
46
+ // Due to a bug (PLAT-9434), temporarily disable rolling upgrade for TLS toggle.
56
47
if (upgradeOption != UpgradeOption .NON_ROLLING_UPGRADE ) {
57
48
throw new PlatformServiceException (
58
49
Status .BAD_REQUEST , "TLS toggle can only be performed in a non-rolling manner." );
59
50
}
60
-
61
- if (this .enableClientToNodeEncrypt == existingEnableClientToNodeEncrypt
62
- && this .enableNodeToNodeEncrypt == existingEnableNodeToNodeEncrypt ) {
63
- throw new PlatformServiceException (
64
- Status .BAD_REQUEST , "No changes in Tls parameters, cannot perform update operation." );
65
- }
66
-
67
- if (existingRootCA != null && rootCA != null && !existingRootCA .equals (rootCA )) {
68
- throw new PlatformServiceException (
69
- Status .BAD_REQUEST , "Cannot update root certificate, if already created." );
70
- }
71
-
72
- if (existingClientRootCA != null
73
- && clientRootCA != null
74
- && !existingClientRootCA .equals (clientRootCA )) {
75
- throw new PlatformServiceException (
76
- Status .BAD_REQUEST , "Cannot update client root certificate, if already created." );
77
- }
78
-
79
- if (!CertificateInfo .isCertificateValid (rootCA )) {
80
- throw new PlatformServiceException (
81
- Status .BAD_REQUEST , "No valid root certificate found for UUID: " + rootCA );
82
- }
83
-
84
- if (!CertificateInfo .isCertificateValid (clientRootCA )) {
85
- throw new PlatformServiceException (
86
- Status .BAD_REQUEST , "No valid client root certificate found for UUID: " + clientRootCA );
87
- }
88
-
89
- if (rootCA != null
90
- && CertificateInfo .get (rootCA ).getCertType () == CertConfigType .CustomServerCert ) {
91
- throw new PlatformServiceException (
92
- Http .Status .BAD_REQUEST ,
93
- "CustomServerCert are only supported for Client to Server Communication." );
94
- }
95
-
96
- if (rootCA != null
97
- && CertificateInfo .get (rootCA ).getCertType () == CertConfigType .CustomCertHostPath
98
- && !userIntent .providerType .equals (CloudType .onprem )) {
99
- throw new PlatformServiceException (
100
- Status .BAD_REQUEST ,
101
- "CustomCertHostPath certificates are only supported for on-prem providers." );
102
- }
103
-
104
- if (clientRootCA != null
105
- && CertificateInfo .get (clientRootCA ).getCertType () == CertConfigType .CustomCertHostPath
106
- && !userIntent .providerType .equals (Common .CloudType .onprem )) {
107
- throw new PlatformServiceException (
108
- Http .Status .BAD_REQUEST ,
109
- "CustomCertHostPath certificates are only supported for on-prem providers." );
110
- }
111
-
112
- // TODO: Add check that the userIntent is to use cert-manager
113
- if (rootCA != null
114
- && CertificateInfo .get (rootCA ).getCertType () == CertConfigType .K8SCertManager
115
- && !userIntent .providerType .equals (CloudType .kubernetes )) {
116
- throw new PlatformServiceException (
117
- Status .BAD_REQUEST ,
118
- "K8SCertManager certificates are only supported for k8s providers with cert-manager"
119
- + " configured." );
120
- }
121
-
122
- // TODO: Add check that the userIntent is to use cert-manager
123
- if (clientRootCA != null
124
- && CertificateInfo .get (clientRootCA ).getCertType () == CertConfigType .K8SCertManager
125
- && !userIntent .providerType .equals (Common .CloudType .kubernetes )) {
126
- throw new PlatformServiceException (
127
- Http .Status .BAD_REQUEST ,
128
- "K8SCertManager certificates are only supported for k8s providers with cert-manager"
129
- + " configured." );
130
- }
131
-
132
- if (rootAndClientRootCASame
133
- && enableNodeToNodeEncrypt
134
- && enableClientToNodeEncrypt
135
- && rootCA != null
136
- && clientRootCA != null
137
- && !rootCA .equals (clientRootCA )) {
138
- throw new PlatformServiceException (
139
- Http .Status .BAD_REQUEST ,
140
- "RootCA and ClientRootCA cannot be different when rootAndClientRootCASame is true." );
51
+ super .verifyParams (universe , isFirstTry );
52
+ if (isFirstTry ) {
53
+ // Validate against the current settings in the universe.
54
+ UniverseDefinitionTaskParams universeDetails = universe .getUniverseDetails ();
55
+ UserIntent userIntent = universeDetails .getPrimaryCluster ().userIntent ;
56
+ boolean existingEnableClientToNodeEncrypt = userIntent .enableClientToNodeEncrypt ;
57
+ boolean existingEnableNodeToNodeEncrypt = userIntent .enableNodeToNodeEncrypt ;
58
+ UUID existingRootCA = universeDetails .rootCA ;
59
+ UUID existingClientRootCA = universeDetails .getClientRootCA ();
60
+
61
+ if (this .enableClientToNodeEncrypt == existingEnableClientToNodeEncrypt
62
+ && this .enableNodeToNodeEncrypt == existingEnableNodeToNodeEncrypt ) {
63
+ throw new PlatformServiceException (
64
+ Status .BAD_REQUEST , "No changes in Tls parameters, cannot perform update operation." );
65
+ }
66
+
67
+ if (existingRootCA != null && rootCA != null && !existingRootCA .equals (rootCA )) {
68
+ throw new PlatformServiceException (
69
+ Status .BAD_REQUEST , "Cannot update root certificate, if already created." );
70
+ }
71
+
72
+ if (existingClientRootCA != null
73
+ && clientRootCA != null
74
+ && !existingClientRootCA .equals (clientRootCA )) {
75
+ throw new PlatformServiceException (
76
+ Status .BAD_REQUEST , "Cannot update client root certificate, if already created." );
77
+ }
78
+
79
+ if (!CertificateInfo .isCertificateValid (rootCA )) {
80
+ throw new PlatformServiceException (
81
+ Status .BAD_REQUEST , "No valid root certificate found for UUID: " + rootCA );
82
+ }
83
+
84
+ if (!CertificateInfo .isCertificateValid (clientRootCA )) {
85
+ throw new PlatformServiceException (
86
+ Status .BAD_REQUEST , "No valid client root certificate found for UUID: " + clientRootCA );
87
+ }
88
+
89
+ if (rootCA != null
90
+ && CertificateInfo .get (rootCA ).getCertType () == CertConfigType .CustomServerCert ) {
91
+ throw new PlatformServiceException (
92
+ Http .Status .BAD_REQUEST ,
93
+ "CustomServerCert are only supported for Client to Server Communication." );
94
+ }
95
+
96
+ if (rootCA != null
97
+ && CertificateInfo .get (rootCA ).getCertType () == CertConfigType .CustomCertHostPath
98
+ && !userIntent .providerType .equals (CloudType .onprem )) {
99
+ throw new PlatformServiceException (
100
+ Status .BAD_REQUEST ,
101
+ "CustomCertHostPath certificates are only supported for on-prem providers." );
102
+ }
103
+
104
+ if (clientRootCA != null
105
+ && CertificateInfo .get (clientRootCA ).getCertType () == CertConfigType .CustomCertHostPath
106
+ && !userIntent .providerType .equals (Common .CloudType .onprem )) {
107
+ throw new PlatformServiceException (
108
+ Http .Status .BAD_REQUEST ,
109
+ "CustomCertHostPath certificates are only supported for on-prem providers." );
110
+ }
111
+
112
+ // TODO: Add check that the userIntent is to use cert-manager
113
+ if (rootCA != null
114
+ && CertificateInfo .get (rootCA ).getCertType () == CertConfigType .K8SCertManager
115
+ && !userIntent .providerType .equals (CloudType .kubernetes )) {
116
+ throw new PlatformServiceException (
117
+ Status .BAD_REQUEST ,
118
+ "K8SCertManager certificates are only supported for k8s providers with cert-manager"
119
+ + " configured." );
120
+ }
121
+
122
+ // TODO: Add check that the userIntent is to use cert-manager
123
+ if (clientRootCA != null
124
+ && CertificateInfo .get (clientRootCA ).getCertType () == CertConfigType .K8SCertManager
125
+ && !userIntent .providerType .equals (Common .CloudType .kubernetes )) {
126
+ throw new PlatformServiceException (
127
+ Http .Status .BAD_REQUEST ,
128
+ "K8SCertManager certificates are only supported for k8s providers with cert-manager"
129
+ + " configured." );
130
+ }
131
+
132
+ if (rootAndClientRootCASame
133
+ && enableNodeToNodeEncrypt
134
+ && enableClientToNodeEncrypt
135
+ && rootCA != null
136
+ && clientRootCA != null
137
+ && !rootCA .equals (clientRootCA )) {
138
+ throw new PlatformServiceException (
139
+ Http .Status .BAD_REQUEST ,
140
+ "RootCA and ClientRootCA cannot be different when rootAndClientRootCASame is true." );
141
+ }
141
142
}
142
143
}
143
144
0 commit comments