From 5b1f96876d812160ca5e65c7f0104631730b19a4 Mon Sep 17 00:00:00 2001 From: travisn Date: Tue, 30 Jan 2024 16:23:10 -0700 Subject: [PATCH 1/2] exporter: dont delete exporter service on daemon deletion The exporter service and service monitor should not be deleted if an individual daemon is being removed from a node. As long as the exporter is enabled with v18 and newer, the exporter service and service monitor should exist. Clusters were seeing their metrics stop collection when the exporter service and service monitor would disappear, especially when multiple clusters are configured. Signed-off-by: travisn (cherry picked from commit a1fc70f2fcb591c69c3effa075d5fe89d809a581) (cherry picked from commit af513df7c4b907ce5fde8629229f6239ca3da800) --- pkg/operator/ceph/cluster/nodedaemon/reconcile.go | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/pkg/operator/ceph/cluster/nodedaemon/reconcile.go b/pkg/operator/ceph/cluster/nodedaemon/reconcile.go index efb53bfa6847..a620c048efca 100644 --- a/pkg/operator/ceph/cluster/nodedaemon/reconcile.go +++ b/pkg/operator/ceph/cluster/nodedaemon/reconcile.go @@ -85,12 +85,12 @@ func (r *ReconcileNode) Reconcile(context context.Context, request reconcile.Req return result, err } -func (r *ReconcileNode) cleanupExporterResources(clusterNamespace string, ns string, nodeName string) (reconcile.Result, error) { +func (r *ReconcileNode) cleanupExporterResources(ns string, nodeName string) (reconcile.Result, error) { err := k8sutil.DeleteServiceMonitor(r.context, r.opManagerContext, ns, cephExporterAppName) if err != nil { logger.Debugf("failed to delete service monitor for ceph exporter in namespace %q on node %q. %v", ns, nodeName, err) } - err = k8sutil.DeleteService(r.opManagerContext, r.context.Clientset, r.opConfig.OperatorNamespace, cephExporterAppName) + err = k8sutil.DeleteService(r.opManagerContext, r.context.Clientset, ns, cephExporterAppName) if err != nil { return reconcile.Result{}, errors.Wrapf(err, "failed to delete ceph exporter metrics service in namespace %q on node %q", ns, nodeName) } @@ -207,10 +207,6 @@ func (r *ReconcileNode) reconcile(request reconcile.Request) (reconcile.Result, if err != nil { return reconcile.Result{}, errors.Wrapf(err, "failed to list and delete deployments in namespace %q on node %q", namespace, request.Name) } - result, err := r.cleanupExporterResources(cephCluster.Namespace, namespace, request.Name) - if err != nil { - return result, errors.Wrapf(err, "failed to cleanup exporter resources in namespace %q on node %q", namespace, request.Name) - } } // Cleanup exporter if the ceph version isn't supported if !cephVersion.IsAtLeast(MinVersionForCephExporter) { @@ -219,7 +215,7 @@ func (r *ReconcileNode) reconcile(request reconcile.Request) (reconcile.Result, if err := r.listDeploymentAndDelete(cephExporterAppName, request.Name, namespace); err != nil { return reconcile.Result{}, errors.Wrap(err, "failed to delete ceph-exporter") } - result, err := r.cleanupExporterResources(cephCluster.Namespace, namespace, request.Name) + result, err := r.cleanupExporterResources(namespace, request.Name) if err != nil { return result, errors.Wrapf(err, "failed to cleanup exporter resources in namespace %q on node %q", namespace, request.Name) } From 89f1837d433b6293fe36a479bbc22b667a673919 Mon Sep 17 00:00:00 2001 From: parth-gr Date: Tue, 30 Jan 2024 20:01:18 +0530 Subject: [PATCH 2/2] ci: reformat the python scripts currently there is a new release of black formatter so updating it with new release Closes: https://github.com/rook/rook/issues/13630 Signe-off-by: parth-gr Signed-off-by: parth-gr (cherry picked from commit 75fcffd08cf841e10753e53ef528529494719671) (cherry picked from commit 6812215dbd39d71dd2e078cc8057a421dd05b6d6) --- .../create-external-cluster-resources.py | 73 +++++++++---------- tests/scripts/pythonwebserver/server.py | 1 + 2 files changed, 37 insertions(+), 37 deletions(-) diff --git a/deploy/examples/create-external-cluster-resources.py b/deploy/examples/create-external-cluster-resources.py index 43b1499be242..0cf27d2559c2 100644 --- a/deploy/examples/create-external-cluster-resources.py +++ b/deploy/examples/create-external-cluster-resources.py @@ -99,22 +99,22 @@ def _init_cmd_output_map(self): ) as json_file: ceph_status_str = json_file.read() self.cmd_names["fs ls"] = """{"format": "json", "prefix": "fs ls"}""" - self.cmd_names[ - "quorum_status" - ] = """{"format": "json", "prefix": "quorum_status"}""" - self.cmd_names[ - "mgr services" - ] = """{"format": "json", "prefix": "mgr services"}""" + self.cmd_names["quorum_status"] = ( + """{"format": "json", "prefix": "quorum_status"}""" + ) + self.cmd_names["mgr services"] = ( + """{"format": "json", "prefix": "mgr services"}""" + ) # all the commands and their output - self.cmd_output_map[ - self.cmd_names["fs ls"] - ] = """[{"name":"myfs","metadata_pool":"myfs-metadata","metadata_pool_id":2,"data_pool_ids":[3],"data_pools":["myfs-replicated"]}]""" - self.cmd_output_map[ - self.cmd_names["quorum_status"] - ] = """{"election_epoch":3,"quorum":[0],"quorum_names":["a"],"quorum_leader_name":"a","quorum_age":14385,"features":{"quorum_con":"4540138292836696063","quorum_mon":["kraken","luminous","mimic","osdmap-prune","nautilus","octopus"]},"monmap":{"epoch":1,"fsid":"af4e1673-0b72-402d-990a-22d2919d0f1c","modified":"2020-05-07T03:36:39.918035Z","created":"2020-05-07T03:36:39.918035Z","min_mon_release":15,"min_mon_release_name":"octopus","features":{"persistent":["kraken","luminous","mimic","osdmap-prune","nautilus","octopus"],"optional":[]},"mons":[{"rank":0,"name":"a","public_addrs":{"addrvec":[{"type":"v2","addr":"10.110.205.174:3300","nonce":0},{"type":"v1","addr":"10.110.205.174:6789","nonce":0}]},"addr":"10.110.205.174:6789/0","public_addr":"10.110.205.174:6789/0","priority":0,"weight":0}]}}""" - self.cmd_output_map[ - self.cmd_names["mgr services"] - ] = """{"dashboard":"https://ceph-dashboard:8443/","prometheus":"http://ceph-dashboard-db:9283/"}""" + self.cmd_output_map[self.cmd_names["fs ls"]] = ( + """[{"name":"myfs","metadata_pool":"myfs-metadata","metadata_pool_id":2,"data_pool_ids":[3],"data_pools":["myfs-replicated"]}]""" + ) + self.cmd_output_map[self.cmd_names["quorum_status"]] = ( + """{"election_epoch":3,"quorum":[0],"quorum_names":["a"],"quorum_leader_name":"a","quorum_age":14385,"features":{"quorum_con":"4540138292836696063","quorum_mon":["kraken","luminous","mimic","osdmap-prune","nautilus","octopus"]},"monmap":{"epoch":1,"fsid":"af4e1673-0b72-402d-990a-22d2919d0f1c","modified":"2020-05-07T03:36:39.918035Z","created":"2020-05-07T03:36:39.918035Z","min_mon_release":15,"min_mon_release_name":"octopus","features":{"persistent":["kraken","luminous","mimic","osdmap-prune","nautilus","octopus"],"optional":[]},"mons":[{"rank":0,"name":"a","public_addrs":{"addrvec":[{"type":"v2","addr":"10.110.205.174:3300","nonce":0},{"type":"v1","addr":"10.110.205.174:6789","nonce":0}]},"addr":"10.110.205.174:6789/0","public_addr":"10.110.205.174:6789/0","priority":0,"weight":0}]}}""" + ) + self.cmd_output_map[self.cmd_names["mgr services"]] = ( + """{"dashboard":"https://ceph-dashboard:8443/","prometheus":"http://ceph-dashboard-db:9283/"}""" + ) self.cmd_output_map[ """{"caps": ["mon", "allow r, allow command quorum_status", "osd", "profile rbd-read-only, allow rwx pool=default.rgw.meta, allow r pool=.rgw.root, allow rw pool=default.rgw.control, allow x pool=default.rgw.buckets.index"], "entity": "client.healthchecker", "format": "json", "prefix": "auth get-or-create"}""" ] = """[{"entity":"client.healthchecker","key":"AQDFkbNeft5bFRAATndLNUSEKruozxiZi3lrdA==","caps":{"mon":"allow r, allow command quorum_status","osd":"profile rbd-read-only, allow rwx pool=default.rgw.meta, allow r pool=.rgw.root, allow rw pool=default.rgw.control, allow x pool=default.rgw.buckets.index"}}]""" @@ -142,9 +142,9 @@ def _init_cmd_output_map(self): self.cmd_output_map[ """{"caps": ["mon", "allow r, allow command quorum_status, allow command version", "mgr", "allow command config", "osd", "profile rbd-read-only, allow rwx pool=default.rgw.meta, allow r pool=.rgw.root, allow rw pool=default.rgw.control, allow rx pool=default.rgw.log, allow x pool=default.rgw.buckets.index"], "entity": "client.healthchecker", "format": "json", "prefix": "auth caps"}""" ] = """[{"entity":"client.healthchecker","key":"AQDFkbNeft5bFRAATndLNUSRKruozxiZi3lrdA==","caps":{"mon": "allow r, allow command quorum_status, allow command version", "mgr": "allow command config", "osd": "profile rbd-read-only, allow rwx pool=default.rgw.meta, allow r pool=.rgw.root, allow rw pool=default.rgw.control, allow rx pool=default.rgw.log, allow x pool=default.rgw.buckets.index"}}]""" - self.cmd_output_map[ - """{"format": "json", "prefix": "mgr services"}""" - ] = """{"dashboard": "http://rook-ceph-mgr-a-57cf9f84bc-f4jnl:7000/", "prometheus": "http://rook-ceph-mgr-a-57cf9f84bc-f4jnl:9283/"}""" + self.cmd_output_map["""{"format": "json", "prefix": "mgr services"}"""] = ( + """{"dashboard": "http://rook-ceph-mgr-a-57cf9f84bc-f4jnl:7000/", "prometheus": "http://rook-ceph-mgr-a-57cf9f84bc-f4jnl:9283/"}""" + ) self.cmd_output_map[ """{"entity": "client.healthchecker", "format": "json", "prefix": "auth get"}""" ] = """{"dashboard": "http://rook-ceph-mgr-a-57cf9f84bc-f4jnl:7000/", "prometheus": "http://rook-ceph-mgr-a-57cf9f84bc-f4jnl:9283/"}""" @@ -218,7 +218,6 @@ def Rados(conffile=None): class S3Auth(AuthBase): - """Attaches AWS Authentication to the given Request object.""" service_base_url = "s3.amazonaws.com" @@ -954,9 +953,9 @@ def get_rbd_provisioner_caps_and_entity(self): rados_namespace, ) if rados_namespace != "": - caps[ - "osd" - ] = f"profile rbd pool={rbd_pool_name} namespace={rados_namespace}" + caps["osd"] = ( + f"profile rbd pool={rbd_pool_name} namespace={rados_namespace}" + ) else: caps["osd"] = f"profile rbd pool={rbd_pool_name}" @@ -989,9 +988,9 @@ def get_rbd_node_caps_and_entity(self): rados_namespace, ) if rados_namespace != "": - caps[ - "osd" - ] = f"profile rbd pool={rbd_pool_name} namespace={rados_namespace}" + caps["osd"] = ( + f"profile rbd pool={rbd_pool_name} namespace={rados_namespace}" + ) else: caps["osd"] = f"profile rbd pool={rbd_pool_name}" @@ -1534,13 +1533,13 @@ def _gen_output_map(self): self.out_map["CSI_RBD_PROVISIONER_SECRET_NAME"], ) = self.create_cephCSIKeyring_user("client.csi-rbd-provisioner") self.out_map["CEPHFS_POOL_NAME"] = self._arg_parser.cephfs_data_pool_name - self.out_map[ - "CEPHFS_METADATA_POOL_NAME" - ] = self._arg_parser.cephfs_metadata_pool_name + self.out_map["CEPHFS_METADATA_POOL_NAME"] = ( + self._arg_parser.cephfs_metadata_pool_name + ) self.out_map["CEPHFS_FS_NAME"] = self._arg_parser.cephfs_filesystem_name - self.out_map[ - "RESTRICTED_AUTH_PERMISSION" - ] = self._arg_parser.restricted_auth_permission + self.out_map["RESTRICTED_AUTH_PERMISSION"] = ( + self._arg_parser.restricted_auth_permission + ) self.out_map["RADOS_NAMESPACE"] = self._arg_parser.rados_namespace self.out_map["SUBVOLUME_GROUP"] = self._arg_parser.subvolume_group self.out_map["CSI_CEPHFS_NODE_SECRET"] = "" @@ -1583,9 +1582,9 @@ def _gen_output_map(self): self.out_map["MONITORING_ENDPOINT_PORT"], ) = self.get_active_and_standby_mgrs() self.out_map["RBD_POOL_NAME"] = self._arg_parser.rbd_data_pool_name - self.out_map[ - "RBD_METADATA_EC_POOL_NAME" - ] = self.validate_rbd_metadata_ec_pool_name() + self.out_map["RBD_METADATA_EC_POOL_NAME"] = ( + self.validate_rbd_metadata_ec_pool_name() + ) self.out_map["RGW_POOL_PREFIX"] = self._arg_parser.rgw_pool_prefix self.out_map["RGW_ENDPOINT"] = "" if self._arg_parser.rgw_endpoint: @@ -1624,9 +1623,9 @@ def _gen_output_map(self): ) = self.create_rgw_admin_ops_user() err = self.validate_rgw_endpoint(info_cap_supported) if self._arg_parser.rgw_tls_cert_path: - self.out_map[ - "RGW_TLS_CERT" - ] = self.validate_rgw_endpoint_tls_cert() + self.out_map["RGW_TLS_CERT"] = ( + self.validate_rgw_endpoint_tls_cert() + ) # if there is no error, set the RGW_ENDPOINT if err != "-1": self.out_map["RGW_ENDPOINT"] = self._arg_parser.rgw_endpoint diff --git a/tests/scripts/pythonwebserver/server.py b/tests/scripts/pythonwebserver/server.py index a9c3590011b4..eb2c841b0c69 100644 --- a/tests/scripts/pythonwebserver/server.py +++ b/tests/scripts/pythonwebserver/server.py @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. """ + #!/usr/bin/env python3 """ Very simple HTTP server in python for logging requests