Fix the following error:

  • Cannot use object of type Maclof\Kubernetes\Models\Node as array in Drupal\k8s\Service\K8sService->updateEntities() (line 1223 of /var/www/html/docroot/cloudorchestrator/docroot/modules/contrib/cloud/modules/cloud_service_providers/k8s/src/Service/K8sService.php)
  • Cannot use object of type Maclof\Kubernetes\Models\Pod as array in Drupal\k8s\Service\K8sBatchOperations::updateNode() (line 115 of /var/www/html/docroot/cloudorchestrator/docroot/modules/contrib/cloud/modules/cloud_service_providers/k8s/src/Service/K8sBatchOperations.php)
  • Cannot use object of type Drupal\k8s\Service\K8sClientExtension\Models\K8sMetricsNodeModel as array in k8s_export_node_metrics() (line 735 of /var/www/html/docroot/cloudorchestrator/docroot/modules/contrib/cloud/modules/cloud_service_providers/k8s/k8s.module)
  • Cannot use object of type Drupal\k8s\Service\K8sClientExtension\Models\K8sMetricsNodeModel as array in Drupal\k8s\Service\K8sBatchOperations::updateNode() (line 167 of /var/www/html/docroot/cloudorchestrator/docroot/modules/contrib/cloud/modules/cloud_service_providers/k8s/src/Service/K8sBatchOperations.php)
  • Cannot use object of type Drupal\k8s\Service\K8sClientExtension\Models\K8sMetricsPodModel as array in k8s_export_pod_metrics() (line 759 of /var/www/html/docroot/cloudorchestrator/docroot/modules/contrib/cloud/modules/cloud_service_providers/k8s/k8s.module)
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

jigish.addweb created an issue. See original summary.

jigish.addweb’s picture

Issue summary: View changes
yas’s picture

jigish.addweb’s picture

jigish.addweb’s picture

Status: Active » Needs review
jigish.addweb’s picture

yas’s picture

@jigishaddweb

Thank you for fixing the issue. Could you please change the following code? Note that this is just an example, there are some similar codes in the patch.

FROM:

diff --git a/modules/cloud_service_providers/k8s/src/Service/K8sBatchOperations.php b/modules/cloud_service_providers/k8s/src/Service/K8sBatchOperations.php

+    $name = !empty($pod['metadata']['name']) ? $pod['metadata']['name'] : '';
+    $namespace = !empty($pod['metadata']['namespace']) ? $pod['metadata']['namespace'] : '';

TO:

    $name = !empty($pod['metadata']['name']) ?: '';
    $namespace = !empty($pod['metadata']['namespace']) ?:  '';

FROM:
   foreach ($metrics_nodes as $metrics_node) {
   foreach ($metrics_pods as $metrics_pod) {
     foreach ($pods as $pod) {
       foreach ($result as $entity) {

TO:

   foreach ($metrics_nodes ?: [] as $metrics_node) {
   foreach ($metrics_pods ?: [] as $metrics_pod) {
     foreach ($pods ?: [] as $pod) {
       foreach ($result ?: [] as $entity) {

@xiaohua-guan
@baldwinlouie
@masami

Could you please review the patch?

jigish.addweb’s picture

yas’s picture

FileSize
832.17 KB
822.28 KB

@jigishaddweb

The tests of the patch #8 for K8s has been passed successfully as the following screenshots:

screenshot-2019-11-29a.png
screenshot-2019-11-29b.png

Xiaohua Guan’s picture

@yas @jigishaddweb

Thanks for the patch file. It looks good to me.

  • yas committed b210aae on 8.x-2.x authored by jigish.addweb
    Issue #3095973 by jigish.addweb, yas, Xiaohua Guan: Fix K8s Service...
yas’s picture

Status: Needs review » Reviewed & tested by the community
yas’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.