From 2a37410a46979e232fe9f9d4cdda4ca9b4459445 Mon Sep 17 00:00:00 2001 From: Siegfried Weber Date: Tue, 21 Jun 2022 17:19:20 +0200 Subject: [PATCH 01/19] Delete orphaned resources --- CHANGELOG.md | 9 ++- Cargo.lock | 8 +- Cargo.toml | 3 + rust/operator-binary/src/hbase_controller.rs | 79 +++++++------------- 4 files changed, 41 insertions(+), 58 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 535826c8..920e3201 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,13 @@ ## [Unreleased] +## Changed + +- Startup probe created and thresholds in liveness and readiness probes fine-tuned ([#193]). +- Orphaned resources are deleted + +[#193]: https://github.com/stackabletech/hbase-operator/pull/193 + ## [0.3.0] - 2022-06-30 ### Added @@ -21,7 +28,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 @@ -30,7 +36,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 diff --git a/Cargo.lock b/Cargo.lock index f280b319..79e403c7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -349,9 +349,9 @@ checksum = "140206b78fb2bc3edbcfc9b5ccbd0b30699cfe8d348b8b31b330e47df5291a5a" [[package]] name = "either" -version = "1.6.1" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457" +checksum = "3f107b87b6afc2a64fd13cac55fe06d6c8859f12d4b14cbcdd2c67d0976781be" [[package]] name = "encoding" @@ -1681,7 +1681,7 @@ dependencies = [ [[package]] name = "stackable-operator" version = "0.22.0" -source = "git+https://github.com/stackabletech/operator-rs.git?tag=0.22.0#5543877169d27770578e634d0d734aa6126f838c" +source = "git+https://github.com//stackabletech/operator-rs.git?branch=orphaned_resources_handling#36eeef436ee2c190ec093e498c5f7f0fdc65f2ea" dependencies = [ "backoff", "chrono", @@ -1715,7 +1715,7 @@ dependencies = [ [[package]] name = "stackable-operator-derive" version = "0.22.0" -source = "git+https://github.com/stackabletech/operator-rs.git?tag=0.22.0#5543877169d27770578e634d0d734aa6126f838c" +source = "git+https://github.com//stackabletech/operator-rs.git?branch=orphaned_resources_handling#36eeef436ee2c190ec093e498c5f7f0fdc65f2ea" dependencies = [ "darling", "proc-macro2", diff --git a/Cargo.toml b/Cargo.toml index 3d9de0bf..65426c73 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,2 +1,5 @@ [workspace] members = ["rust/crd", "rust/operator-binary"] + +[patch."https://github.com/stackabletech/operator-rs.git"] +stackable-operator = { git = "https://github.com//stackabletech/operator-rs.git", branch = "orphaned_resources_handling" } diff --git a/rust/operator-binary/src/hbase_controller.rs b/rust/operator-binary/src/hbase_controller.rs index ceef3f2a..05975241 100644 --- a/rust/operator-binary/src/hbase_controller.rs +++ b/rust/operator-binary/src/hbase_controller.rs @@ -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}, @@ -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}, @@ -57,17 +58,8 @@ pub enum Error { NoRegionServerRole, #[snafu(display("failed to calculate global service name"))] GlobalServiceNameNotFound, - #[snafu(display("failed to apply global Service"))] - ApplyRoleService { - source: stackable_operator::error::Error, - }, - #[snafu(display("failed to apply Service for {}", rolegroup))] - ApplyRoleGroupService { - source: stackable_operator::error::Error, - rolegroup: RoleGroupRef, - }, - #[snafu(display("failed to apply discovery configmap"))] - ApplyDiscoveryConfigMap { + #[snafu(display("failed to update cluster resources"))] + UpdateClusterResources { source: stackable_operator::error::Error, }, #[snafu(display("failed to build discovery configmap"))] @@ -79,16 +71,6 @@ pub enum Error { source: stackable_operator::error::Error, rolegroup: RoleGroupRef, }, - #[snafu(display("failed to apply ConfigMap for {}", rolegroup))] - ApplyRoleGroupConfig { - source: stackable_operator::error::Error, - rolegroup: RoleGroupRef, - }, - #[snafu(display("failed to apply StatefulSet for {}", rolegroup))] - ApplyRoleGroupStatefulSet { - source: stackable_operator::error::Error, - rolegroup: RoleGroupRef, - }, #[snafu(display("failed to generate product config"))] GenerateProductConfig { source: stackable_operator::product_config_utils::ConfigError, @@ -155,56 +137,49 @@ pub async fn reconcile_hbase(hbase: Arc, ctx: Arc) -> Result< ) .context(InvalidProductConfigSnafu)?; + let mut cluster_services = Vec::new(); + let mut cluster_configmaps = Vec::new(); + let mut cluster_statefulsets = Vec::new(); + let region_server_role_service = build_region_server_role_service(&hbase)?; - client - .apply_patch( - FIELD_MANAGER_SCOPE, - ®ion_server_role_service, - ®ion_server_role_service, - ) - .await - .context(ApplyRoleServiceSnafu)?; + cluster_services.push(region_server_role_service); // discovery config map let discovery_cm = build_discovery_configmap(&hbase, &zk_connect_string) .context(BuildDiscoveryConfigMapSnafu)?; - client - .apply_patch(FIELD_MANAGER_SCOPE, &discovery_cm, &discovery_cm) - .await - .context(ApplyDiscoveryConfigMapSnafu)?; + cluster_configmaps.push(discovery_cm); for (role_name, group_config) in validated_config.iter() { for (rolegroup_name, rolegroup_config) in group_config.iter() { let rolegroup = hbase.server_rolegroup_ref(role_name, rolegroup_name); let rg_service = build_rolegroup_service(&hbase, &rolegroup, rolegroup_config)?; + cluster_services.push(rg_service); + let rg_configmap = build_rolegroup_config_map( &hbase, &rolegroup, rolegroup_config, &zk_connect_string, )?; + cluster_configmaps.push(rg_configmap); + let rg_statefulset = build_rolegroup_statefulset(&hbase, &rolegroup, rolegroup_config)?; - client - .apply_patch(FIELD_MANAGER_SCOPE, &rg_service, &rg_service) - .await - .with_context(|_| ApplyRoleGroupServiceSnafu { - rolegroup: rolegroup.clone(), - })?; - client - .apply_patch(FIELD_MANAGER_SCOPE, &rg_configmap, &rg_configmap) - .await - .with_context(|_| ApplyRoleGroupConfigSnafu { - rolegroup: rolegroup.clone(), - })?; - client - .apply_patch(FIELD_MANAGER_SCOPE, &rg_statefulset, &rg_statefulset) - .await - .with_context(|_| ApplyRoleGroupStatefulSetSnafu { - rolegroup: rolegroup.clone(), - })?; + cluster_statefulsets.push(rg_statefulset); } } + ClusterResources::new( + APP_NAME, + FIELD_MANAGER_SCOPE, + &hbase.object_ref(&()), + &cluster_services, + &cluster_configmaps, + &cluster_statefulsets, + ) + .update(client) + .await + .context(UpdateClusterResourcesSnafu)?; + Ok(Action::await_change()) } From 494f8a4f0b1bdd2d3f01786e92b905ce21ebf1eb Mon Sep 17 00:00:00 2001 From: Siegfried Weber Date: Thu, 23 Jun 2022 14:51:17 +0200 Subject: [PATCH 02/19] Create integration test for handling of orphaned resources --- .../kuttl/orphaned_resources/00-assert.yaml | 14 +++++++++ .../00-install-zookeeper.yaml.j2 | 19 ++++++++++++ .../kuttl/orphaned_resources/01-assert.yaml | 30 +++++++++++++++++++ .../01-install-hdfs.yaml.j2 | 21 +++++++++++++ .../kuttl/orphaned_resources/02-assert.yaml | 30 +++++++++++++++++++ .../02-install-hbase.yaml.j2 | 23 ++++++++++++++ .../kuttl/orphaned_resources/03-assert.yaml | 10 +++++++ .../03-remove-restserver.yaml | 7 +++++ .../kuttl/orphaned_resources/04-assert.yaml | 30 +++++++++++++++++++ .../04-change-regionserver-rolegroup.yaml | 11 +++++++ .../orphaned_regionserver.yaml | 20 +++++++++++++ .../orphaned_restserver.yaml | 20 +++++++++++++ tests/test-definition.yaml | 5 ++++ 13 files changed, 240 insertions(+) create mode 100644 tests/templates/kuttl/orphaned_resources/00-assert.yaml create mode 100644 tests/templates/kuttl/orphaned_resources/00-install-zookeeper.yaml.j2 create mode 100644 tests/templates/kuttl/orphaned_resources/01-assert.yaml create mode 100644 tests/templates/kuttl/orphaned_resources/01-install-hdfs.yaml.j2 create mode 100644 tests/templates/kuttl/orphaned_resources/02-assert.yaml create mode 100644 tests/templates/kuttl/orphaned_resources/02-install-hbase.yaml.j2 create mode 100644 tests/templates/kuttl/orphaned_resources/03-assert.yaml create mode 100644 tests/templates/kuttl/orphaned_resources/03-remove-restserver.yaml create mode 100644 tests/templates/kuttl/orphaned_resources/04-assert.yaml create mode 100644 tests/templates/kuttl/orphaned_resources/04-change-regionserver-rolegroup.yaml create mode 100644 tests/templates/kuttl/orphaned_resources/orphaned_regionserver.yaml create mode 100644 tests/templates/kuttl/orphaned_resources/orphaned_restserver.yaml diff --git a/tests/templates/kuttl/orphaned_resources/00-assert.yaml b/tests/templates/kuttl/orphaned_resources/00-assert.yaml new file mode 100644 index 00000000..a1e216b4 --- /dev/null +++ b/tests/templates/kuttl/orphaned_resources/00-assert.yaml @@ -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 diff --git a/tests/templates/kuttl/orphaned_resources/00-install-zookeeper.yaml.j2 b/tests/templates/kuttl/orphaned_resources/00-install-zookeeper.yaml.j2 new file mode 100644 index 00000000..45f9eb8a --- /dev/null +++ b/tests/templates/kuttl/orphaned_resources/00-install-zookeeper.yaml.j2 @@ -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'] }} +--- +apiVersion: zookeeper.stackable.tech/v1alpha1 +kind: ZookeeperZnode +metadata: + name: test-znode +spec: + clusterRef: + name: test-zk diff --git a/tests/templates/kuttl/orphaned_resources/01-assert.yaml b/tests/templates/kuttl/orphaned_resources/01-assert.yaml new file mode 100644 index 00000000..8800b24d --- /dev/null +++ b/tests/templates/kuttl/orphaned_resources/01-assert.yaml @@ -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 diff --git a/tests/templates/kuttl/orphaned_resources/01-install-hdfs.yaml.j2 b/tests/templates/kuttl/orphaned_resources/01-install-hdfs.yaml.j2 new file mode 100644 index 00000000..409b740d --- /dev/null +++ b/tests/templates/kuttl/orphaned_resources/01-install-hdfs.yaml.j2 @@ -0,0 +1,21 @@ +--- +apiVersion: hdfs.stackable.tech/v1alpha1 +kind: HdfsCluster +metadata: + name: test-hdfs +spec: + version: {{ test_scenario['values']['hdfs'] }} + zookeeperConfigMapName: test-znode + log4j: "" + nameNodes: + roleGroups: + default: + replicas: 2 + dataNodes: + roleGroups: + default: + replicas: 1 + journalNodes: + roleGroups: + default: + replicas: 1 diff --git a/tests/templates/kuttl/orphaned_resources/02-assert.yaml b/tests/templates/kuttl/orphaned_resources/02-assert.yaml new file mode 100644 index 00000000..c50ea9af --- /dev/null +++ b/tests/templates/kuttl/orphaned_resources/02-assert.yaml @@ -0,0 +1,30 @@ +--- +apiVersion: kuttl.dev/v1beta1 +kind: TestAssert +metadata: + name: install-hbase +timeout: 600 +--- +apiVersion: apps/v1 +kind: StatefulSet +metadata: + name: test-hbase-master-default +status: + readyReplicas: 1 + replicas: 1 +--- +apiVersion: apps/v1 +kind: StatefulSet +metadata: + name: test-hbase-regionserver-default +status: + readyReplicas: 1 + replicas: 1 +--- +apiVersion: apps/v1 +kind: StatefulSet +metadata: + name: test-hbase-restserver-default +status: + readyReplicas: 1 + replicas: 1 diff --git a/tests/templates/kuttl/orphaned_resources/02-install-hbase.yaml.j2 b/tests/templates/kuttl/orphaned_resources/02-install-hbase.yaml.j2 new file mode 100644 index 00000000..6da4c2c7 --- /dev/null +++ b/tests/templates/kuttl/orphaned_resources/02-install-hbase.yaml.j2 @@ -0,0 +1,23 @@ +--- +apiVersion: hbase.stackable.tech/v1alpha1 +kind: HbaseCluster +metadata: + name: test-hbase +spec: + version: {{ test_scenario['values']['hbase'] }} + hdfsConfigMapName: test-hdfs-namenode-default + zookeeperConfigMapName: test-znode + config: + hbaseRootdir: /hbase + masters: + roleGroups: + default: + replicas: 1 + regionServers: + roleGroups: + default: + replicas: 1 + restServers: + roleGroups: + default: + replicas: 1 diff --git a/tests/templates/kuttl/orphaned_resources/03-assert.yaml b/tests/templates/kuttl/orphaned_resources/03-assert.yaml new file mode 100644 index 00000000..9be77038 --- /dev/null +++ b/tests/templates/kuttl/orphaned_resources/03-assert.yaml @@ -0,0 +1,10 @@ +--- +apiVersion: kuttl.dev/v1beta1 +kind: TestAssert +metadata: + name: remove-restserver +timeout: 600 +commands: + - script: | + kubectl kuttl errors --namespace $NAMESPACE \ + ../templates/kuttl/orphaned_resources/orphaned_restserver.yaml diff --git a/tests/templates/kuttl/orphaned_resources/03-remove-restserver.yaml b/tests/templates/kuttl/orphaned_resources/03-remove-restserver.yaml new file mode 100644 index 00000000..062c532b --- /dev/null +++ b/tests/templates/kuttl/orphaned_resources/03-remove-restserver.yaml @@ -0,0 +1,7 @@ +--- +apiVersion: hbase.stackable.tech/v1alpha1 +kind: HbaseCluster +metadata: + name: test-hbase +spec: + restServers: null diff --git a/tests/templates/kuttl/orphaned_resources/04-assert.yaml b/tests/templates/kuttl/orphaned_resources/04-assert.yaml new file mode 100644 index 00000000..841678e5 --- /dev/null +++ b/tests/templates/kuttl/orphaned_resources/04-assert.yaml @@ -0,0 +1,30 @@ +--- +apiVersion: kuttl.dev/v1beta1 +kind: TestAssert +metadata: + name: change-regionserver-rolegroup +timeout: 600 +commands: + - script: | + kubectl kuttl errors --namespace $NAMESPACE \ + ../templates/kuttl/orphaned_resources/orphaned_regionserver.yaml +--- +apiVersion: apps/v1 +kind: StatefulSet +metadata: + name: test-hbase-regionserver-newrolegroup +--- +apiVersion: v1 +kind: Pod +metadata: + name: test-hbase-regionserver-newrolegroup-0 +--- +apiVersion: v1 +kind: ConfigMap +metadata: + name: test-hbase-regionserver-newrolegroup +--- +apiVersion: v1 +kind: Service +metadata: + name: test-hbase-regionserver-newrolegroup diff --git a/tests/templates/kuttl/orphaned_resources/04-change-regionserver-rolegroup.yaml b/tests/templates/kuttl/orphaned_resources/04-change-regionserver-rolegroup.yaml new file mode 100644 index 00000000..aaed32c8 --- /dev/null +++ b/tests/templates/kuttl/orphaned_resources/04-change-regionserver-rolegroup.yaml @@ -0,0 +1,11 @@ +--- +apiVersion: hbase.stackable.tech/v1alpha1 +kind: HbaseCluster +metadata: + name: test-hbase +spec: + regionServers: + roleGroups: + default: null + newrolegroup: + replicas: 1 diff --git a/tests/templates/kuttl/orphaned_resources/orphaned_regionserver.yaml b/tests/templates/kuttl/orphaned_resources/orphaned_regionserver.yaml new file mode 100644 index 00000000..645452c0 --- /dev/null +++ b/tests/templates/kuttl/orphaned_resources/orphaned_regionserver.yaml @@ -0,0 +1,20 @@ +--- +apiVersion: apps/v1 +kind: StatefulSet +metadata: + name: test-hbase-regionserver-default +--- +apiVersion: v1 +kind: Pod +metadata: + name: test-hbase-regionserver-default-0 +--- +apiVersion: v1 +kind: ConfigMap +metadata: + name: test-hbase-regionserver-default +--- +apiVersion: v1 +kind: Service +metadata: + name: test-hbase-regionserver-default diff --git a/tests/templates/kuttl/orphaned_resources/orphaned_restserver.yaml b/tests/templates/kuttl/orphaned_resources/orphaned_restserver.yaml new file mode 100644 index 00000000..ece984dc --- /dev/null +++ b/tests/templates/kuttl/orphaned_resources/orphaned_restserver.yaml @@ -0,0 +1,20 @@ +--- +apiVersion: apps/v1 +kind: StatefulSet +metadata: + name: test-hbase-restserver-default +--- +apiVersion: v1 +kind: Pod +metadata: + name: test-hbase-restserver-default-0 +--- +apiVersion: v1 +kind: ConfigMap +metadata: + name: test-hbase-restserver-default +--- +apiVersion: v1 +kind: Service +metadata: + name: test-hbase-restserver-default diff --git a/tests/test-definition.yaml b/tests/test-definition.yaml index ceaf8f37..db44c558 100644 --- a/tests/test-definition.yaml +++ b/tests/test-definition.yaml @@ -21,3 +21,8 @@ tests: - hbase - zookeeper - hdfs + - name: orphaned_resources + dimensions: + - hbase + - zookeeper + - hdfs From b27a6319531b2f7e94cbc03fc93e7beef3021d2e Mon Sep 17 00:00:00 2001 From: Siegfried Weber Date: Mon, 11 Jul 2022 16:26:35 +0200 Subject: [PATCH 03/19] Upgrade to changed ClusterResources API --- Cargo.lock | 4 ++-- rust/operator-binary/src/hbase_controller.rs | 15 +++++++++++---- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 79e403c7..6774cbd8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1681,7 +1681,7 @@ dependencies = [ [[package]] name = "stackable-operator" version = "0.22.0" -source = "git+https://github.com//stackabletech/operator-rs.git?branch=orphaned_resources_handling#36eeef436ee2c190ec093e498c5f7f0fdc65f2ea" +source = "git+https://github.com//stackabletech/operator-rs.git?branch=orphaned_resources_handling#3bac6be50deb2e22937b9ce439c33d0bf6b48afd" dependencies = [ "backoff", "chrono", @@ -1715,7 +1715,7 @@ dependencies = [ [[package]] name = "stackable-operator-derive" version = "0.22.0" -source = "git+https://github.com//stackabletech/operator-rs.git?branch=orphaned_resources_handling#36eeef436ee2c190ec093e498c5f7f0fdc65f2ea" +source = "git+https://github.com//stackabletech/operator-rs.git?branch=orphaned_resources_handling#3bac6be50deb2e22937b9ce439c33d0bf6b48afd" dependencies = [ "darling", "proc-macro2", diff --git a/rust/operator-binary/src/hbase_controller.rs b/rust/operator-binary/src/hbase_controller.rs index 05975241..ade254e8 100644 --- a/rust/operator-binary/src/hbase_controller.rs +++ b/rust/operator-binary/src/hbase_controller.rs @@ -58,6 +58,10 @@ 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 update cluster resources"))] UpdateClusterResources { source: stackable_operator::error::Error, @@ -168,7 +172,7 @@ pub async fn reconcile_hbase(hbase: Arc, ctx: Arc) -> Result< } } - ClusterResources::new( + let mut cluster_resources = ClusterResources::new( APP_NAME, FIELD_MANAGER_SCOPE, &hbase.object_ref(&()), @@ -176,9 +180,12 @@ pub async fn reconcile_hbase(hbase: Arc, ctx: Arc) -> Result< &cluster_configmaps, &cluster_statefulsets, ) - .update(client) - .await - .context(UpdateClusterResourcesSnafu)?; + .context(CreateClusterResourcesSnafu)?; + + cluster_resources + .update(client) + .await + .context(UpdateClusterResourcesSnafu)?; Ok(Action::await_change()) } From d4e8c0a79cb8befe806bbf0defc73e3ef2f7d05c Mon Sep 17 00:00:00 2001 From: Siegfried Weber Date: Wed, 13 Jul 2022 12:03:32 +0200 Subject: [PATCH 04/19] Upgrade to changed ClusterResources API --- Cargo.lock | 4 +- rust/operator-binary/src/discovery.rs | 2 + rust/operator-binary/src/hbase_controller.rs | 97 ++++++++++++++------ 3 files changed, 74 insertions(+), 29 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6774cbd8..ee6f3708 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1681,7 +1681,7 @@ dependencies = [ [[package]] name = "stackable-operator" version = "0.22.0" -source = "git+https://github.com//stackabletech/operator-rs.git?branch=orphaned_resources_handling#3bac6be50deb2e22937b9ce439c33d0bf6b48afd" +source = "git+https://github.com//stackabletech/operator-rs.git?branch=orphaned_resources_handling#fe4b1b4d1ae903c604dd08909b242ae605b45678" dependencies = [ "backoff", "chrono", @@ -1715,7 +1715,7 @@ dependencies = [ [[package]] name = "stackable-operator-derive" version = "0.22.0" -source = "git+https://github.com//stackabletech/operator-rs.git?branch=orphaned_resources_handling#3bac6be50deb2e22937b9ce439c33d0bf6b48afd" +source = "git+https://github.com//stackabletech/operator-rs.git?branch=orphaned_resources_handling#fe4b1b4d1ae903c604dd08909b242ae605b45678" dependencies = [ "darling", "proc-macro2", diff --git a/rust/operator-binary/src/discovery.rs b/rust/operator-binary/src/discovery.rs index adba475f..330134e0 100644 --- a/rust/operator-binary/src/discovery.rs +++ b/rust/operator-binary/src/discovery.rs @@ -13,6 +13,7 @@ use std::collections::HashMap; pub fn build_discovery_configmap( hbase: &HbaseCluster, zookeeper_connect_string: &str, + operator_name: &str, ) -> OperatorResult { let hbase_site_data: HashMap> = [( HBASE_ZOOKEEPER_QUORUM.to_string(), @@ -29,6 +30,7 @@ pub fn build_discovery_configmap( hbase, APP_NAME, hbase_version(hbase).map_err(|_| Error::MissingObjectKey { key: "version" })?, + operator_name, &HbaseRole::RegionServer.to_string(), "discovery", ) diff --git a/rust/operator-binary/src/hbase_controller.rs b/rust/operator-binary/src/hbase_controller.rs index ade254e8..8c950198 100644 --- a/rust/operator-binary/src/hbase_controller.rs +++ b/rust/operator-binary/src/hbase_controller.rs @@ -33,7 +33,7 @@ use std::{ }; use strum::{EnumDiscriminants, IntoStaticStr}; -const FIELD_MANAGER_SCOPE: &str = "hbasecluster"; +const OPERATOR_NAME: &str = "hbase-operator"; const CONFIG_DIR_NAME: &str = "/stackable/conf"; const HDFS_DISCOVERY_TMP_DIR: &str = "/stackable/tmp/hdfs"; @@ -62,8 +62,21 @@ pub enum Error { CreateClusterResources { source: stackable_operator::error::Error, }, - #[snafu(display("failed to update cluster resources"))] - UpdateClusterResources { + #[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, + }, + #[snafu(display("failed to apply Service for {}", rolegroup))] + ApplyRoleGroupService { + source: stackable_operator::error::Error, + rolegroup: RoleGroupRef, + }, + #[snafu(display("failed to apply discovery configmap"))] + ApplyDiscoveryConfigMap { source: stackable_operator::error::Error, }, #[snafu(display("failed to build discovery configmap"))] @@ -75,6 +88,16 @@ pub enum Error { source: stackable_operator::error::Error, rolegroup: RoleGroupRef, }, + #[snafu(display("failed to apply ConfigMap for {}", rolegroup))] + ApplyRoleGroupConfig { + source: stackable_operator::error::Error, + rolegroup: RoleGroupRef, + }, + #[snafu(display("failed to apply StatefulSet for {}", rolegroup))] + ApplyRoleGroupStatefulSet { + source: stackable_operator::error::Error, + rolegroup: RoleGroupRef, + }, #[snafu(display("failed to generate product config"))] GenerateProductConfig { source: stackable_operator::product_config_utils::ConfigError, @@ -141,51 +164,60 @@ pub async fn reconcile_hbase(hbase: Arc, ctx: Arc) -> Result< ) .context(InvalidProductConfigSnafu)?; - let mut cluster_services = Vec::new(); - let mut cluster_configmaps = Vec::new(); - let mut cluster_statefulsets = Vec::new(); + let mut cluster_resources = + ClusterResources::new(APP_NAME, OPERATOR_NAME, &hbase.object_ref(&())) + .context(CreateClusterResourcesSnafu)?; let region_server_role_service = build_region_server_role_service(&hbase)?; - cluster_services.push(region_server_role_service); + cluster_resources + .add_service(client, ®ion_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, OPERATOR_NAME) .context(BuildDiscoveryConfigMapSnafu)?; - cluster_configmaps.push(discovery_cm); + cluster_resources + .add_configmap(client, &discovery_cm) + .await + .context(ApplyDiscoveryConfigMapSnafu)?; for (role_name, group_config) in validated_config.iter() { for (rolegroup_name, rolegroup_config) in group_config.iter() { let rolegroup = hbase.server_rolegroup_ref(role_name, rolegroup_name); let rg_service = build_rolegroup_service(&hbase, &rolegroup, rolegroup_config)?; - cluster_services.push(rg_service); - let rg_configmap = build_rolegroup_config_map( &hbase, &rolegroup, rolegroup_config, &zk_connect_string, )?; - cluster_configmaps.push(rg_configmap); - let rg_statefulset = build_rolegroup_statefulset(&hbase, &rolegroup, rolegroup_config)?; - cluster_statefulsets.push(rg_statefulset); + cluster_resources + .add_service(client, &rg_service) + .await + .with_context(|_| ApplyRoleGroupServiceSnafu { + rolegroup: rolegroup.clone(), + })?; + cluster_resources + .add_configmap(client, &rg_configmap) + .await + .with_context(|_| ApplyRoleGroupConfigSnafu { + rolegroup: rolegroup.clone(), + })?; + cluster_resources + .add_statefulset(client, &rg_statefulset) + .await + .with_context(|_| ApplyRoleGroupStatefulSetSnafu { + rolegroup: rolegroup.clone(), + })?; } } - let mut cluster_resources = ClusterResources::new( - APP_NAME, - FIELD_MANAGER_SCOPE, - &hbase.object_ref(&()), - &cluster_services, - &cluster_configmaps, - &cluster_statefulsets, - ) - .context(CreateClusterResourcesSnafu)?; - cluster_resources - .update(client) + .finalize(client) .await - .context(UpdateClusterResourcesSnafu)?; + .context(DeleteOrphanedResourcesSnafu)?; Ok(Action::await_change()) } @@ -215,7 +247,14 @@ pub fn build_region_server_role_service(hbase: &HbaseCluster) -> Result .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)?, + OPERATOR_NAME, + &role_name, + "global", + ) .build(), spec: Some(ServiceSpec { ports: Some(ports), @@ -267,6 +306,7 @@ fn build_rolegroup_config_map( hbase, APP_NAME, hbase_version(hbase)?, + OPERATOR_NAME, &rolegroup.role, &rolegroup.role_group, ) @@ -314,6 +354,7 @@ fn build_rolegroup_service( hbase, APP_NAME, hbase_version(hbase)?, + OPERATOR_NAME, &rolegroup.role, &rolegroup.role_group, ) @@ -453,6 +494,7 @@ fn build_rolegroup_statefulset( hbase, APP_NAME, hbase_version, + OPERATOR_NAME, &rolegroup_ref.role, &rolegroup_ref.role_group, ) @@ -476,6 +518,7 @@ fn build_rolegroup_statefulset( hbase, APP_NAME, hbase_version, + OPERATOR_NAME, &rolegroup_ref.role, &rolegroup_ref.role_group, ) From 2396dba1d678b4d20fb8a9f61da80162638525be Mon Sep 17 00:00:00 2001 From: Siegfried Weber Date: Mon, 18 Jul 2022 15:35:51 +0200 Subject: [PATCH 05/19] Upgrade to changed ClusterResources API --- Cargo.lock | 4 ++-- rust/operator-binary/src/hbase_controller.rs | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ee6f3708..eec1e1b4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1681,7 +1681,7 @@ dependencies = [ [[package]] name = "stackable-operator" version = "0.22.0" -source = "git+https://github.com//stackabletech/operator-rs.git?branch=orphaned_resources_handling#fe4b1b4d1ae903c604dd08909b242ae605b45678" +source = "git+https://github.com//stackabletech/operator-rs.git?branch=orphaned_resources_handling#9a2f6171eda0799ea5c79f09bc1c25e3540c6404" dependencies = [ "backoff", "chrono", @@ -1715,7 +1715,7 @@ dependencies = [ [[package]] name = "stackable-operator-derive" version = "0.22.0" -source = "git+https://github.com//stackabletech/operator-rs.git?branch=orphaned_resources_handling#fe4b1b4d1ae903c604dd08909b242ae605b45678" +source = "git+https://github.com//stackabletech/operator-rs.git?branch=orphaned_resources_handling#9a2f6171eda0799ea5c79f09bc1c25e3540c6404" dependencies = [ "darling", "proc-macro2", diff --git a/rust/operator-binary/src/hbase_controller.rs b/rust/operator-binary/src/hbase_controller.rs index 8c950198..d164eefd 100644 --- a/rust/operator-binary/src/hbase_controller.rs +++ b/rust/operator-binary/src/hbase_controller.rs @@ -170,7 +170,7 @@ pub async fn reconcile_hbase(hbase: Arc, ctx: Arc) -> Result< let region_server_role_service = build_region_server_role_service(&hbase)?; cluster_resources - .add_service(client, ®ion_server_role_service) + .add(client, ®ion_server_role_service) .await .context(ApplyRoleServiceSnafu)?; @@ -178,7 +178,7 @@ pub async fn reconcile_hbase(hbase: Arc, ctx: Arc) -> Result< let discovery_cm = build_discovery_configmap(&hbase, &zk_connect_string, OPERATOR_NAME) .context(BuildDiscoveryConfigMapSnafu)?; cluster_resources - .add_configmap(client, &discovery_cm) + .add(client, &discovery_cm) .await .context(ApplyDiscoveryConfigMapSnafu)?; @@ -194,19 +194,19 @@ pub async fn reconcile_hbase(hbase: Arc, ctx: Arc) -> Result< )?; let rg_statefulset = build_rolegroup_statefulset(&hbase, &rolegroup, rolegroup_config)?; cluster_resources - .add_service(client, &rg_service) + .add(client, &rg_service) .await .with_context(|_| ApplyRoleGroupServiceSnafu { rolegroup: rolegroup.clone(), })?; cluster_resources - .add_configmap(client, &rg_configmap) + .add(client, &rg_configmap) .await .with_context(|_| ApplyRoleGroupConfigSnafu { rolegroup: rolegroup.clone(), })?; cluster_resources - .add_statefulset(client, &rg_statefulset) + .add(client, &rg_statefulset) .await .with_context(|_| ApplyRoleGroupStatefulSetSnafu { rolegroup: rolegroup.clone(), From 2315e1fd23790f9e6ecdb4377c10cd8b95bc7140 Mon Sep 17 00:00:00 2001 From: Siegfried Weber Date: Mon, 18 Jul 2022 16:47:57 +0200 Subject: [PATCH 06/19] Update operator-rs --- Cargo.lock | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index eec1e1b4..f310edc9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1395,9 +1395,9 @@ dependencies = [ [[package]] name = "regex" -version = "1.5.6" +version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d83f127d94bdbcda4c8cc2e50f6f84f4b611f69c902699ca385a39c3a75f9ff1" +checksum = "4c4eb3267174b8c6c2f654116623910a0fef09c4753f8dd83db29c48a0df988b" dependencies = [ "aho-corasick", "memchr", @@ -1415,9 +1415,9 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.6.26" +version = "0.6.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49b3de9ec5dc0a3417da371aab17d729997c15010e7fd24ff707773a33bddb64" +checksum = "a3f87b73ce11b1619a3c6332f45341e0047173771e8b8b73f87bfeefb7b56244" [[package]] name = "remove_dir_all" @@ -1681,7 +1681,7 @@ dependencies = [ [[package]] name = "stackable-operator" version = "0.22.0" -source = "git+https://github.com//stackabletech/operator-rs.git?branch=orphaned_resources_handling#9a2f6171eda0799ea5c79f09bc1c25e3540c6404" +source = "git+https://github.com//stackabletech/operator-rs.git?branch=orphaned_resources_handling#f0ce911fa4e4673fd8c26a0ce61e6b80bbbc346e" dependencies = [ "backoff", "chrono", @@ -1715,7 +1715,7 @@ dependencies = [ [[package]] name = "stackable-operator-derive" version = "0.22.0" -source = "git+https://github.com//stackabletech/operator-rs.git?branch=orphaned_resources_handling#9a2f6171eda0799ea5c79f09bc1c25e3540c6404" +source = "git+https://github.com//stackabletech/operator-rs.git?branch=orphaned_resources_handling#f0ce911fa4e4673fd8c26a0ce61e6b80bbbc346e" dependencies = [ "darling", "proc-macro2", From 8efd97b0f8f8a1cb47fabb1cdef9982f47999367 Mon Sep 17 00:00:00 2001 From: Siegfried Weber Date: Mon, 18 Jul 2022 16:49:05 +0200 Subject: [PATCH 07/19] Update changelog --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 920e3201..9808ebd4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,9 +5,10 @@ ## Changed - Startup probe created and thresholds in liveness and readiness probes fine-tuned ([#193]). -- Orphaned resources are deleted +- Orphaned resources are deleted ([#215]). [#193]: https://github.com/stackabletech/hbase-operator/pull/193 +[#215]: https://github.com/stackabletech/hbase-operator/pull/215 ## [0.3.0] - 2022-06-30 From 6d8126838c34c2d2af25ff15ec098aa7bdcba2ca Mon Sep 17 00:00:00 2001 From: Siegfried Weber Date: Mon, 18 Jul 2022 16:53:54 +0200 Subject: [PATCH 08/19] Adapt code style to other operators --- rust/operator-binary/src/discovery.rs | 4 ++-- rust/operator-binary/src/hbase_controller.rs | 16 ++++++++-------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/rust/operator-binary/src/discovery.rs b/rust/operator-binary/src/discovery.rs index 330134e0..432b7002 100644 --- a/rust/operator-binary/src/discovery.rs +++ b/rust/operator-binary/src/discovery.rs @@ -13,7 +13,7 @@ use std::collections::HashMap; pub fn build_discovery_configmap( hbase: &HbaseCluster, zookeeper_connect_string: &str, - operator_name: &str, + managed_by: &str, ) -> OperatorResult { let hbase_site_data: HashMap> = [( HBASE_ZOOKEEPER_QUORUM.to_string(), @@ -30,7 +30,7 @@ pub fn build_discovery_configmap( hbase, APP_NAME, hbase_version(hbase).map_err(|_| Error::MissingObjectKey { key: "version" })?, - operator_name, + managed_by, &HbaseRole::RegionServer.to_string(), "discovery", ) diff --git a/rust/operator-binary/src/hbase_controller.rs b/rust/operator-binary/src/hbase_controller.rs index d164eefd..584fff39 100644 --- a/rust/operator-binary/src/hbase_controller.rs +++ b/rust/operator-binary/src/hbase_controller.rs @@ -33,7 +33,7 @@ use std::{ }; use strum::{EnumDiscriminants, IntoStaticStr}; -const OPERATOR_NAME: &str = "hbase-operator"; +const CONTROLLER_NAME: &str = "hbase-operator"; const CONFIG_DIR_NAME: &str = "/stackable/conf"; const HDFS_DISCOVERY_TMP_DIR: &str = "/stackable/tmp/hdfs"; @@ -165,7 +165,7 @@ pub async fn reconcile_hbase(hbase: Arc, ctx: Arc) -> Result< .context(InvalidProductConfigSnafu)?; let mut cluster_resources = - ClusterResources::new(APP_NAME, OPERATOR_NAME, &hbase.object_ref(&())) + ClusterResources::new(APP_NAME, CONTROLLER_NAME, &hbase.object_ref(&())) .context(CreateClusterResourcesSnafu)?; let region_server_role_service = build_region_server_role_service(&hbase)?; @@ -175,7 +175,7 @@ pub async fn reconcile_hbase(hbase: Arc, ctx: Arc) -> Result< .context(ApplyRoleServiceSnafu)?; // discovery config map - let discovery_cm = build_discovery_configmap(&hbase, &zk_connect_string, OPERATOR_NAME) + let discovery_cm = build_discovery_configmap(&hbase, &zk_connect_string, CONTROLLER_NAME) .context(BuildDiscoveryConfigMapSnafu)?; cluster_resources .add(client, &discovery_cm) @@ -251,7 +251,7 @@ pub fn build_region_server_role_service(hbase: &HbaseCluster) -> Result hbase, APP_NAME, hbase_version(hbase)?, - OPERATOR_NAME, + CONTROLLER_NAME, &role_name, "global", ) @@ -306,7 +306,7 @@ fn build_rolegroup_config_map( hbase, APP_NAME, hbase_version(hbase)?, - OPERATOR_NAME, + CONTROLLER_NAME, &rolegroup.role, &rolegroup.role_group, ) @@ -354,7 +354,7 @@ fn build_rolegroup_service( hbase, APP_NAME, hbase_version(hbase)?, - OPERATOR_NAME, + CONTROLLER_NAME, &rolegroup.role, &rolegroup.role_group, ) @@ -494,7 +494,7 @@ fn build_rolegroup_statefulset( hbase, APP_NAME, hbase_version, - OPERATOR_NAME, + CONTROLLER_NAME, &rolegroup_ref.role, &rolegroup_ref.role_group, ) @@ -518,7 +518,7 @@ fn build_rolegroup_statefulset( hbase, APP_NAME, hbase_version, - OPERATOR_NAME, + CONTROLLER_NAME, &rolegroup_ref.role, &rolegroup_ref.role_group, ) From 30f1508858bec3001584c6dd709835f7451bc806 Mon Sep 17 00:00:00 2001 From: Siegfried Weber Date: Tue, 19 Jul 2022 11:59:58 +0200 Subject: [PATCH 09/19] Temporarily allow overriding the operator-rs location --- deny.toml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/deny.toml b/deny.toml index a557486d..30b7a1c8 100644 --- a/deny.toml +++ b/deny.toml @@ -57,6 +57,9 @@ license-files = [ [sources] unknown-registry = "deny" unknown-git = "deny" +private = [ + "https://github.com//stackabletech" +] [sources.allow-org] github = ["stackabletech"] From 90ae417a6e30eff3b2d6d42c1bcac1c8e6596f2d Mon Sep 17 00:00:00 2001 From: Siegfried Weber Date: Wed, 20 Jul 2022 09:48:33 +0200 Subject: [PATCH 10/19] Update operator-rs --- Cargo.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7596146b..861f3e78 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1681,7 +1681,7 @@ dependencies = [ [[package]] name = "stackable-operator" version = "0.22.0" -source = "git+https://github.com//stackabletech/operator-rs.git?branch=orphaned_resources_handling#f0ce911fa4e4673fd8c26a0ce61e6b80bbbc346e" +source = "git+https://github.com//stackabletech/operator-rs.git?branch=orphaned_resources_handling#15d7315f8e45d6f6bd520106da8b3d5b5107eb4f" dependencies = [ "backoff", "chrono", @@ -1715,7 +1715,7 @@ dependencies = [ [[package]] name = "stackable-operator-derive" version = "0.22.0" -source = "git+https://github.com//stackabletech/operator-rs.git?branch=orphaned_resources_handling#f0ce911fa4e4673fd8c26a0ce61e6b80bbbc346e" +source = "git+https://github.com//stackabletech/operator-rs.git?branch=orphaned_resources_handling#15d7315f8e45d6f6bd520106da8b3d5b5107eb4f" dependencies = [ "darling", "proc-macro2", From 40f4aeec6ab2750f0cbd5449761e5c24ed5aadea Mon Sep 17 00:00:00 2001 From: Siegfried Weber Date: Wed, 27 Jul 2022 16:31:53 +0200 Subject: [PATCH 11/19] Update operator-rs --- Cargo.lock | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 00aeb2fe..5abf5334 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -175,9 +175,9 @@ dependencies = [ [[package]] name = "clap" -version = "3.2.14" +version = "3.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54635806b078b7925d6e36810b1755f2a4b5b4d57560432c1ecf60bcbe10602b" +checksum = "44bbe24bbd31a185bc2c4f7c2abe80bea13a20d57ee4e55be70ac512bdc76417" dependencies = [ "atty", "bitflags", @@ -192,9 +192,9 @@ dependencies = [ [[package]] name = "clap_derive" -version = "3.2.7" +version = "3.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "759bf187376e1afa7b85b959e6a664a3e7a95203415dba952ad19139e798f902" +checksum = "9ba52acd3b0a5c33aeada5cdaa3267cdc7c594a98731d4268cdc1532f4264cb4" dependencies = [ "heck", "proc-macro-error", @@ -830,9 +830,9 @@ dependencies = [ [[package]] name = "kube" -version = "0.73.1" +version = "0.74.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f68b954ea9ad888de953fb1488bd8f377c4c78d82d4642efa5925189210b50b7" +checksum = "a527a8001a61d8d470dab27ac650889938760c243903e7cd90faaf7c60a34bdd" dependencies = [ "k8s-openapi", "kube-client", @@ -843,9 +843,9 @@ dependencies = [ [[package]] name = "kube-client" -version = "0.73.1" +version = "0.74.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9150dc7107d9acf4986088f284a0a6dddc5ae37ef1ffdf142f6811dc5998dd58" +checksum = "c0d48f42df4e8342e9f488c4b97e3759d0042c4e7ab1a853cc285adb44409480" dependencies = [ "base64", "bytes", @@ -880,9 +880,9 @@ dependencies = [ [[package]] name = "kube-core" -version = "0.73.1" +version = "0.74.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc8c429676abe6a73b374438d5ca02caaf9ae7a635441253c589b779fa5d0622" +checksum = "91f56027f862fdcad265d2e9616af416a355e28a1c620bb709083494753e070d" dependencies = [ "chrono", "form_urlencoded", @@ -898,9 +898,9 @@ dependencies = [ [[package]] name = "kube-derive" -version = "0.73.1" +version = "0.74.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfb405f0d39181acbfdc7c79e3fc095330c9b6465ab50aeb662d762e53b662f1" +checksum = "66d74121eb41af4480052901f31142d8d9bbdf1b7c6b856da43bcb02f5b1b177" dependencies = [ "darling", "proc-macro2", @@ -911,9 +911,9 @@ dependencies = [ [[package]] name = "kube-runtime" -version = "0.73.1" +version = "0.74.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6e9e9da456f0101b77f864a9da44866b9891ad4740db508b4b269343ebeb01d" +checksum = "8fdcf5a20f968768e342ef1a457491bb5661fccd81119666d626c57500b16d99" dependencies = [ "ahash", "backoff", @@ -1311,9 +1311,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.40" +version = "1.0.42" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd96a1e8ed2596c337f8eae5f24924ec83f5ad5ab21ea8e455d3566c69fbcaf7" +checksum = "c278e965f1d8cf32d6e0e96de3d3e79712178ae67986d9cf9151f51e95aac89b" dependencies = [ "unicode-ident", ] @@ -1683,8 +1683,8 @@ dependencies = [ [[package]] name = "stackable-operator" -version = "0.22.0" -source = "git+https://github.com//stackabletech/operator-rs.git?branch=orphaned_resources_handling#15d7315f8e45d6f6bd520106da8b3d5b5107eb4f" +version = "0.23.0" +source = "git+https://github.com//stackabletech/operator-rs.git?branch=orphaned_resources_handling#0bc74c5b0a9bb6f2121e727e93c1621b69cc91b8" dependencies = [ "backoff", "chrono", @@ -1717,8 +1717,8 @@ dependencies = [ [[package]] name = "stackable-operator-derive" -version = "0.22.0" -source = "git+https://github.com//stackabletech/operator-rs.git?branch=orphaned_resources_handling#15d7315f8e45d6f6bd520106da8b3d5b5107eb4f" +version = "0.23.0" +source = "git+https://github.com//stackabletech/operator-rs.git?branch=orphaned_resources_handling#0bc74c5b0a9bb6f2121e727e93c1621b69cc91b8" dependencies = [ "darling", "proc-macro2", @@ -1873,9 +1873,9 @@ checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c" [[package]] name = "tokio" -version = "1.20.0" +version = "1.20.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57aec3cfa4c296db7255446efb4928a6be304b431a806216105542a67b6ca82e" +checksum = "7a8325f63a7d4774dd041e363b2409ed1c5cbbd0f867795e661df066b2b0a581" dependencies = [ "autocfg", "libc", From 16344990b1acb82e19b679aa295a3d1ac1a93416 Mon Sep 17 00:00:00 2001 From: Siegfried Weber Date: Wed, 27 Jul 2022 16:33:19 +0200 Subject: [PATCH 12/19] Remove HBase 2.4.8 from the integration tests to decrease the amount of tests --- tests/test-definition.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/test-definition.yaml b/tests/test-definition.yaml index db44c558..c0ec9049 100644 --- a/tests/test-definition.yaml +++ b/tests/test-definition.yaml @@ -6,7 +6,6 @@ dimensions: - 3.3.3-stackable0.1.0 - name: hbase values: - - 2.4.8-stackable0.6.0 - 2.4.9-stackable0.6.0 - 2.4.11-stackable0.6.0 - 2.4.12-stackable0.1.0 From 0e834efa79eb973b41475754bd01db5bb79a1fe0 Mon Sep 17 00:00:00 2001 From: Siegfried Weber Date: Mon, 1 Aug 2022 17:29:15 +0200 Subject: [PATCH 13/19] Update operator-rs --- Cargo.lock | 4 ++-- rust/operator-binary/src/hbase_controller.rs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5abf5334..e207f975 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1684,7 +1684,7 @@ dependencies = [ [[package]] name = "stackable-operator" version = "0.23.0" -source = "git+https://github.com//stackabletech/operator-rs.git?branch=orphaned_resources_handling#0bc74c5b0a9bb6f2121e727e93c1621b69cc91b8" +source = "git+https://github.com//stackabletech/operator-rs.git?branch=orphaned_resources_handling#660f2dc9abd2f47ac27991a69b04b3763658f8e0" dependencies = [ "backoff", "chrono", @@ -1718,7 +1718,7 @@ dependencies = [ [[package]] name = "stackable-operator-derive" version = "0.23.0" -source = "git+https://github.com//stackabletech/operator-rs.git?branch=orphaned_resources_handling#0bc74c5b0a9bb6f2121e727e93c1621b69cc91b8" +source = "git+https://github.com//stackabletech/operator-rs.git?branch=orphaned_resources_handling#660f2dc9abd2f47ac27991a69b04b3763658f8e0" dependencies = [ "darling", "proc-macro2", diff --git a/rust/operator-binary/src/hbase_controller.rs b/rust/operator-binary/src/hbase_controller.rs index 584fff39..b4e1db89 100644 --- a/rust/operator-binary/src/hbase_controller.rs +++ b/rust/operator-binary/src/hbase_controller.rs @@ -215,7 +215,7 @@ pub async fn reconcile_hbase(hbase: Arc, ctx: Arc) -> Result< } cluster_resources - .finalize(client) + .delete_orphaned_resources(client) .await .context(DeleteOrphanedResourcesSnafu)?; From 411975d5a15101f658a6b5962e24f4adab885894 Mon Sep 17 00:00:00 2001 From: Siegfried Weber Date: Thu, 4 Aug 2022 10:27:33 +0200 Subject: [PATCH 14/19] Upgrade stackable-operator to version 0.24.0 --- Cargo.lock | 8 ++++---- Cargo.toml | 3 --- rust/crd/Cargo.toml | 2 +- rust/operator-binary/Cargo.toml | 4 ++-- rust/operator-binary/src/hbase_controller.rs | 1 + 5 files changed, 8 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 285d997b..deadb2bd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1696,8 +1696,8 @@ dependencies = [ [[package]] name = "stackable-operator" -version = "0.23.0" -source = "git+https://github.com//stackabletech/operator-rs.git?branch=orphaned_resources_handling#660f2dc9abd2f47ac27991a69b04b3763658f8e0" +version = "0.24.0" +source = "git+https://github.com/stackabletech/operator-rs.git?tag=0.24.0#8667365352e384e298caa8ebe9f99b2381c190ed" dependencies = [ "backoff", "chrono", @@ -1730,8 +1730,8 @@ dependencies = [ [[package]] name = "stackable-operator-derive" -version = "0.23.0" -source = "git+https://github.com//stackabletech/operator-rs.git?branch=orphaned_resources_handling#660f2dc9abd2f47ac27991a69b04b3763658f8e0" +version = "0.24.0" +source = "git+https://github.com/stackabletech/operator-rs.git?tag=0.24.0#8667365352e384e298caa8ebe9f99b2381c190ed" dependencies = [ "darling", "proc-macro2", diff --git a/Cargo.toml b/Cargo.toml index 65426c73..3d9de0bf 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,5 +1,2 @@ [workspace] members = ["rust/crd", "rust/operator-binary"] - -[patch."https://github.com/stackabletech/operator-rs.git"] -stackable-operator = { git = "https://github.com//stackabletech/operator-rs.git", branch = "orphaned_resources_handling" } diff --git a/rust/crd/Cargo.toml b/rust/crd/Cargo.toml index 752d925b..ceed313c 100644 --- a/rust/crd/Cargo.toml +++ b/rust/crd/Cargo.toml @@ -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"] } diff --git a/rust/operator-binary/Cargo.toml b/rust/operator-binary/Cargo.toml index 9fcb51c8..ec68ad31 100644 --- a/rust/operator-binary/Cargo.toml +++ b/rust/operator-binary/Cargo.toml @@ -16,7 +16,7 @@ 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" @@ -24,4 +24,4 @@ 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" } diff --git a/rust/operator-binary/src/hbase_controller.rs b/rust/operator-binary/src/hbase_controller.rs index b4e1db89..5ee58a56 100644 --- a/rust/operator-binary/src/hbase_controller.rs +++ b/rust/operator-binary/src/hbase_controller.rs @@ -446,6 +446,7 @@ fn build_rolegroup_statefulset( }; let container = ContainerBuilder::new("hbase") + .expect("ContainerBuilder not created") .image(image) .command(vec![ "/bin/bash".to_string(), From 3762c53ddc82fc5796634af3878e5193b54615d1 Mon Sep 17 00:00:00 2001 From: Siegfried Weber Date: Thu, 4 Aug 2022 10:30:17 +0200 Subject: [PATCH 15/19] Disable overriding the operator-rs location --- deny.toml | 3 --- 1 file changed, 3 deletions(-) diff --git a/deny.toml b/deny.toml index 30b7a1c8..a557486d 100644 --- a/deny.toml +++ b/deny.toml @@ -57,9 +57,6 @@ license-files = [ [sources] unknown-registry = "deny" unknown-git = "deny" -private = [ - "https://github.com//stackabletech" -] [sources.allow-org] github = ["stackabletech"] From 0b18a874513d819b40fc83bcf2b369e1b63a6d77 Mon Sep 17 00:00:00 2001 From: Siegfried Weber Date: Thu, 4 Aug 2022 10:38:06 +0200 Subject: [PATCH 16/19] Add HBase 2.4.8 again to the integration tests --- tests/test-definition.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/test-definition.yaml b/tests/test-definition.yaml index c0ec9049..db44c558 100644 --- a/tests/test-definition.yaml +++ b/tests/test-definition.yaml @@ -6,6 +6,7 @@ dimensions: - 3.3.3-stackable0.1.0 - name: hbase values: + - 2.4.8-stackable0.6.0 - 2.4.9-stackable0.6.0 - 2.4.11-stackable0.6.0 - 2.4.12-stackable0.1.0 From a8f50f94578e85b909257e7d5544c35ba390ddc3 Mon Sep 17 00:00:00 2001 From: Siegfried Weber Date: Thu, 4 Aug 2022 11:13:30 +0200 Subject: [PATCH 17/19] Remove all but the latest product versions from the test matrix --- tests/test-definition.yaml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/tests/test-definition.yaml b/tests/test-definition.yaml index db44c558..bf7b81e3 100644 --- a/tests/test-definition.yaml +++ b/tests/test-definition.yaml @@ -2,18 +2,12 @@ dimensions: - name: hdfs values: - - 3.2.2-stackable0.5.0 - 3.3.3-stackable0.1.0 - name: hbase values: - - 2.4.8-stackable0.6.0 - - 2.4.9-stackable0.6.0 - - 2.4.11-stackable0.6.0 - 2.4.12-stackable0.1.0 - name: zookeeper values: - - 3.6.3-stackable0.7.1 - - 3.7.0-stackable0.7.1 - 3.8.0-stackable0.7.1 tests: - name: smoke From ccbca8a8c1712417b2b0f60dc3f8493eee67c8ee Mon Sep 17 00:00:00 2001 From: Siegfried Weber Date: Thu, 4 Aug 2022 14:22:35 +0200 Subject: [PATCH 18/19] Use all product versions in the smoke test but only the latest ones in the orphaned resources test --- .../00-install-zookeeper.yaml.j2 | 2 +- .../01-install-hdfs.yaml.j2 | 2 +- .../02-install-hbase.yaml.j2 | 2 +- tests/test-definition.yaml | 27 ++++++++++++++----- 4 files changed, 24 insertions(+), 9 deletions(-) diff --git a/tests/templates/kuttl/orphaned_resources/00-install-zookeeper.yaml.j2 b/tests/templates/kuttl/orphaned_resources/00-install-zookeeper.yaml.j2 index 45f9eb8a..0626058f 100644 --- a/tests/templates/kuttl/orphaned_resources/00-install-zookeeper.yaml.j2 +++ b/tests/templates/kuttl/orphaned_resources/00-install-zookeeper.yaml.j2 @@ -8,7 +8,7 @@ spec: roleGroups: default: replicas: 1 - version: {{ test_scenario['values']['zookeeper'] }} + version: {{ test_scenario['values']['zookeeper-latest'] }} --- apiVersion: zookeeper.stackable.tech/v1alpha1 kind: ZookeeperZnode diff --git a/tests/templates/kuttl/orphaned_resources/01-install-hdfs.yaml.j2 b/tests/templates/kuttl/orphaned_resources/01-install-hdfs.yaml.j2 index 409b740d..c130c457 100644 --- a/tests/templates/kuttl/orphaned_resources/01-install-hdfs.yaml.j2 +++ b/tests/templates/kuttl/orphaned_resources/01-install-hdfs.yaml.j2 @@ -4,7 +4,7 @@ kind: HdfsCluster metadata: name: test-hdfs spec: - version: {{ test_scenario['values']['hdfs'] }} + version: {{ test_scenario['values']['hdfs-latest'] }} zookeeperConfigMapName: test-znode log4j: "" nameNodes: diff --git a/tests/templates/kuttl/orphaned_resources/02-install-hbase.yaml.j2 b/tests/templates/kuttl/orphaned_resources/02-install-hbase.yaml.j2 index 6da4c2c7..4ac58b8c 100644 --- a/tests/templates/kuttl/orphaned_resources/02-install-hbase.yaml.j2 +++ b/tests/templates/kuttl/orphaned_resources/02-install-hbase.yaml.j2 @@ -4,7 +4,7 @@ kind: HbaseCluster metadata: name: test-hbase spec: - version: {{ test_scenario['values']['hbase'] }} + version: {{ test_scenario['values']['hbase-latest'] }} hdfsConfigMapName: test-hdfs-namenode-default zookeeperConfigMapName: test-znode config: diff --git a/tests/test-definition.yaml b/tests/test-definition.yaml index bf7b81e3..11a39051 100644 --- a/tests/test-definition.yaml +++ b/tests/test-definition.yaml @@ -1,22 +1,37 @@ --- dimensions: + - name: hbase + values: + - 2.4.8-stackable0.6.0 + - 2.4.9-stackable0.6.0 + - 2.4.11-stackable0.6.0 + - 2.4.12-stackable0.1.0 + - name: hbase-latest + values: + - 2.4.12-stackable0.1.0 - name: hdfs values: + - 3.2.2-stackable0.5.0 - 3.3.3-stackable0.1.0 - - name: hbase + - name: hdfs-latest values: - - 2.4.12-stackable0.1.0 + - 3.3.3-stackable0.1.0 - name: zookeeper + values: + - 3.6.3-stackable0.7.1 + - 3.7.0-stackable0.7.1 + - 3.8.0-stackable0.7.1 + - name: zookeeper-latest values: - 3.8.0-stackable0.7.1 tests: - name: smoke dimensions: - hbase - - zookeeper - hdfs + - zookeeper - name: orphaned_resources dimensions: - - hbase - - zookeeper - - hdfs + - hbase-latest + - hdfs-latest + - zookeeper-latest From 258ad6d44bff169f3566a9ffeccbeed980284662 Mon Sep 17 00:00:00 2001 From: Siegfried Weber Date: Thu, 4 Aug 2022 17:25:23 +0200 Subject: [PATCH 19/19] Use error files instead of calling "kubectl kuttl errors" --- tests/templates/kuttl/orphaned_resources/03-assert.yaml | 4 ---- .../{orphaned_restserver.yaml => 03-errors.yaml} | 0 tests/templates/kuttl/orphaned_resources/04-assert.yaml | 4 ---- .../{orphaned_regionserver.yaml => 04-errors.yaml} | 0 4 files changed, 8 deletions(-) rename tests/templates/kuttl/orphaned_resources/{orphaned_restserver.yaml => 03-errors.yaml} (100%) rename tests/templates/kuttl/orphaned_resources/{orphaned_regionserver.yaml => 04-errors.yaml} (100%) diff --git a/tests/templates/kuttl/orphaned_resources/03-assert.yaml b/tests/templates/kuttl/orphaned_resources/03-assert.yaml index 9be77038..69833745 100644 --- a/tests/templates/kuttl/orphaned_resources/03-assert.yaml +++ b/tests/templates/kuttl/orphaned_resources/03-assert.yaml @@ -4,7 +4,3 @@ kind: TestAssert metadata: name: remove-restserver timeout: 600 -commands: - - script: | - kubectl kuttl errors --namespace $NAMESPACE \ - ../templates/kuttl/orphaned_resources/orphaned_restserver.yaml diff --git a/tests/templates/kuttl/orphaned_resources/orphaned_restserver.yaml b/tests/templates/kuttl/orphaned_resources/03-errors.yaml similarity index 100% rename from tests/templates/kuttl/orphaned_resources/orphaned_restserver.yaml rename to tests/templates/kuttl/orphaned_resources/03-errors.yaml diff --git a/tests/templates/kuttl/orphaned_resources/04-assert.yaml b/tests/templates/kuttl/orphaned_resources/04-assert.yaml index 841678e5..bfeeddc9 100644 --- a/tests/templates/kuttl/orphaned_resources/04-assert.yaml +++ b/tests/templates/kuttl/orphaned_resources/04-assert.yaml @@ -4,10 +4,6 @@ kind: TestAssert metadata: name: change-regionserver-rolegroup timeout: 600 -commands: - - script: | - kubectl kuttl errors --namespace $NAMESPACE \ - ../templates/kuttl/orphaned_resources/orphaned_regionserver.yaml --- apiVersion: apps/v1 kind: StatefulSet diff --git a/tests/templates/kuttl/orphaned_resources/orphaned_regionserver.yaml b/tests/templates/kuttl/orphaned_resources/04-errors.yaml similarity index 100% rename from tests/templates/kuttl/orphaned_resources/orphaned_regionserver.yaml rename to tests/templates/kuttl/orphaned_resources/04-errors.yaml