Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
2a37410
Delete orphaned resources
siegfriedweber Jun 21, 2022
494f8a4
Create integration test for handling of orphaned resources
siegfriedweber Jun 23, 2022
b27a631
Upgrade to changed ClusterResources API
siegfriedweber Jul 11, 2022
d4e8c0a
Upgrade to changed ClusterResources API
siegfriedweber Jul 13, 2022
2396dba
Upgrade to changed ClusterResources API
siegfriedweber Jul 18, 2022
2315e1f
Update operator-rs
siegfriedweber Jul 18, 2022
8efd97b
Update changelog
siegfriedweber Jul 18, 2022
a007b56
Merge branch 'main' into orphaned_resources_handling
siegfriedweber Jul 18, 2022
6d81268
Adapt code style to other operators
siegfriedweber Jul 18, 2022
5fb1fbc
Merge branch 'main' into orphaned_resources_handling
siegfriedweber Jul 19, 2022
30f1508
Temporarily allow overriding the operator-rs location
siegfriedweber Jul 19, 2022
90ae417
Update operator-rs
siegfriedweber Jul 20, 2022
f110337
Merge branch 'main' into orphaned_resources_handling
siegfriedweber Jul 27, 2022
40f4aee
Update operator-rs
siegfriedweber Jul 27, 2022
1634499
Remove HBase 2.4.8 from the integration tests to decrease the amount …
siegfriedweber Jul 27, 2022
0e834ef
Update operator-rs
siegfriedweber Aug 1, 2022
2c4a099
Merge branch 'main' into orphaned_resources_handling
siegfriedweber Aug 4, 2022
411975d
Upgrade stackable-operator to version 0.24.0
siegfriedweber Aug 4, 2022
3762c53
Disable overriding the operator-rs location
siegfriedweber Aug 4, 2022
0b18a87
Add HBase 2.4.8 again to the integration tests
siegfriedweber Aug 4, 2022
a8f50f9
Remove all but the latest product versions from the test matrix
siegfriedweber Aug 4, 2022
ccbca8a
Use all product versions in the smoke test but only the latest ones i…
siegfriedweber Aug 4, 2022
258ad6d
Use error files instead of calling "kubectl kuttl errors"
siegfriedweber Aug 4, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,15 @@

## Changed

