Skip to content

Commit 5185d67

Browse files
Techassiadwk67
andcommitted
Add pause/stop feature to operator (#348)
# Description See [#72](stackabletech/issues#72). ## Definition of Done Checklist - Not all of these items are applicable to all PRs, the author should update this template to only leave the boxes in that are relevant - Please make sure all these things are done and tick the boxes ```[tasklist] # Author - [ ] CRD changes approved - [ ] Helm chart can be installed and deployed operator works - [ ] Integration tests passed (for non trivial changes) ``` ```[tasklist] # Reviewer - [x] Code contains useful comments - [x] (Integration-)Test cases added - [ ] Documentation added or updated - [x] Changelog updated - [x] Cargo.toml only contains references to git tags (not specific commits or branches) ``` ```[tasklist] # Acceptance - [ ] Feature Tracker has been updated - [ ] Proper release label has been added ``` Once the review is done, comment `bors r+` (or `bors merge`) to merge. [Further information](https://bors.tech/documentation/getting-started/#reviewing-pull-requests) Co-authored-by: Andrew Kenworthy <andrew.kenworthy@stackable.de>
1 parent 355965e commit 5185d67

22 files changed

Lines changed: 313 additions & 11 deletions

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
- Log aggregation added ([#326]).
88
- Deploy default and support custom affinities ([#337]).
9+
- Extend cluster resources for status and cluster operation (paused, stopped) ([#348])
910

1011
### Changed
1112

@@ -19,6 +20,7 @@
1920
[#326]: https://github.com/stackabletech/superset-operator/pull/326
2021
[#337]: https://github.com/stackabletech/superset-operator/pull/337
2122
[#344]: https://github.com/stackabletech/superset-operator/pull/344
23+
[#348]: https://github.com/stackabletech/superset-operator/pull/348
2224

2325
## [23.1.0] - 2023-01-23
2426

Cargo.lock

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

deploy/helm/superset-operator/crds/crds.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,21 @@ spec:
4747
description: This role will be given in addition to any AUTH_ROLES_MAPPING. Gets mapped to `AUTH_USER_REGISTRATION_ROLE`
4848
type: string
4949
type: object
50+
clusterOperation:
51+
default:
52+
stopped: false
53+
reconciliationPaused: false
54+
description: Cluster operations like pause reconciliation or cluster stop.
55+
properties:
56+
reconciliationPaused:
57+
default: false
58+
description: Flag to stop cluster reconciliation by the operator. This means that all changes in the custom resource spec are ignored until this flag is set to false or removed. The operator will however still watch the deployed resources at the time and update the custom resource status field. If applied at the same time with `stopped`, `reconciliationPaused` will take precedence over `stopped` and stop the reconciliation immediately.
59+
type: boolean
60+
stopped:
61+
default: false
62+
description: Flag to stop the cluster. This means all deployed resources (e.g. Services, StatefulSets, ConfigMaps) are kept but all deployed Pods (e.g. replicas from a StatefulSet) are scaled to 0 and therefore stopped and removed. If applied at the same time with `reconciliationPaused`, the latter will pause reconciliation and `stopped` will take no effect until `reconciliationPaused` is set to false or removed.
63+
type: boolean
64+
type: object
5065
credentialsSecret:
5166
type: string
5267
databaseInitialization:
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
= Cluster Operation
2+
3+
Superset installations can be configured with different cluster operations like pausing reconciliation or stopping the
4+
cluster. See xref:concepts:cluster_operations.adoc[cluster operations] for more details.

docs/modules/superset/partials/nav.adoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@
1010
** xref:superset:usage-guide/logging.adoc[]
1111
** xref:superset:usage-guide/configuration-environment-overrides.adoc[]
1212
* xref:superset:configuration.adoc[]
13+
* xref:superset:cluster_operations.adoc[]

rust/crd/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ publish = false
1111
[dependencies]
1212
serde = "1.0"
1313
serde_json = "1.0"
14-
stackable-operator = { git = "https://github.com/stackabletech/operator-rs.git", tag = "0.36.0" }
14+
stackable-operator = { git = "https://github.com/stackabletech/operator-rs.git", tag = "0.39.0" }
1515
strum = { version = "0.24", features = ["derive"] }
1616
snafu = "0.7"
1717
tracing = "0.1"

rust/crd/src/lib.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use affinity::get_affinity;
66
use serde::{Deserialize, Serialize};
77
use snafu::{OptionExt, ResultExt, Snafu};
88
use stackable_operator::commons::affinity::StackableAffinity;
9+
use stackable_operator::commons::cluster_operation::ClusterOperation;
910
use stackable_operator::commons::product_image_selection::ProductImage;
1011
use stackable_operator::kube::ResourceExt;
1112
use stackable_operator::role_utils::RoleGroup;
@@ -164,6 +165,9 @@ pub struct SupersetClusterSpec {
164165
/// Use with caution.
165166
#[serde(default, skip_serializing_if = "Option::is_none")]
166167
pub service_type: Option<ServiceType>,
168+
/// Cluster operations like pause reconciliation or cluster stop.
169+
#[serde(default)]
170+
pub cluster_operation: ClusterOperation,
167171
}
168172

169173
// TODO: Temporary solution until listener-operator is finished

rust/operator-binary/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@ futures = { version = "0.3", features = ["compat"] }
1616
indoc = "1.0"
1717
serde = "1.0"
1818
snafu = "0.7"
19-
stackable-operator = { git = "https://github.com/stackabletech/operator-rs.git", tag = "0.36.0" }
19+
stackable-operator = { git = "https://github.com/stackabletech/operator-rs.git", tag = "0.39.0" }
2020
stackable-superset-crd = { path = "../crd" }
2121
strum = { version = "0.24", features = ["derive"] }
2222
tokio = { version = "1.25", features = ["macros", "rt-multi-thread"] }
2323
tracing = "0.1"
2424

2525
[build-dependencies]
2626
built = { version = "0.5", features = ["chrono", "git2"] }
27-
stackable-operator = { git = "https://github.com/stackabletech/operator-rs.git", tag = "0.36.0" }
27+
stackable-operator = { git = "https://github.com/stackabletech/operator-rs.git", tag = "0.39.0" }
2828
stackable-superset-crd = { path = "../crd" }

rust/operator-binary/src/superset_controller.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ use crate::{
1212

1313
use indoc::formatdoc;
1414
use snafu::{OptionExt, ResultExt, Snafu};
15+
use stackable_operator::cluster_resources::ClusterResourceApplyStrategy;
1516
use stackable_operator::commons::product_image_selection::ResolvedProductImage;
1617
use stackable_operator::{
1718
builder::{ConfigMapBuilder, ContainerBuilder, ObjectMetaBuilder, PodBuilder},
@@ -268,12 +269,13 @@ pub async fn reconcile_superset(superset: Arc<SupersetCluster>, ctx: Arc<Ctx>) -
268269
OPERATOR_NAME,
269270
SUPERSET_CONTROLLER_NAME,
270271
&superset.object_ref(&()),
272+
ClusterResourceApplyStrategy::from(&superset.spec.cluster_operation),
271273
)
272274
.context(CreateClusterResourcesSnafu)?;
273275

274276
let node_role_service = build_node_role_service(&superset, &resolved_product_image)?;
275277
cluster_resources
276-
.add(client, &node_role_service)
278+
.add(client, node_role_service)
277279
.await
278280
.context(ApplyRoleServiceSnafu)?;
279281

@@ -325,19 +327,19 @@ pub async fn reconcile_superset(superset: Arc<SupersetCluster>, ctx: Arc<Ctx>) -
325327
&config,
326328
)?;
327329
cluster_resources
328-
.add(client, &rg_service)
330+
.add(client, rg_service)
329331
.await
330332
.with_context(|_| ApplyRoleGroupServiceSnafu {
331333
rolegroup: rolegroup.clone(),
332334
})?;
333335
cluster_resources
334-
.add(client, &rg_configmap)
336+
.add(client, rg_configmap)
335337
.await
336338
.with_context(|_| ApplyRoleGroupConfigSnafu {
337339
rolegroup: rolegroup.clone(),
338340
})?;
339341
cluster_resources
340-
.add(client, &rg_statefulset)
342+
.add(client, rg_statefulset)
341343
.await
342344
.with_context(|_| ApplyRoleGroupStatefulSetSnafu {
343345
rolegroup: rolegroup.clone(),
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
apiVersion: kuttl.dev/v1beta1
3+
kind: TestAssert
4+
metadata:
5+
name: test-superset-postgresql
6+
timeout: 480
7+
---
8+
apiVersion: apps/v1
9+
kind: StatefulSet
10+
metadata:
11+
name: superset-postgresql
12+
status:
13+
readyReplicas: 1
14+
replicas: 1

0 commit comments

Comments
 (0)