-
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathcontroller.rs
More file actions
694 lines (625 loc) · 23.8 KB
/
Copy pathcontroller.rs
File metadata and controls
694 lines (625 loc) · 23.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
//! Ensures that `Pod`s are configured and running for each [`SupersetCluster`]
pub(crate) mod build;
pub mod dereference;
pub mod validate;
use std::{collections::BTreeMap, str::FromStr, sync::Arc};
use const_format::concatcp;
use snafu::{ResultExt, Snafu};
use stackable_operator::{
builder::meta::ObjectMetaBuilder,
cli::OperatorEnvironmentOptions,
client::Client,
cluster_resources::ClusterResourceApplyStrategy,
commons::{
affinity::StackableAffinity,
product_image_selection::ResolvedProductImage,
random_secret_creation::{self, create_random_secret_if_not_exists},
resources::{NoRuntimeLimits, Resources},
},
crd::listener,
k8s_openapi::api::{
apps::v1::{Deployment, StatefulSet},
core::v1::{ConfigMap, Secret, Service, ServiceAccount},
policy::v1::PodDisruptionBudget,
rbac::v1::RoleBinding,
},
kube::{
Resource,
api::ObjectMeta,
core::{DeserializeGuard, error_boundary},
runtime::controller::Action,
},
kvp::Labels,
logging::controller::ReconcilerError,
shared::time::Duration,
status::condition::{
compute_conditions, deployment::DeploymentConditionBuilder,
operations::ClusterOperationsConditionBuilder, statefulset::StatefulSetConditionBuilder,
},
v2::{
HasName, HasUid, NameIsValidLabelValue,
builder::meta::ownerreference_from_resource,
cluster_resources::cluster_resources_new,
kvp::label::{recommended_labels, role_group_selector},
product_logging::framework::{ValidatedContainerLogConfigChoice, VectorContainerLogConfig},
role_group_utils::ResourceNames,
role_utils::{self, GenericCommonConfig, RoleGroupConfig},
types::{
kubernetes::{ListenerClassName, ListenerName, NamespaceName, Uid},
operator::{
ClusterName, ControllerName, OperatorName, ProductName, ProductVersion,
RoleGroupName, RoleName,
},
},
},
};
use strum::{EnumDiscriminants, IntoStaticStr};
use tracing::instrument;
use crate::{
OPERATOR_NAME,
crd::{
APP_NAME, INTERNAL_SECRET_SECRET_KEY, SupersetRole,
authentication::SupersetClientAuthenticationDetailsResolved,
authorization::SupersetOpaConfigResolved,
databases::{
CeleryBrokerConnection, CeleryResultsBackendConnection, MetadataDatabaseConnection,
},
v1alpha1::{
SupersetCluster, SupersetClusterStatus, SupersetConfig, SupersetConfigOverrides,
SupersetStorageConfig,
},
},
};
pub const SUPERSET_CONTROLLER_NAME: &str = "supersetcluster";
pub const SUPERSET_FULL_CONTROLLER_NAME: &str =
concatcp!(SUPERSET_CONTROLLER_NAME, '.', OPERATOR_NAME);
pub const CONTAINER_IMAGE_BASE_NAME: &str = "superset";
pub struct Ctx {
pub client: stackable_operator::client::Client,
pub operator_environment: OperatorEnvironmentOptions,
}
/// Every Kubernetes resource produced by the build step.
///
/// The `Node` role is provisioned via a `StatefulSet` (it serves the Superset web UI), while the
/// `Worker`/`Beat` Celery roles are provisioned via `Deployment`s; the build step collects both.
pub struct KubernetesResources {
pub stateful_sets: Vec<StatefulSet>,
pub deployments: Vec<Deployment>,
pub services: Vec<Service>,
pub listeners: Vec<listener::v1alpha1::Listener>,
pub config_maps: Vec<ConfigMap>,
pub pod_disruption_budgets: Vec<PodDisruptionBudget>,
pub service_accounts: Vec<ServiceAccount>,
pub role_bindings: Vec<RoleBinding>,
}
/// Per-role configuration extracted during validation.
#[derive(Clone, Debug)]
pub struct ValidatedRoleConfig {
pub pdb: Option<stackable_operator::commons::pdb::PdbConfig>,
pub listener_class: Option<ListenerClassName>,
pub group_listener_name: Option<ListenerName>,
}
/// A validated, merged Superset role-group config.
///
/// Aliasing [`RoleGroupConfig`] keeps `replicas` optional (`Option<u16>`), so an
/// unset value is propagated all the way to the StatefulSet/Deployment `replicas` field. That lets
/// an external controller such as a HorizontalPodAutoscaler own the replica count instead of the
/// operator forcing a default.
pub type SupersetRoleGroupConfig =
RoleGroupConfig<ValidatedSupersetConfig, GenericCommonConfig, SupersetConfigOverrides>;
/// A validated Superset config: the merged [`SupersetConfig`] exploded into named fields, with its
/// raw `logging` replaced by the up-front–validated [`ValidatedLogging`] (so an invalid custom log
/// ConfigMap name or a missing Vector aggregator name fails reconciliation during validation rather
/// than at resource-build time). The raw [`SupersetConfig`] does not survive into this struct, so
/// the build step never sees the un-validated CRD type.
#[derive(Clone, Debug)]
pub struct ValidatedSupersetConfig {
pub affinity: StackableAffinity,
pub graceful_shutdown_timeout: Option<Duration>,
pub logging: ValidatedLogging,
pub resources: Resources<SupersetStorageConfig, NoRuntimeLimits>,
pub row_limit: Option<i32>,
pub webserver_timeout: Option<u32>,
}
impl ValidatedSupersetConfig {
/// Builds the validated config from the merged [`SupersetConfig`], swapping in the
/// already-validated logging.
fn from_merged(merged: SupersetConfig, logging: ValidatedLogging) -> Self {
Self {
affinity: merged.affinity,
graceful_shutdown_timeout: merged.graceful_shutdown_timeout,
logging,
resources: merged.resources,
row_limit: merged.row_limit,
webserver_timeout: merged.webserver_timeout,
}
}
}
/// Validated logging configuration for the Superset and (optional) Vector container.
///
/// Produced up-front by `validate_logging` so that an invalid custom log ConfigMap name or a
/// missing Vector aggregator discovery ConfigMap name fails reconciliation during validation rather
/// than at resource-build time.
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct ValidatedLogging {
pub superset_container: ValidatedContainerLogConfigChoice,
pub vector_container: Option<VectorContainerLogConfig>,
pub enable_vector_agent: bool,
}
/// Cluster-wide configuration that applies to every role and role group.
///
/// Carries the dereferenced external references, so every downstream build step reads them from
/// here rather than from the raw cluster object.
#[derive(Clone, Debug)]
pub struct ValidatedClusterConfig {
pub authentication_config: SupersetClientAuthenticationDetailsResolved,
pub opa_config: Option<SupersetOpaConfigResolved>,
/// Name of the Secret holding the admin user credentials.
pub credentials_secret_name: String,
/// Name of the auto-generated Secret holding the Flask `SECRET_KEY`.
pub secret_key_secret_name: String,
/// Name of the Secret holding the Mapbox API key, if configured.
pub mapbox_secret: Option<String>,
/// Connection to the metadata database.
pub metadata_database: MetadataDatabaseConnection,
/// Connection to the Celery results backend, if configured.
pub celery_results_backend: Option<CeleryResultsBackendConnection>,
/// Connection to the Celery broker, if configured.
pub celery_broker: Option<CeleryBrokerConnection>,
}
/// The validated cluster: proves that config merging succeeded for every role and role group
/// before any Kubernetes resources are created.
#[derive(Clone, Debug)]
pub struct ValidatedCluster {
/// `ObjectMeta` carrying `name`, `namespace` and `uid`, captured during validation, so this
/// struct can stand in as the owner [`Resource`] for child objects.
metadata: ObjectMeta,
pub name: ClusterName,
pub namespace: NamespaceName,
pub uid: Uid,
pub product_version: ProductVersion,
pub image: ResolvedProductImage,
pub cluster_config: ValidatedClusterConfig,
pub role_groups: BTreeMap<SupersetRole, BTreeMap<RoleGroupName, SupersetRoleGroupConfig>>,
pub role_configs: BTreeMap<SupersetRole, ValidatedRoleConfig>,
}
impl ValidatedCluster {
pub fn new(
name: ClusterName,
namespace: NamespaceName,
uid: Uid,
image: ResolvedProductImage,
cluster_config: ValidatedClusterConfig,
role_groups: BTreeMap<SupersetRole, BTreeMap<RoleGroupName, SupersetRoleGroupConfig>>,
role_configs: BTreeMap<SupersetRole, ValidatedRoleConfig>,
) -> Self {
let product_version = ProductVersion::from_str(&image.app_version_label_value)
.expect("the app version label value is a valid product version");
Self {
// Capture only the identity fields needed to own child objects, derived from the
// typed cluster identity rather than the raw CRD.
metadata: ObjectMeta {
name: Some(name.to_string()),
namespace: Some(namespace.to_string()),
uid: Some(uid.to_string()),
..ObjectMeta::default()
},
image,
cluster_config,
role_groups,
role_configs,
name,
namespace,
uid,
product_version,
}
}
pub fn role_group_resource_names(
&self,
role: &SupersetRole,
role_group_name: &RoleGroupName,
) -> ResourceNames {
ResourceNames {
cluster_name: self.name.clone(),
role_name: role.into(),
role_group_name: role_group_name.clone(),
}
}
/// Type-safe names for the per-cluster RBAC resources: the ServiceAccount shared by all
/// Pods, its (namespaced) RoleBinding, and the operator-deployed ClusterRole it binds.
pub fn cluster_resource_names(&self) -> role_utils::ResourceNames {
role_utils::ResourceNames {
cluster_name: self.name.clone(),
product_name: product_name(),
}
}
pub fn recommended_labels(
&self,
role: &SupersetRole,
role_group_name: &RoleGroupName,
) -> Labels {
self.recommended_labels_for(&role.into(), role_group_name)
}
pub fn recommended_labels_for(
&self,
role_name: &RoleName,
role_group_name: &RoleGroupName,
) -> Labels {
self.recommended_labels_with(&self.product_version, role_name, role_group_name)
}
/// Recommended labels with a constant `none` version, for PVC templates that cannot be modified
/// after deployment (keeps the labels stable across version upgrades).
pub fn unversioned_recommended_labels(
&self,
role: &SupersetRole,
role_group_name: &RoleGroupName,
) -> Labels {
self.recommended_labels_with(
&build::UNVERSIONED_PRODUCT_VERSION,
&role.into(),
role_group_name,
)
}
fn recommended_labels_with(
&self,
product_version: &ProductVersion,
role_name: &RoleName,
role_group_name: &RoleGroupName,
) -> Labels {
recommended_labels(
self,
&product_name(),
product_version,
&operator_name(),
&controller_name(),
role_name,
role_group_name,
)
}
pub fn role_group_selector(
&self,
role: &SupersetRole,
role_group_name: &RoleGroupName,
) -> Labels {
role_group_selector(self, &product_name(), &role.into(), role_group_name)
}
/// Returns an [`ObjectMetaBuilder`] pre-filled with the namespace, an owner reference back to
/// this cluster, and the recommended labels for a resource named `name` in `role`/
/// `role_group_name`.
///
/// Consolidates the metadata chain repeated by the role-group child-resource builders. Call
/// sites that need extra labels/annotations chain them onto the returned builder.
pub(crate) fn object_meta(
&self,
name: impl Into<String>,
role: &SupersetRole,
role_group_name: &RoleGroupName,
) -> ObjectMetaBuilder {
let mut builder = ObjectMetaBuilder::new();
builder
.name_and_namespace(self)
.name(name)
.ownerreference(ownerreference_from_resource(self, None, Some(true)))
.with_labels(self.recommended_labels(role, role_group_name));
builder
}
}
/// Lets [`ValidatedCluster`] stand in for the raw [`SupersetCluster`] when building owner
/// references and metadata for child objects. Kind/group/version are delegated to the CRD; the
/// `metadata` (name, namespace, uid) is captured during validation.
impl Resource for ValidatedCluster {
type DynamicType = <SupersetCluster as Resource>::DynamicType;
type Scope = <SupersetCluster as Resource>::Scope;
fn kind(dt: &Self::DynamicType) -> std::borrow::Cow<'_, str> {
SupersetCluster::kind(dt)
}
fn group(dt: &Self::DynamicType) -> std::borrow::Cow<'_, str> {
SupersetCluster::group(dt)
}
fn version(dt: &Self::DynamicType) -> std::borrow::Cow<'_, str> {
SupersetCluster::version(dt)
}
fn plural(dt: &Self::DynamicType) -> std::borrow::Cow<'_, str> {
SupersetCluster::plural(dt)
}
fn meta(&self) -> &ObjectMeta {
&self.metadata
}
fn meta_mut(&mut self) -> &mut ObjectMeta {
&mut self.metadata
}
}
impl HasName for ValidatedCluster {
fn to_name(&self) -> String {
self.name.to_string()
}
}
impl HasUid for ValidatedCluster {
fn to_uid(&self) -> Uid {
self.uid.clone()
}
}
impl NameIsValidLabelValue for ValidatedCluster {
fn to_label_value(&self) -> String {
self.name.to_label_value()
}
}
/// The product name (`superset`) as a type-safe label value.
pub(crate) fn product_name() -> ProductName {
ProductName::from_str(APP_NAME).expect("'superset' is a valid product name")
}
/// The operator name as a type-safe label value.
pub(crate) fn operator_name() -> OperatorName {
OperatorName::from_str(OPERATOR_NAME).expect("the operator name is a valid label value")
}
/// The controller name as a type-safe label value.
pub(crate) fn controller_name() -> ControllerName {
ControllerName::from_str(SUPERSET_CONTROLLER_NAME)
.expect("the controller name is a valid label value")
}
#[derive(Snafu, Debug, EnumDiscriminants)]
#[strum_discriminants(derive(IntoStaticStr))]
#[allow(clippy::enum_variant_names)]
pub enum Error {
#[snafu(display("failed to dereference external objects"))]
Dereference { source: dereference::Error },
#[snafu(display("failed to validate cluster"))]
Validate { source: validate::Error },
#[snafu(display("failed to delete orphaned resources"))]
DeleteOrphanedResources {
source: stackable_operator::cluster_resources::Error,
},
#[snafu(display("failed to build the Kubernetes resources"))]
BuildResources { source: build::Error },
#[snafu(display("failed to apply Kubernetes resource"))]
ApplyResource {
source: stackable_operator::cluster_resources::Error,
},
#[snafu(display("failed to update status"))]
ApplyStatus {
source: stackable_operator::client::Error,
},
#[snafu(display("SupersetCluster object is invalid"))]
InvalidSupersetCluster {
source: error_boundary::InvalidObject,
},
#[snafu(display("failed to create SECRET_KEY secret"))]
CreateSecretKeySecret {
source: random_secret_creation::Error,
},
#[snafu(display("failed to retrieve credentials secret {secret_name:?}"))]
RetrieveCredentialsSecret {
source: stackable_operator::client::Error,
secret_name: String,
},
#[snafu(display("object is missing metadata to build owner reference"))]
ObjectMissingMetadataForOwnerRef {
source: stackable_operator::builder::meta::Error,
},
#[snafu(display("failed to create SECRET_KEY secret from migrated value"))]
CreateRandomSecret {
source: stackable_operator::client::Error,
},
}
type Result<T, E = Error> = std::result::Result<T, E>;
impl ReconcilerError for Error {
fn category(&self) -> &'static str {
ErrorDiscriminants::from(self).into()
}
}
pub async fn reconcile_superset(
superset: Arc<DeserializeGuard<SupersetCluster>>,
ctx: Arc<Ctx>,
) -> Result<Action> {
tracing::info!("Starting reconcile");
let superset = superset
.0
.as_ref()
.map_err(error_boundary::InvalidObject::clone)
.context(InvalidSupersetClusterSnafu)?;
let client = &ctx.client;
let cluster_operation_cond_builder =
ClusterOperationsConditionBuilder::new(&superset.spec.cluster_config.cluster_operation);
let dereferenced = dereference::dereference(client, superset)
.await
.context(DereferenceSnafu)?;
let validated = validate::validate_cluster(
superset,
dereferenced,
&ctx.operator_environment.image_repository,
)
.context(ValidateSnafu)?;
let mut cluster_resources = cluster_resources_new(
&product_name(),
&operator_name(),
&controller_name(),
&validated.name,
&validated.namespace,
&validated.uid,
ClusterResourceApplyStrategy::from(&superset.spec.cluster_config.cluster_operation),
&superset.spec.object_overrides,
);
// TODO: Can be removed after SDP 26.7 is released (it's only a migration from 26.3 - 26.7)
// (don't forget about the snafu Error variants).
// Removal is tracked in https://github.com/stackabletech/superset-operator/issues/755
migrate_legacy_secret_key_secret_from_26_3(superset, &validated, client).await?;
create_random_secret_if_not_exists(
&validated.cluster_config.secret_key_secret_name,
INTERNAL_SECRET_SECRET_KEY,
256,
&validated,
client,
)
.await
.context(CreateSecretKeySecretSnafu)?;
let resources = build::build(&validated).context(BuildResourcesSnafu)?;
let mut statefulset_cond_builder = StatefulSetConditionBuilder::default();
let mut deployment_cond_builder = DeploymentConditionBuilder::default();
// The StatefulSets/Deployments are applied last, so every ConfigMap and Secret they mount
// already exists — otherwise a changed mount would restart the Pods.
// See https://github.com/stackabletech/commons-operator/issues/111 for details.
for service_account in resources.service_accounts {
cluster_resources
.add(client, service_account)
.await
.context(ApplyResourceSnafu)?;
}
for role_binding in resources.role_bindings {
cluster_resources
.add(client, role_binding)
.await
.context(ApplyResourceSnafu)?;
}
for service in resources.services {
cluster_resources
.add(client, service)
.await
.context(ApplyResourceSnafu)?;
}
for config_map in resources.config_maps {
cluster_resources
.add(client, config_map)
.await
.context(ApplyResourceSnafu)?;
}
for listener in resources.listeners {
cluster_resources
.add(client, listener)
.await
.context(ApplyResourceSnafu)?;
}
for pdb in resources.pod_disruption_budgets {
cluster_resources
.add(client, pdb)
.await
.context(ApplyResourceSnafu)?;
}
for statefulset in resources.stateful_sets {
statefulset_cond_builder.add(
cluster_resources
.add(client, statefulset)
.await
.context(ApplyResourceSnafu)?,
);
}
for deployment in resources.deployments {
deployment_cond_builder.add(
cluster_resources
.add(client, deployment)
.await
.context(ApplyResourceSnafu)?,
);
}
cluster_resources
.delete_orphaned_resources(client)
.await
.context(DeleteOrphanedResourcesSnafu)?;
let status = SupersetClusterStatus {
conditions: compute_conditions(
superset,
&[
&statefulset_cond_builder,
&deployment_cond_builder,
&cluster_operation_cond_builder,
],
),
};
client
.apply_patch_status(OPERATOR_NAME, superset, &status)
.await
.context(ApplyStatusSnafu)?;
Ok(Action::await_change())
}
// TODO: Can be removed after SDP 26.7 is released (it's only a migration from 26.3 - 26.7)
// (don't forget about the snafu Error variants).
// Removal is tracked in https://github.com/stackabletech/superset-operator/issues/755
#[instrument(skip_all)]
async fn migrate_legacy_secret_key_secret_from_26_3(
superset: &SupersetCluster,
validated: &ValidatedCluster,
client: &Client,
) -> Result<()> {
let old_secret_name = &validated.cluster_config.credentials_secret_name;
let new_secret_name = &validated.cluster_config.secret_key_secret_name;
let secret_namespace = &validated.namespace;
let new_secret = client
.get_opt::<Secret>(new_secret_name, secret_namespace.as_ref())
.await
.with_context(|_| RetrieveCredentialsSecretSnafu {
secret_name: new_secret_name,
})?;
if new_secret.is_some() {
tracing::debug!("SECRET_KEY Secret already exists, nothing to migrate");
return Ok(());
}
let old_secret = client
.get_opt::<Secret>(old_secret_name, secret_namespace.as_ref())
.await
.with_context(|_| RetrieveCredentialsSecretSnafu {
secret_name: old_secret_name,
})?;
let old_secret_key = old_secret
.and_then(|secret| secret.data)
// Note: We remove the key to take ownership
.and_then(|mut data| data.remove("connections.secretKey"))
.and_then(|key| String::from_utf8(key.0).ok());
if let Some(old_secret_key) = old_secret_key {
tracing::info!(
old.secret.name = old_secret_name,
old.secret.namespace = %secret_namespace,
new.secret.name = new_secret_name,
new.secret.namespace = %secret_namespace,
"Migrating old SECRET_KEY to new Secret"
);
let secret = Secret {
metadata: ObjectMetaBuilder::new()
.name(new_secret_name)
.namespace(secret_namespace)
.ownerreference_from_resource(superset, None, Some(true))
.context(ObjectMissingMetadataForOwnerRefSnafu)?
.build(),
string_data: Some(BTreeMap::from([(
INTERNAL_SECRET_SECRET_KEY.to_string(),
old_secret_key,
)])),
..Secret::default()
};
client
.create(&secret)
.await
.context(CreateRandomSecretSnafu)?;
}
Ok(())
}
pub fn error_policy(
_obj: Arc<DeserializeGuard<SupersetCluster>>,
error: &Error,
_ctx: Arc<Ctx>,
) -> Action {
match error {
Error::InvalidSupersetCluster { .. } => Action::await_change(),
_ => Action::requeue(*Duration::from_secs(5)),
}
}
#[cfg(test)]
pub(crate) mod test_support {
use crate::{
controller::dereference::DereferencedObjects,
crd::authentication::{
self, SupersetClientAuthenticationDetailsResolved, v1alpha1::FlaskRolesSyncMoment,
},
};
/// A [`DereferencedObjects`] with no authentication classes and no OPA config, for tests that
/// build a `ValidatedCluster` without exercising the dereference step.
pub(crate) fn default_dereferenced() -> DereferencedObjects {
DereferencedObjects {
authentication_config: SupersetClientAuthenticationDetailsResolved {
authentication_classes_resolved: vec![],
user_registration: true,
user_registration_role: authentication::DEFAULT_USER_REGISTRATION_ROLE.to_string(),
sync_roles_at: FlaskRolesSyncMoment::default(),
},
opa_config: None,
}
}
}