You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@nifi.apache.org by GitBox <gi...@apache.org> on 2022/07/19 07:14:59 UTC

[GitHub] [nifi-minifi-cpp] fgerlits opened a new pull request, #1373: MINIFICPP-1851 Collect pod metrics in Kubernetes

fgerlits opened a new pull request, #1373:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1373

   https://issues.apache.org/jira/browse/MINIFICPP-1851
   
   ---
   
   Thank you for submitting a contribution to Apache NiFi - MiNiFi C++.
   
   In order to streamline the review of the contribution we ask you
   to ensure the following steps have been taken:
   
   ### For all changes:
   - [x] Is there a JIRA ticket associated with this PR? Is it referenced
        in the commit message?
   
   - [x] Does your PR title start with MINIFICPP-XXXX where XXXX is the JIRA number you are trying to resolve? Pay particular attention to the hyphen "-" character.
   
   - [x] Has your PR been rebased against the latest commit within the target branch (typically main)?
   
   - [ ] Is your initial contribution a single, squashed commit?
   
   ### For code changes:
   - [ ] If adding new dependencies to the code, are these dependencies licensed in a way that is compatible for inclusion under [ASF 2.0](http://www.apache.org/legal/resolved.html#category-a)?
   - [ ] If applicable, have you updated the LICENSE file?
   - [ ] If applicable, have you updated the NOTICE file?
   
   ### For documentation related changes:
   - [ ] Have you ensured that format looks appropriate for the output in which it is rendered?
   
   ### Note:
   Please ensure that once the PR is submitted, you check GitHub Actions CI results for build issues and submit an update to your PR as soon as possible.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [nifi-minifi-cpp] adamdebreceni commented on a diff in pull request #1373: MINIFICPP-1851 Collect pod metrics in Kubernetes

Posted by GitBox <gi...@apache.org>.
adamdebreceni commented on code in PR #1373:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1373#discussion_r926699838


##########
extensions/kubernetes/MetricsFilter.h:
##########
@@ -0,0 +1,30 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#pragma once
+
+#include <functional>
+#include <string>
+
+#include "utils/expected.h"
+
+namespace org::apache::nifi::minifi::kubernetes::metrics {
+
+[[nodiscard]] nonstd::expected<std::string, std::string> filter(
+    const std::string& metrics_json,
+    const std::function<bool(const std::string& name_space, const std::string& pod_name, const std::string& container_name)>& filter_function);

Review Comment:
   I'm not sure how I feel about the filter function's type, specifically the three `std::string` parameters, given how we construct the lambda and how we forward to another function taking three `std::string`s (`KubernetesControllerService::matchesRegexFilters`), I think we could wrap this in some kind of `ContainerInfo` struct, it could also make it easier to later add other things we would like to filter on (maybe labels?)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [nifi-minifi-cpp] szaszm commented on a diff in pull request #1373: MINIFICPP-1851 Collect pod metrics in Kubernetes

Posted by GitBox <gi...@apache.org>.
szaszm commented on code in PR #1373:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1373#discussion_r929381281


##########
extensions/kubernetes/MetricsApi.cpp:
##########
@@ -0,0 +1,47 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#include "MetricsApi.h"
+
+#include <memory>
+
+extern "C" {
+#include "include/generic.h"
+}
+
+#include "ApiClient.h"
+
+namespace {
+struct genericClient_t_deleter { void operator()(genericClient_t* ptr) const noexcept { genericClient_free(ptr); } };
+using genericClient_unique_ptr = std::unique_ptr<genericClient_t, genericClient_t_deleter>;
+
+struct char_deleter { void operator()(char* ptr) const noexcept { free(ptr); } };
+using char_unique_ptr = std::unique_ptr<char, char_deleter>;

Review Comment:
   You can use `utils::FreeDeleter` here. `char*` vs `void*` is not an issue, it gets converted and freed normally.



##########
extensions/kubernetes/MetricsFilter.cpp:
##########
@@ -0,0 +1,81 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#include "MetricsFilter.h"
+
+#include "rapidjson/document.h"
+#include "rapidjson/error/en.h"
+#include "rapidjson/stringbuffer.h"
+#include "rapidjson/writer.h"
+#include "utils/StringUtils.h"
+
+namespace org::apache::nifi::minifi::kubernetes::metrics {
+
+nonstd::expected<std::string, std::string> filter(const std::string& metrics_json, const std::function<bool(const kubernetes::ContainerInfo&)>& filter_function) {
+  rapidjson::Document document;
+  rapidjson::ParseResult parse_result = document.Parse<rapidjson::kParseStopWhenDoneFlag>(metrics_json.data());
+  if (parse_result.IsError()) {
+    return nonstd::make_unexpected(utils::StringUtils::join_pack("Error parsing the metrics received from the Kubernetes API at offset ",
+        std::to_string(parse_result.Offset()), ": ", rapidjson::GetParseError_En(parse_result.Code())));
+  }
+
+  if (!document.HasMember("items") || !document["items"].IsArray()) {
+    return nonstd::make_unexpected("Unexpected JSON received from the Kubernetes API: missing list of 'items'");

Review Comment:
   Using expected like this is fine, but it would be nicer if you introduced an error category and error codes for the extension, and used `std::error_code` instead. It's totally fine if you don't want to do it, just a thought.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [nifi-minifi-cpp] adamdebreceni commented on a diff in pull request #1373: MINIFICPP-1851 Collect pod metrics in Kubernetes

Posted by GitBox <gi...@apache.org>.
adamdebreceni commented on code in PR #1373:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1373#discussion_r926621783


##########
extensions/kubernetes/ApiClient.cpp:
##########
@@ -0,0 +1,53 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#include "ApiClient.h"
+
+extern "C" {
+#include "config/incluster_config.h"
+#include "config/kube_config.h"
+#include "include/apiClient.h"
+}
+
+#include "utils/StringUtils.h"
+
+namespace {
+
+gsl::not_null<apiClient_t*> createApiClient(char **base_path, sslConfig_t** ssl_config, list_t** api_keys) {
+  int rc = load_incluster_config(base_path, ssl_config, api_keys);
+  if (rc != 0) {
+    throw std::runtime_error(org::apache::nifi::minifi::utils::StringUtils::join_pack("load_incluster_config() failed with error code ", std::to_string(rc)));
+  }
+  const auto api_client = apiClient_create_with_base_path(*base_path, *ssl_config, *api_keys);
+  if (!api_client) {
+    throw std::runtime_error("apiClient_create_with_base_path() failed");
+  }
+  return gsl::make_not_null(api_client);
+}
+
+}  // namespace
+
+namespace org::apache::nifi::minifi::kubernetes {
+
+ApiClient::ApiClient() : api_client_(createApiClient(&base_path_, &ssl_config_, &api_keys_)) {}

Review Comment:
   while this is safe in its current form, if the order of members were to change, this could break, I think either a comment in the header, that the order of members should not change (or that `api_client_` must come after others), or moving this initialization to the body of the constructor could help



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [nifi-minifi-cpp] fgerlits commented on a diff in pull request #1373: MINIFICPP-1851 Collect pod metrics in Kubernetes

Posted by GitBox <gi...@apache.org>.
fgerlits commented on code in PR #1373:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1373#discussion_r926832741


##########
extensions/kubernetes/MetricsFilter.h:
##########
@@ -0,0 +1,30 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#pragma once
+
+#include <functional>
+#include <string>
+
+#include "utils/expected.h"
+
+namespace org::apache::nifi::minifi::kubernetes::metrics {
+
+[[nodiscard]] nonstd::expected<std::string, std::string> filter(
+    const std::string& metrics_json,
+    const std::function<bool(const std::string& name_space, const std::string& pod_name, const std::string& container_name)>& filter_function);

Review Comment:
   Yes, I agree that is more readable.  Changed in 4e9944adebd8b6800d1e35dd00cb76ac85d00f7d.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [nifi-minifi-cpp] fgerlits commented on a diff in pull request #1373: MINIFICPP-1851 Collect pod metrics in Kubernetes

Posted by GitBox <gi...@apache.org>.
fgerlits commented on code in PR #1373:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1373#discussion_r932386844


##########
extensions/kubernetes/MetricsApi.cpp:
##########
@@ -0,0 +1,47 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#include "MetricsApi.h"
+
+#include <memory>
+
+extern "C" {
+#include "include/generic.h"
+}
+
+#include "ApiClient.h"
+
+namespace {
+struct genericClient_t_deleter { void operator()(genericClient_t* ptr) const noexcept { genericClient_free(ptr); } };
+using genericClient_unique_ptr = std::unique_ptr<genericClient_t, genericClient_t_deleter>;
+
+struct char_deleter { void operator()(char* ptr) const noexcept { free(ptr); } };
+using char_unique_ptr = std::unique_ptr<char, char_deleter>;

Review Comment:
   fixed in ebfa8b42bbebbac3c74adb2875c66ad003a458bb



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [nifi-minifi-cpp] fgerlits commented on a diff in pull request #1373: MINIFICPP-1851 Collect pod metrics in Kubernetes

Posted by GitBox <gi...@apache.org>.
fgerlits commented on code in PR #1373:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1373#discussion_r926647992


##########
extensions/kubernetes/ApiClient.cpp:
##########
@@ -0,0 +1,53 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#include "ApiClient.h"
+
+extern "C" {
+#include "config/incluster_config.h"
+#include "config/kube_config.h"
+#include "include/apiClient.h"
+}
+
+#include "utils/StringUtils.h"
+
+namespace {
+
+gsl::not_null<apiClient_t*> createApiClient(char **base_path, sslConfig_t** ssl_config, list_t** api_keys) {
+  int rc = load_incluster_config(base_path, ssl_config, api_keys);
+  if (rc != 0) {
+    throw std::runtime_error(org::apache::nifi::minifi::utils::StringUtils::join_pack("load_incluster_config() failed with error code ", std::to_string(rc)));
+  }
+  const auto api_client = apiClient_create_with_base_path(*base_path, *ssl_config, *api_keys);
+  if (!api_client) {
+    throw std::runtime_error("apiClient_create_with_base_path() failed");
+  }
+  return gsl::make_not_null(api_client);
+}
+
+}  // namespace
+
+namespace org::apache::nifi::minifi::kubernetes {
+
+ApiClient::ApiClient() : api_client_(createApiClient(&base_path_, &ssl_config_, &api_keys_)) {}

Review Comment:
   Good point.  If it was in the body of the constructor, it couldn't be marked `gsl::not_null`, so I added a comment instead.  https://github.com/apache/nifi-minifi-cpp/pull/1373/commits/58fb3ddeb8e35322c17c8fb1d49ffc0ca57d90ac



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [nifi-minifi-cpp] fgerlits commented on a diff in pull request #1373: MINIFICPP-1851 Collect pod metrics in Kubernetes

Posted by GitBox <gi...@apache.org>.
fgerlits commented on code in PR #1373:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1373#discussion_r926648440


##########
extensions/kubernetes/ApiClient.h:
##########
@@ -0,0 +1,48 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#pragma once
+
+#include <string>
+
+#include "utils/gsl.h"
+
+struct apiClient_t;
+struct list_t;
+struct sslConfig_t;
+
+namespace org::apache::nifi::minifi::kubernetes {
+
+class ApiClient {
+ public:
+  ApiClient();
+  ~ApiClient() noexcept;
+
+  ApiClient(ApiClient&&) = delete;
+  ApiClient(const ApiClient&) = delete;
+  ApiClient& operator=(ApiClient&&) = delete;
+  ApiClient& operator=(const ApiClient&) = delete;
+
+  [[nodiscard]] gsl::not_null<apiClient_t*> getClient() const noexcept { return api_client_; }
+
+ private:
+  char* base_path_ = nullptr;
+  sslConfig_t* ssl_config_ = nullptr;
+  list_t* api_keys_ = nullptr;
+  gsl::not_null<apiClient_t*> api_client_;

Review Comment:
   I have added `gsl::owner` annotations in https://github.com/apache/nifi-minifi-cpp/pull/1373/commits/58fb3ddeb8e35322c17c8fb1d49ffc0ca57d90ac



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [nifi-minifi-cpp] adamdebreceni commented on a diff in pull request #1373: MINIFICPP-1851 Collect pod metrics in Kubernetes

Posted by GitBox <gi...@apache.org>.
adamdebreceni commented on code in PR #1373:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1373#discussion_r926623139


##########
extensions/kubernetes/ApiClient.h:
##########
@@ -0,0 +1,48 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#pragma once
+
+#include <string>
+
+#include "utils/gsl.h"
+
+struct apiClient_t;
+struct list_t;
+struct sslConfig_t;
+
+namespace org::apache::nifi::minifi::kubernetes {
+
+class ApiClient {
+ public:
+  ApiClient();
+  ~ApiClient() noexcept;
+
+  ApiClient(ApiClient&&) = delete;
+  ApiClient(const ApiClient&) = delete;
+  ApiClient& operator=(ApiClient&&) = delete;
+  ApiClient& operator=(const ApiClient&) = delete;
+
+  [[nodiscard]] gsl::not_null<apiClient_t*> getClient() const noexcept { return api_client_; }
+
+ private:
+  char* base_path_ = nullptr;
+  sslConfig_t* ssl_config_ = nullptr;
+  list_t* api_keys_ = nullptr;
+  gsl::not_null<apiClient_t*> api_client_;

Review Comment:
   the objects behind these pointers seem to be managed by `ApiClient`, should we wrap then in `gsl::owner`?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [nifi-minifi-cpp] fgerlits commented on a diff in pull request #1373: MINIFICPP-1851 Collect pod metrics in Kubernetes

Posted by GitBox <gi...@apache.org>.
fgerlits commented on code in PR #1373:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1373#discussion_r932390028


##########
extensions/kubernetes/MetricsFilter.cpp:
##########
@@ -0,0 +1,81 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#include "MetricsFilter.h"
+
+#include "rapidjson/document.h"
+#include "rapidjson/error/en.h"
+#include "rapidjson/stringbuffer.h"
+#include "rapidjson/writer.h"
+#include "utils/StringUtils.h"
+
+namespace org::apache::nifi::minifi::kubernetes::metrics {
+
+nonstd::expected<std::string, std::string> filter(const std::string& metrics_json, const std::function<bool(const kubernetes::ContainerInfo&)>& filter_function) {
+  rapidjson::Document document;
+  rapidjson::ParseResult parse_result = document.Parse<rapidjson::kParseStopWhenDoneFlag>(metrics_json.data());
+  if (parse_result.IsError()) {
+    return nonstd::make_unexpected(utils::StringUtils::join_pack("Error parsing the metrics received from the Kubernetes API at offset ",
+        std::to_string(parse_result.Offset()), ": ", rapidjson::GetParseError_En(parse_result.Code())));
+  }
+
+  if (!document.HasMember("items") || !document["items"].IsArray()) {
+    return nonstd::make_unexpected("Unexpected JSON received from the Kubernetes API: missing list of 'items'");

Review Comment:
   Since we only use this from one place, and the only thing we do with the error is log it, I would leave it as it is for now.  We can refine it later.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [nifi-minifi-cpp] szaszm closed pull request #1373: MINIFICPP-1851 Collect pod metrics in Kubernetes

Posted by GitBox <gi...@apache.org>.
szaszm closed pull request #1373: MINIFICPP-1851 Collect pod metrics in Kubernetes
URL: https://github.com/apache/nifi-minifi-cpp/pull/1373


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org