- Startup probe created and thresholds in liveness and readiness probes fine-tuned ([#193]).
- Include chart name when installing with a custom release name ([#209], [#210]).
- Orphaned resources are deleted ([#215]).
- Fix HBase-shell start failure ([#218]).

[#193]: https://github.com/stackabletech/hbase-operator/pull/193
[#209]: https://github.com/stackabletech/hbase-operator/pull/209
[#210]: https://github.com/stackabletech/hbase-operator/pull/210
[#215]: https://github.com/stackabletech/hbase-operator/pull/215
[#218]: https://github.com/stackabletech/hbase-operator/pull/218

## [0.3.0] - 2022-06-30
Expand All @@ -30,7 +34,6 @@
- `hbaseManagesZk`: defaults to false
- `hbaseClusterDistributed`: defaults to true
- [BREAKING] Specifying the product version has been changed to adhere to [ADR018](https://docs.stackable.tech/home/contributor/adr/ADR018-product_image_versioning.html) instead of just specifying the product version you will now have to add the Stackable image version as well, so `version: 3.5.8` becomes (for example) `version: 3.5.8-stackable0.1.0` ([#179])
- Startup probe created and thresholds in liveness and readiness probes fine-tuned ([#193]).

[#133]: https://github.com/stackabletech/hbase-operator/pull/133
[#137]: https://github.com/stackabletech/hbase-operator/pull/137
Expand All @@ -39,7 +42,6 @@
[#162]: https://github.com/stackabletech/hbase-operator/pull/162
[#163]: https://github.com/stackabletech/hbase-operator/pull/163
[#179]: https://github.com/stackabletech/hbase-operator/pull/179
[#193]: https://github.com/stackabletech/hbase-operator/pull/193
[#197]: https://github.com/stackabletech/hbase-operator/pull/197

## [0.2.0] - 2022-02-14
Expand Down
28 changes: 14 additions & 14 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion rust/crd/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ version = "0.4.0-nightly"
[dependencies]
serde = "1.0"
serde_json = "1.0"
stackable-operator = { git = "https://github.com/stackabletech/operator-rs.git", tag = "0.22.0" }
stackable-operator = { git = "https://github.com/stackabletech/operator-rs.git", tag = "0.24.0" }
strum = { version = "0.24", features = ["derive"] }
4 changes: 2 additions & 2 deletions rust/operator-binary/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ serde = "1.0"
serde_yaml = "0.9"
snafu = "0.7"
stackable-hbase-crd = { path = "../crd" }
stackable-operator = { git = "https://github.com/stackabletech/operator-rs.git", tag = "0.22.0" }
stackable-operator = { git = "https://github.com/stackabletech/operator-rs.git", tag = "0.24.0" }
strum = { version = "0.24", features = ["derive"] }
tokio = { version = "1.20", features = ["macros", "rt-multi-thread"] }
tracing = "0.1"

[build-dependencies]
built = { version = "0.5", features = ["chrono", "git2"] }
stackable-hbase-crd = { path = "../crd" }
stackable-operator = { git = "https://github.com/stackabletech/operator-rs.git", tag = "0.22.0" }
stackable-operator = { git = "https://github.com/stackabletech/operator-rs.git", tag = "0.24.0" }
2 changes: 2 additions & 0 deletions rust/operator-binary/src/discovery.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ use std::collections::HashMap;
pub fn build_discovery_configmap(
hbase: &HbaseCluster,
zookeeper_connect_string: &str,
managed_by: &str,
) -> OperatorResult<ConfigMap> {
let hbase_site_data: HashMap<String, Option<String>> = [(
HBASE_ZOOKEEPER_QUORUM.to_string(),
Expand All @@ -29,6 +30,7 @@ pub fn build_discovery_configmap(
hbase,
APP_NAME,
hbase_version(hbase).map_err(|_| Error::MissingObjectKey { key: "version" })?,
managed_by,
&HbaseRole::RegionServer.to_string(),
"discovery",
)
Expand Down
62 changes: 44 additions & 18 deletions rust/operator-binary/src/hbase_controller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use stackable_hbase_crd::{
};
use stackable_operator::{
builder::{ConfigMapBuilder, ContainerBuilder, ObjectMetaBuilder, PodBuilder},
cluster_resources::ClusterResources,
k8s_openapi::{
api::{
apps::v1::{StatefulSet, StatefulSetSpec},
Expand All @@ -18,7 +19,7 @@ use stackable_operator::{
},
apimachinery::pkg::{apis::meta::v1::LabelSelector, util::intstr::IntOrString},
},
kube::{runtime::controller::Action, ResourceExt},
kube::{runtime::controller::Action, Resource, ResourceExt},
labels::{role_group_selector_labels, role_selector_labels},
logging::controller::ReconcilerError,
product_config::{types::PropertyNameKind, writer, ProductConfigManager},
Expand All @@ -32,7 +33,7 @@ use std::{
};
use strum::{EnumDiscriminants, IntoStaticStr};

const FIELD_MANAGER_SCOPE: &str = "hbasecluster";
const CONTROLLER_NAME: &str = "hbase-operator";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not the same. The field manager needs to identify the controller within the operator.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"hbase-operator" is the controller name in this case. As there is only one controller in this operator, it should not pose a problem. But if you see a problem then please create a ticket. I agree that this naming is a bit confusing. So we could provide both, operator name and controller name, to ClusterResources.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


const CONFIG_DIR_NAME: &str = "/stackable/conf";
const HDFS_DISCOVERY_TMP_DIR: &str = "/stackable/tmp/hdfs";
Expand All @@ -57,6 +58,14 @@ pub enum Error {
NoRegionServerRole,
#[snafu(display("failed to calculate global service name"))]
GlobalServiceNameNotFound,
#[snafu(display("failed to create cluster resources"))]
CreateClusterResources {
source: stackable_operator::error::Error,
},
#[snafu(display("failed to delete orphaned resources"))]
DeleteOrphanedResources {
source: stackable_operator::error::Error,
},
#[snafu(display("failed to apply global Service"))]
ApplyRoleService {
source: stackable_operator::error::Error,
Expand Down Expand Up @@ -155,21 +164,21 @@ pub async fn reconcile_hbase(hbase: Arc<HbaseCluster>, ctx: Arc<Ctx>) -> Result<
)
.context(InvalidProductConfigSnafu)?;

let mut cluster_resources =
ClusterResources::new(APP_NAME, CONTROLLER_NAME, &hbase.object_ref(&()))
.context(CreateClusterResourcesSnafu)?;

let region_server_role_service = build_region_server_role_service(&hbase)?;
client
.apply_patch(
FIELD_MANAGER_SCOPE,
&region_server_role_service,
&region_server_role_service,
)
cluster_resources
.add(client, &region_server_role_service)
.await
.context(ApplyRoleServiceSnafu)?;

// discovery config map
let discovery_cm = build_discovery_configmap(&hbase, &zk_connect_string)
let discovery_cm = build_discovery_configmap(&hbase, &zk_connect_string, CONTROLLER_NAME)
.context(BuildDiscoveryConfigMapSnafu)?;
client
.apply_patch(FIELD_MANAGER_SCOPE, &discovery_cm, &discovery_cm)
cluster_resources
.add(client, &discovery_cm)
.await
.context(ApplyDiscoveryConfigMapSnafu)?;

Expand All @@ -184,27 +193,32 @@ pub async fn reconcile_hbase(hbase: Arc<HbaseCluster>, ctx: Arc<Ctx>) -> Result<
&zk_connect_string,
)?;
let rg_statefulset = build_rolegroup_statefulset(&hbase, &rolegroup, rolegroup_config)?;
client
.apply_patch(FIELD_MANAGER_SCOPE, &rg_service, &rg_service)
cluster_resources
.add(client, &rg_service)
.await
.with_context(|_| ApplyRoleGroupServiceSnafu {
rolegroup: rolegroup.clone(),
})?;
client
.apply_patch(FIELD_MANAGER_SCOPE, &rg_configmap, &rg_configmap)
cluster_resources
.add(client, &rg_configmap)
.await
.with_context(|_| ApplyRoleGroupConfigSnafu {
rolegroup: rolegroup.clone(),
})?;
client
.apply_patch(FIELD_MANAGER_SCOPE, &rg_statefulset, &rg_statefulset)
cluster_resources
.add(client, &rg_statefulset)
.await
.with_context(|_| ApplyRoleGroupStatefulSetSnafu {
rolegroup: rolegroup.clone(),
})?;
}
}

cluster_resources
.delete_orphaned_resources(client)
.await
.context(DeleteOrphanedResourcesSnafu)?;

Ok(Action::await_change())
}

Expand Down Expand Up @@ -233,7 +247,14 @@ pub fn build_region_server_role_service(hbase: &HbaseCluster) -> Result<Service>
.name(&role_svc_name)
.ownerreference_from_resource(hbase, None, Some(true))
.context(ObjectMissingMetadataForOwnerRefSnafu)?
.with_recommended_labels(hbase, APP_NAME, hbase_version(hbase)?, &role_name, "global")
.with_recommended_labels(
hbase,
APP_NAME,
hbase_version(hbase)?,
CONTROLLER_NAME,
&role_name,
"global",
)
.build(),
spec: Some(ServiceSpec {
ports: Some(ports),
Expand Down Expand Up @@ -285,6 +306,7 @@ fn build_rolegroup_config_map(
hbase,
APP_NAME,
hbase_version(hbase)?,
CONTROLLER_NAME,
&rolegroup.role,
&rolegroup.role_group,
)
Expand Down Expand Up @@ -332,6 +354,7 @@ fn build_rolegroup_service(
hbase,
APP_NAME,
hbase_version(hbase)?,
CONTROLLER_NAME,
&rolegroup.role,
&rolegroup.role_group,
)
Expand Down Expand Up @@ -423,6 +446,7 @@ fn build_rolegroup_statefulset(
};

let container = ContainerBuilder::new("hbase")
.expect("ContainerBuilder not created")
.image(image)
.command(vec![
"/bin/bash".to_string(),
Expand Down Expand Up @@ -471,6 +495,7 @@ fn build_rolegroup_statefulset(
hbase,
APP_NAME,
hbase_version,
CONTROLLER_NAME,
&rolegroup_ref.role,
&rolegroup_ref.role_group,
)
Expand All @@ -494,6 +519,7 @@ fn build_rolegroup_statefulset(
hbase,
APP_NAME,
hbase_version,
CONTROLLER_NAME,
&rolegroup_ref.role,
&rolegroup_ref.role_group,
)
Expand Down
14 changes: 14 additions & 0 deletions tests/templates/kuttl/orphaned_resources/00-assert.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
apiVersion: kuttl.dev/v1beta1
kind: TestAssert
metadata:
name: install-zk
timeout: 600
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: test-zk-server-default
status:
readyReplicas: 1
replicas: 1
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
apiVersion: zookeeper.stackable.tech/v1alpha1
kind: ZookeeperCluster
metadata:
name: test-zk
spec:
servers:
roleGroups:
default:
replicas: 1
version: {{ test_scenario['values']['zookeeper-latest'] }}
---
apiVersion: zookeeper.stackable.tech/v1alpha1
kind: ZookeeperZnode
metadata:
name: test-znode
spec:
clusterRef:
name: test-zk
30 changes: 30 additions & 0 deletions tests/templates/kuttl/orphaned_resources/01-assert.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
apiVersion: kuttl.dev/v1beta1
kind: TestAssert
metadata:
name: install-hdfs
timeout: 600
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: test-hdfs-namenode-default
status:
readyReplicas: 2
replicas: 2
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: test-hdfs-journalnode-default
status:
readyReplicas: 1
replicas: 1
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: test-hdfs-datanode-default
status:
readyReplicas: 1
replicas: 1
Loading