@@ -192,25 +192,24 @@ func isAutoModeCluster(r *resource) bool {
192
192
return false
193
193
}
194
194
195
- // If ComputeConfig is not specified, this is not an Auto Mode cluster
196
- if r .ko .Spec .ComputeConfig == nil {
195
+ // Check if all three Auto Mode configurations are present
196
+ hasComputeConfig := r .ko .Spec .ComputeConfig != nil
197
+ hasStorageConfig := r .ko .Spec .StorageConfig != nil && r .ko .Spec .StorageConfig .BlockStorage != nil
198
+ hasELBConfig := r .ko .Spec .KubernetesNetworkConfig != nil && r .ko .Spec .KubernetesNetworkConfig .ElasticLoadBalancing != nil
199
+
200
+ // All three must be present for this to be considered an Auto Mode cluster
201
+ if ! hasComputeConfig || ! hasStorageConfig || ! hasELBConfig {
197
202
return false
198
203
}
199
204
200
205
// Check compute configuration
201
206
computeEnabled := r .ko .Spec .ComputeConfig .Enabled != nil && * r .ko .Spec .ComputeConfig .Enabled
202
207
203
208
// Check storage configuration
204
- storageEnabled := false
205
- if r .ko .Spec .StorageConfig != nil && r .ko .Spec .StorageConfig .BlockStorage != nil {
206
- storageEnabled = r .ko .Spec .StorageConfig .BlockStorage .Enabled != nil && * r .ko .Spec .StorageConfig .BlockStorage .Enabled
207
- }
209
+ storageEnabled := r .ko .Spec .StorageConfig .BlockStorage .Enabled != nil && * r .ko .Spec .StorageConfig .BlockStorage .Enabled
208
210
209
211
// Check elastic load balancing configuration
210
- elbEnabled := false
211
- if r .ko .Spec .KubernetesNetworkConfig != nil && r .ko .Spec .KubernetesNetworkConfig .ElasticLoadBalancing != nil {
212
- elbEnabled = r .ko .Spec .KubernetesNetworkConfig .ElasticLoadBalancing .Enabled != nil && * r .ko .Spec .KubernetesNetworkConfig .ElasticLoadBalancing .Enabled
213
- }
212
+ elbEnabled := r .ko .Spec .KubernetesNetworkConfig .ElasticLoadBalancing .Enabled != nil && * r .ko .Spec .KubernetesNetworkConfig .ElasticLoadBalancing .Enabled
214
213
215
214
// Auto Mode requires all three capabilities to have the same state (all true or all false)
216
215
// If they are all true, Auto Mode is enabled
@@ -222,25 +221,31 @@ func isAutoModeCluster(r *resource) bool {
222
221
// validateAutoModeConfig validates that Auto Mode configuration is consistent.
223
222
// Returns an error if the configuration is invalid (partial enablement).
224
223
func validateAutoModeConfig (r * resource ) error {
225
- if r == nil || r .ko == nil || r . ko . Spec . ComputeConfig == nil {
224
+ if r == nil || r .ko == nil {
226
225
return nil // Not an Auto Mode configuration
227
226
}
228
227
229
- // Check compute configuration
230
- computeEnabled := r .ko .Spec .ComputeConfig .Enabled != nil && * r .ko .Spec .ComputeConfig .Enabled
228
+ // Check if any Auto Mode configuration is present
229
+ hasComputeConfig := r .ko .Spec .ComputeConfig != nil
230
+ hasStorageConfig := r .ko .Spec .StorageConfig != nil && r .ko .Spec .StorageConfig .BlockStorage != nil
231
+ hasELBConfig := r .ko .Spec .KubernetesNetworkConfig != nil && r .ko .Spec .KubernetesNetworkConfig .ElasticLoadBalancing != nil
231
232
232
- // Check storage configuration
233
- storageEnabled := false
234
- if r .ko .Spec .StorageConfig != nil && r .ko .Spec .StorageConfig .BlockStorage != nil {
235
- storageEnabled = r .ko .Spec .StorageConfig .BlockStorage .Enabled != nil && * r .ko .Spec .StorageConfig .BlockStorage .Enabled
233
+ // If no Auto Mode configuration is present, it's valid (not an Auto Mode cluster)
234
+ if ! hasComputeConfig && ! hasStorageConfig && ! hasELBConfig {
235
+ return nil
236
236
}
237
237
238
- // Check elastic load balancing configuration
239
- elbEnabled := false
240
- if r . ko . Spec . KubernetesNetworkConfig != nil && r . ko . Spec . KubernetesNetworkConfig . ElasticLoadBalancing != nil {
241
- elbEnabled = r . ko . Spec . KubernetesNetworkConfig . ElasticLoadBalancing . Enabled != nil && * r . ko . Spec . KubernetesNetworkConfig . ElasticLoadBalancing . Enabled
238
+ // If any Auto Mode configuration is present, ALL must be present
239
+ if ! hasComputeConfig || ! hasStorageConfig || ! hasELBConfig {
240
+ return fmt . Errorf ( "invalid Auto Mode configuration: when configuring Auto Mode, all three capabilities must be specified (compute=%v, storage=%v, elb=%v)" ,
241
+ hasComputeConfig , hasStorageConfig , hasELBConfig )
242
242
}
243
243
244
+ // Check that all configurations have the same enabled state
245
+ computeEnabled := r .ko .Spec .ComputeConfig .Enabled != nil && * r .ko .Spec .ComputeConfig .Enabled
246
+ storageEnabled := r .ko .Spec .StorageConfig .BlockStorage .Enabled != nil && * r .ko .Spec .StorageConfig .BlockStorage .Enabled
247
+ elbEnabled := r .ko .Spec .KubernetesNetworkConfig .ElasticLoadBalancing .Enabled != nil && * r .ko .Spec .KubernetesNetworkConfig .ElasticLoadBalancing .Enabled
248
+
244
249
// All three must be in the same state
245
250
if computeEnabled == storageEnabled && storageEnabled == elbEnabled {
246
251
return nil // Valid configuration
0 commit comments